mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-8972 various small fixes & improvements
X-SVN-Rev: 31136
This commit is contained in:
parent
26baae9070
commit
d25c4ca662
7 changed files with 57 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010, International Business Machines
|
||||
* Copyright (C) 2010-2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* file name: charstr.cpp
|
||||
|
@ -127,4 +127,19 @@ UBool CharString::ensureCapacity(int32_t capacity,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
CharString &CharString::appendPathPart(const StringPiece &s, UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return *this;
|
||||
}
|
||||
if(s.length()==0) {
|
||||
return *this;
|
||||
}
|
||||
char c;
|
||||
if(len>0 && (c=buffer[len-1])!=U_FILE_SEP_CHAR && c!=U_FILE_ALT_SEP_CHAR) {
|
||||
append(U_FILE_SEP_CHAR, errorCode);
|
||||
}
|
||||
append(s, errorCode);
|
||||
return *this;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
|
|
@ -107,6 +107,13 @@ public:
|
|||
|
||||
CharString &appendInvariantChars(const UnicodeString &s, UErrorCode &errorCode);
|
||||
|
||||
/**
|
||||
* Appends a filename/path part, e.g., a directory name.
|
||||
* First appends a U_FILE_SEP_CHAR if necessary.
|
||||
* Does nothing if s is empty.
|
||||
*/
|
||||
CharString &appendPathPart(const StringPiece &s, UErrorCode &errorCode);
|
||||
|
||||
private:
|
||||
MaybeStackArray<char, 40> buffer;
|
||||
int32_t len;
|
||||
|
|
|
@ -2033,7 +2033,7 @@ u_versionFromUString(UVersionInfo versionArray, const UChar *versionString) {
|
|||
}
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
u_versionToString(UVersionInfo versionArray, char *versionString) {
|
||||
u_versionToString(const UVersionInfo versionArray, char *versionString) {
|
||||
uint16_t count, part;
|
||||
uint8_t field;
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ u_versionFromUString(UVersionInfo versionArray, const UChar *versionString);
|
|||
* @stable ICU 2.4
|
||||
*/
|
||||
U_STABLE void U_EXPORT2
|
||||
u_versionToString(UVersionInfo versionArray, char *versionString);
|
||||
u_versionToString(const UVersionInfo versionArray, char *versionString);
|
||||
|
||||
/**
|
||||
* Gets the ICU release version. The version array stores the version information
|
||||
|
|
|
@ -17195,7 +17195,7 @@ cp;ABF8;-Alpha;gc=Nd;-IDS;InSC=Other;lb=NU;na=MEETEI MAYEK DIGIT EIGHT;nt=De;nv=
|
|||
cp;ABF9;-Alpha;gc=Nd;-IDS;InSC=Other;lb=NU;na=MEETEI MAYEK DIGIT NINE;nt=De;nv=9;SB=NU;WB=NU;-XIDS
|
||||
cp;ABFA..ABFF;age=NA;-Alpha;gc=Cn;-Gr_Base;-IDC;-IDS;InSC=Other;lb=XX;SB=XX;sc=Zzzz;WB=XX;-XIDC;-XIDS
|
||||
|
||||
block;AC00..D7AF;age=2.0;Alpha;blk=Hangul;ea=W;gc=Lo;GCB=LVT;Gr_Base;IDC;IDS;lb=H3;NFD_QC=N;NFKD_QC=N;SB=LE;sc=Hang;WB=LE;XIDC;XIDS
|
||||
block;AC00..D7AF;age=2.0;Alpha;blk=Hangul;dt=Can;ea=W;gc=Lo;GCB=LVT;Gr_Base;IDC;IDS;lb=H3;NFD_QC=N;NFKD_QC=N;SB=LE;sc=Hang;WB=LE;XIDC;XIDS
|
||||
# AC00..D7A3 Hangul Syllables
|
||||
algnamesrange;AC00..D7A3;hangul
|
||||
cp;AC00;GCB=LV;lb=H2
|
||||
|
@ -17597,7 +17597,7 @@ cp;D734;GCB=LV;lb=H2
|
|||
cp;D750;GCB=LV;lb=H2
|
||||
cp;D76C;GCB=LV;lb=H2
|
||||
cp;D788;GCB=LV;lb=H2
|
||||
cp;D7A4..D7AF;age=NA;-Alpha;ea=N;gc=Cn;GCB=XX;-Gr_Base;-IDC;-IDS;lb=XX;NFD_QC=Y;NFKD_QC=Y;SB=XX;sc=Zzzz;WB=XX;-XIDC;-XIDS
|
||||
cp;D7A4..D7AF;age=NA;-Alpha;dt=None;ea=N;gc=Cn;GCB=XX;-Gr_Base;-IDC;-IDS;lb=XX;NFD_QC=Y;NFKD_QC=Y;SB=XX;sc=Zzzz;WB=XX;-XIDC;-XIDS
|
||||
|
||||
block;D7B0..D7FF;age=5.2;Alpha;blk=Jamo_Ext_B;ea=W;gc=Lo;GCB=T;Gr_Base;IDC;IDS;lb=JT;SB=LE;sc=Hang;WB=LE;XIDC;XIDS
|
||||
# D7B0..D7FF Hangul Jamo Extended-B
|
||||
|
|
|
@ -42,8 +42,8 @@ PropertyNames::getPropertyValueEnum(int32_t property, const char *name) const {
|
|||
UniProps::UniProps()
|
||||
: start(U_SENTINEL), end(U_SENTINEL),
|
||||
bmg(U_SENTINEL),
|
||||
numericValue(NULL),
|
||||
name(NULL), uni1Name(NULL), nameAlias(NULL) {
|
||||
digitValue(-1), numericValue(NULL),
|
||||
name(NULL), nameAlias(NULL) {
|
||||
memset(binProps, 0, sizeof(binProps));
|
||||
memset(intProps, 0, sizeof(intProps));
|
||||
memset(age, 0, 4);
|
||||
|
@ -94,7 +94,7 @@ static const char *lineTypeStrings[]={
|
|||
"property",
|
||||
"binary",
|
||||
"value",
|
||||
"default",
|
||||
"defaults",
|
||||
"block",
|
||||
"cp",
|
||||
"algnamesrange"
|
||||
|
@ -200,7 +200,7 @@ PreparsedUCD::getProps(UnicodeSet &newValues, UErrorCode &errorCode) {
|
|||
if(!parseCodePointRange(field, start, end, errorCode)) { return NULL; }
|
||||
UniProps *props;
|
||||
switch(lineType) {
|
||||
case DEFAULT_LINE:
|
||||
case DEFAULTS_LINE:
|
||||
if(defaultLineIndex>=0) {
|
||||
fprintf(stderr,
|
||||
"error in preparsed UCD: second line with default properties on line %ld\n",
|
||||
|
@ -322,26 +322,41 @@ PreparsedUCD::parseProperty(UniProps &props, const char *field, UnicodeSet &newV
|
|||
field, (long)lineNumber);
|
||||
errorCode=U_PARSE_ERROR;
|
||||
} else if(prop<UCHAR_INT_LIMIT) {
|
||||
int32_t value;
|
||||
if((value=pnames->getPropertyValueEnum(prop, v))==UCHAR_INVALID_CODE) {
|
||||
int32_t value=pnames->getPropertyValueEnum(prop, v);
|
||||
if(value==UCHAR_INVALID_CODE && prop==UCHAR_CANONICAL_COMBINING_CLASS) {
|
||||
// TODO: Make getPropertyValueEnum(UCHAR_CANONICAL_COMBINING_CLASS, v) work.
|
||||
char *end;
|
||||
unsigned long ccc=uprv_strtoul(v, &end, 10);
|
||||
if(v<end && *end==0 && ccc<=254) {
|
||||
value=(int32_t)ccc;
|
||||
}
|
||||
}
|
||||
if(value==UCHAR_INVALID_CODE) {
|
||||
fprintf(stderr,
|
||||
"error in preparsed UCD: '%s' is not a valid value on line %ld\n",
|
||||
field, (long)lineNumber);
|
||||
errorCode=U_PARSE_ERROR;
|
||||
} else {
|
||||
props.intProps[prop]=value;
|
||||
props.intProps[prop-UCHAR_INT_START]=value;
|
||||
}
|
||||
} else if(*v=='<' && lineType==DEFAULTS_LINE) {
|
||||
// Ignore default values like <code point>.
|
||||
return TRUE;
|
||||
} else {
|
||||
char c;
|
||||
switch(prop) {
|
||||
case UCHAR_NUMERIC_VALUE:
|
||||
props.numericValue=v;
|
||||
c=*v;
|
||||
if('0'<=c && c<='9' && v[1]==0) {
|
||||
props.digitValue=c-'0';
|
||||
} else {
|
||||
props.digitValue=-1;
|
||||
}
|
||||
break;
|
||||
case UCHAR_NAME:
|
||||
props.name=v;
|
||||
break;
|
||||
case UCHAR_UNICODE_1_NAME:
|
||||
props.uni1Name=v;
|
||||
break;
|
||||
case UCHAR_AGE:
|
||||
u_versionFromString(props.age, v); // Writes 0.0.0.0 if v is not numeric.
|
||||
break;
|
||||
|
|
|
@ -40,14 +40,16 @@ struct U_TOOLUTIL_API UniProps {
|
|||
UniProps();
|
||||
~UniProps();
|
||||
|
||||
int32_t getIntProp(int32_t prop) const { return intProps[prop-UCHAR_INT_START]; }
|
||||
|
||||
UChar32 start, end;
|
||||
UBool binProps[UCHAR_BINARY_LIMIT];
|
||||
int32_t intProps[UCHAR_INT_LIMIT-UCHAR_INT_START];
|
||||
UVersionInfo age;
|
||||
UChar32 bmg;
|
||||
int32_t digitValue;
|
||||
const char *numericValue;
|
||||
const char *name;
|
||||
const char *uni1Name;
|
||||
const char *nameAlias;
|
||||
UnicodeString cf;
|
||||
};
|
||||
|
@ -71,7 +73,7 @@ public:
|
|||
VALUE_LINE,
|
||||
|
||||
/** defaults;0000..10FFFF;age=NA;bc=L;... */
|
||||
DEFAULT_LINE,
|
||||
DEFAULTS_LINE,
|
||||
/** block;0000..007F;age=1.1;blk=ASCII;ea=Na;... */
|
||||
BLOCK_LINE,
|
||||
/** cp;0030;AHex;bc=EN;gc=Nd;na=DIGIT ZERO;... */
|
||||
|
@ -108,7 +110,7 @@ public:
|
|||
const UVersionInfo &getUnicodeVersion() const { return ucdVersion; }
|
||||
|
||||
/** Returns TRUE if the current line has property values. */
|
||||
UBool lineHasPropertyValues() const { return DEFAULT_LINE<=lineType && lineType<=CP_LINE; }
|
||||
UBool lineHasPropertyValues() const { return DEFAULTS_LINE<=lineType && lineType<=CP_LINE; }
|
||||
|
||||
/**
|
||||
* Parses properties from the current line.
|
||||
|
|
Loading…
Add table
Reference in a new issue