diff options
author | Craig Cornelius <ccornelius@google.com> | 2012-10-09 17:03:29 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2012-11-27 16:39:12 -0800 |
commit | 103e9ffba2cba345d0078eb8b8db33249f81840a (patch) | |
tree | 7db64141088188c7006e8027ff457a70742b824e /common/uchar.c | |
parent | 31315bc7a9f2672f87f2f7c7c7611c88e447a43a (diff) | |
download | icu4c-103e9ffba2cba345d0078eb8b8db33249f81840a.tar.gz |
ICU 49.2upgrade
(cherry-pick of 83a171d1a62abf406f7f44ae671823d5ec20db7d.)
Change-Id: I2f0f13293d9f47b4605c4ac173d1096dce2b8eb4
Diffstat (limited to 'common/uchar.c')
-rw-r--r-- | common/uchar.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/common/uchar.c b/common/uchar.c index 04dd60b8..9cb5f0db 100644 --- a/common/uchar.c +++ b/common/uchar.c @@ -1,6 +1,6 @@ /* ******************************************************************************** -* Copyright (C) 1996-2010, International Business Machines +* Copyright (C) 1996-2012, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************** * @@ -23,6 +23,7 @@ #include "unicode/uchar.h" #include "unicode/uscript.h" #include "unicode/udata.h" +#include "uassert.h" #include "umutex.h" #include "cmemory.h" #include "ucln_cmn.h" @@ -33,8 +34,9 @@ #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) -/* uchar_props_data.c is machine-generated by genprops --csource */ -#include "uchar_props_data.c" +/* uchar_props_data.h is machine-generated by genprops --csource */ +#define INCLUDED_FROM_UCHAR_C +#include "uchar_props_data.h" /* constants and macros for access to the data ------------------------------ */ @@ -475,7 +477,7 @@ u_forDigit(int32_t digit, int8_t radix) { } } -/* miscellaneous, and support for uprops.c ---------------------------------- */ +/* miscellaneous, and support for uprops.cpp -------------------------------- */ U_CAPI void U_EXPORT2 u_getUnicodeVersion(UVersionInfo versionArray) { @@ -485,19 +487,19 @@ u_getUnicodeVersion(UVersionInfo versionArray) { } U_CFUNC uint32_t -u_getUnicodeProperties(UChar32 c, int32_t column) { - uint16_t vecIndex; +u_getMainProperties(UChar32 c) { + uint32_t props; + GET_PROPS(c, props); + return props; +} - if(column==-1) { - uint32_t props; - GET_PROPS(c, props); - return props; - } else if( - column<0 || column>=propsVectorsColumns - ) { +U_CFUNC uint32_t +u_getUnicodeProperties(UChar32 c, int32_t column) { + U_ASSERT(column>=0); + if(column>=propsVectorsColumns) { return 0; } else { - vecIndex=UTRIE2_GET16(&propsVectorsTrie, c); + uint16_t vecIndex=UTRIE2_GET16(&propsVectorsTrie, c); return propsVectors[vecIndex+column]; } } @@ -548,7 +550,6 @@ uscript_getScript(UChar32 c, UErrorCode *pErrorCode) { U_DRAFT UBool U_EXPORT2 uscript_hasScript(UChar32 c, UScriptCode sc) { - UScriptCode script; const uint16_t *scx; uint32_t scriptX=u_getUnicodeProperties(c, 0)&UPROPS_SCRIPT_X_MASK; if(scriptX<UPROPS_SCRIPT_X_WITH_COMMON) { @@ -556,16 +557,12 @@ uscript_hasScript(UChar32 c, UScriptCode sc) { } scx=scriptExtensions+(scriptX&UPROPS_SCRIPT_MASK); - if(scriptX<UPROPS_SCRIPT_X_WITH_INHERITED) { - script=USCRIPT_COMMON; - } else if(scriptX<UPROPS_SCRIPT_X_WITH_OTHER) { - script=USCRIPT_INHERITED; - } else { - script=(UScriptCode)scx[0]; + if(scriptX>=UPROPS_SCRIPT_X_WITH_OTHER) { scx=scriptExtensions+scx[1]; } - if(sc==script) { - return TRUE; + if(sc>0x7fff) { + /* Guard against bogus input that would make us go past the Script_Extensions terminator. */ + return FALSE; } while(sc>*scx) { ++scx; @@ -590,14 +587,19 @@ uscript_getScriptExtensions(UChar32 c, } scriptX=u_getUnicodeProperties(c, 0)&UPROPS_SCRIPT_X_MASK; if(scriptX<UPROPS_SCRIPT_X_WITH_COMMON) { - return 0; + if(capacity==0) { + *pErrorCode=U_BUFFER_OVERFLOW_ERROR; + } else { + scripts[0]=(UScriptCode)scriptX; + } + return 1; } - length=0; scx=scriptExtensions+(scriptX&UPROPS_SCRIPT_MASK); if(scriptX>=UPROPS_SCRIPT_X_WITH_OTHER) { scx=scriptExtensions+scx[1]; } + length=0; do { sx=*scx++; if(length<capacity) { |