2002-02-25 18:48:30 +00:00
|
|
|
/*
|
|
|
|
*******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
* file name: props2.c
|
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2002feb24
|
|
|
|
* created by: Markus W. Scherer
|
|
|
|
*
|
|
|
|
* Parse more Unicode Character Database files and store
|
|
|
|
* additional Unicode character properties in bit set vectors.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "unicode/utypes.h"
|
2002-03-02 02:26:19 +00:00
|
|
|
#include "unicode/uchar.h"
|
2002-03-01 01:58:49 +00:00
|
|
|
#include "unicode/uscript.h"
|
2002-02-25 18:48:30 +00:00
|
|
|
#include "cstring.h"
|
|
|
|
#include "cmemory.h"
|
|
|
|
#include "utrie.h"
|
|
|
|
#include "uprops.h"
|
|
|
|
#include "propsvec.h"
|
|
|
|
#include "uparse.h"
|
|
|
|
#include "genprops.h"
|
|
|
|
|
2003-03-04 00:40:44 +00:00
|
|
|
#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
|
2002-03-06 23:31:11 +00:00
|
|
|
|
2002-02-25 18:48:30 +00:00
|
|
|
/* data --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static UNewTrie *trie;
|
2002-07-04 17:08:34 +00:00
|
|
|
uint32_t *pv;
|
2002-02-25 18:48:30 +00:00
|
|
|
static int32_t pvCount;
|
|
|
|
|
2003-03-04 00:40:44 +00:00
|
|
|
/* miscellaneous ------------------------------------------------------------ */
|
2002-03-04 01:34:58 +00:00
|
|
|
|
2003-03-04 00:40:44 +00:00
|
|
|
static char *
|
|
|
|
trimTerminateField(char *s, char *limit) {
|
|
|
|
/* trim leading whitespace */
|
|
|
|
s=(char *)u_skipWhitespace(s);
|
|
|
|
|
|
|
|
/* trim trailing whitespace */
|
|
|
|
while(s<limit && (*(limit-1)==' ' || *(limit-1)=='\t')) {
|
|
|
|
--limit;
|
|
|
|
}
|
|
|
|
*limit=0;
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
2002-02-25 18:48:30 +00:00
|
|
|
|
|
|
|
static void
|
2002-03-02 02:26:19 +00:00
|
|
|
parseTwoFieldFile(char *filename, char *basename,
|
|
|
|
const char *ucdFile, const char *suffix,
|
|
|
|
UParseLineFn *lineFn,
|
2003-03-04 00:40:44 +00:00
|
|
|
UErrorCode *pErrorCode) {
|
|
|
|
char *fields[2][2];
|
|
|
|
|
|
|
|
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
writeUCDFilename(basename, ucdFile, suffix);
|
|
|
|
|
|
|
|
u_parseDelimitedFile(filename, ';', fields, 2, lineFn, NULL, pErrorCode);
|
|
|
|
if(U_FAILURE(*pErrorCode)) {
|
|
|
|
fprintf(stderr, "error parsing %s.txt: %s\n", ucdFile, u_errorName(*pErrorCode));
|
|
|
|
}
|
|
|
|
}
|
2002-02-25 18:48:30 +00:00
|
|
|
|
2002-07-23 23:01:08 +00:00
|
|
|
static void U_CALLCONV
|
2002-03-02 02:26:19 +00:00
|
|
|
ageLineFn(void *context,
|
|
|
|
char *fields[][2], int32_t fieldCount,
|
|
|
|
UErrorCode *pErrorCode);
|
|
|
|
|
2003-03-04 00:40:44 +00:00
|
|
|
/* parse files with single enumerated properties ---------------------------- */
|
|
|
|
|
|
|
|
struct SingleEnum {
|
|
|
|
const char *ucdFile, *propName;
|
|
|
|
UProperty prop;
|
|
|
|
int32_t vecWord, vecShift;
|
|
|
|
uint32_t vecMask;
|
|
|
|
};
|
|
|
|
typedef struct SingleEnum SingleEnum;
|
|
|
|
|
|
|
|
static void
|
|
|
|
parseSingleEnumFile(char *filename, char *basename, const char *suffix,
|
|
|
|
const SingleEnum *sen,
|
|
|
|
UErrorCode *pErrorCode);
|
|
|
|
|
|
|
|
static const SingleEnum scriptSingleEnum={
|
|
|
|
"Scripts", "script",
|
|
|
|
UCHAR_SCRIPT,
|
|
|
|
0, 0, UPROPS_SCRIPT_MASK
|
|
|
|
};
|
|
|
|
|
|
|
|
static const SingleEnum blockSingleEnum={
|
|
|
|
"Blocks", "block",
|
|
|
|
UCHAR_BLOCK,
|
|
|
|
0, UPROPS_BLOCK_SHIFT, UPROPS_BLOCK_MASK
|
|
|
|
};
|
|
|
|
|
|
|
|
static const SingleEnum lineBreakSingleEnum={
|
|
|
|
"LineBreak", "line break",
|
|
|
|
UCHAR_LINE_BREAK,
|
|
|
|
0, UPROPS_LB_SHIFT, UPROPS_LB_MASK
|
|
|
|
};
|
|
|
|
|
|
|
|
static const SingleEnum eawSingleEnum={
|
|
|
|
"EastAsianWidth", "east asian width",
|
|
|
|
UCHAR_EAST_ASIAN_WIDTH,
|
|
|
|
0, UPROPS_EA_SHIFT, UPROPS_EA_MASK
|
|
|
|
};
|
2002-03-02 02:26:19 +00:00
|
|
|
|
2003-03-07 21:43:18 +00:00
|
|
|
static const SingleEnum jtSingleEnum={
|
|
|
|
"DerivedJoiningType", "joining type",
|
|
|
|
UCHAR_JOINING_TYPE,
|
|
|
|
2, UPROPS_JT_SHIFT, UPROPS_JT_MASK
|
|
|
|
};
|
|
|
|
|
|
|
|
static const SingleEnum jgSingleEnum={
|
|
|
|
"DerivedJoiningGroup", "joining group",
|
|
|
|
UCHAR_JOINING_GROUP,
|
|
|
|
2, UPROPS_JG_SHIFT, UPROPS_JG_MASK
|
|
|
|
};
|
|
|
|
|
2002-07-23 23:01:08 +00:00
|
|
|
static void U_CALLCONV
|
2003-03-04 00:40:44 +00:00
|
|
|
singleEnumLineFn(void *context,
|
|
|
|
char *fields[][2], int32_t fieldCount,
|
|
|
|
UErrorCode *pErrorCode) {
|
|
|
|
const SingleEnum *sen;
|
|
|
|
char *s;
|
|
|
|
uint32_t start, limit, uv;
|
|
|
|
int32_t value;
|
|
|
|
|
|
|
|
sen=(const SingleEnum *)context;
|
|
|
|
|
|
|
|
u_parseCodePointRange(fields[0][0], &start, &limit, pErrorCode);
|
|
|
|
if(U_FAILURE(*pErrorCode)) {
|
|
|
|
fprintf(stderr, "genprops: syntax error in %s.txt field 0 at %s\n", sen->ucdFile, fields[0][0]);
|
|
|
|
exit(*pErrorCode);
|
|
|
|
}
|
|
|
|
++limit;
|
|
|
|
|
|
|
|
/* parse property alias */
|
|
|
|
s=trimTerminateField(fields[1][0], fields[1][1]);
|
|
|
|
value=u_getPropertyValueEnum(sen->prop, s);
|
|
|
|
if(value<0) {
|
|
|
|
if(sen->prop==UCHAR_BLOCK) {
|
|
|
|
if(isToken("Greek", s)) {
|
|
|
|
value=UBLOCK_GREEK; /* Unicode 3.2 renames this to "Greek and Coptic" */
|
|
|
|
} else if(isToken("Combining Marks for Symbols", s)) {
|
|
|
|
value=UBLOCK_COMBINING_MARKS_FOR_SYMBOLS; /* Unicode 3.2 renames this to "Combining Diacritical Marks for Symbols" */
|
|
|
|
} else if(isToken("Private Use", s)) {
|
|
|
|
value=UBLOCK_PRIVATE_USE; /* Unicode 3.2 renames this to "Private Use Area" */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(value<0) {
|
|
|
|
fprintf(stderr, "genprops error: unknown %s name in %s.txt field 1 at %s\n",
|
|
|
|
sen->propName, sen->ucdFile, s);
|
|
|
|
exit(U_PARSE_ERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
uv=(uint32_t)(value<<sen->vecShift);
|
|
|
|
if((uv&sen->vecMask)!=uv) {
|
|
|
|
fprintf(stderr, "genprops error: %s value overflow (0x%x) at %s\n",
|
|
|
|
sen->propName, uv, s);
|
|
|
|
exit(U_INTERNAL_PROGRAM_ERROR);
|
|
|
|
}
|
|
|
|
|
2003-03-07 21:43:18 +00:00
|
|
|
if(!upvec_setValue(pv, start, limit, sen->vecWord, uv, sen->vecMask, pErrorCode)) {
|
2003-03-04 00:40:44 +00:00
|
|
|
fprintf(stderr, "genprops error: unable to set %s code: %s\n",
|
|
|
|
sen->propName, u_errorName(*pErrorCode));
|
|
|
|
exit(*pErrorCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
parseSingleEnumFile(char *filename, char *basename, const char *suffix,
|
|
|
|
const SingleEnum *sen,
|
|
|
|
UErrorCode *pErrorCode) {
|
|
|
|
char *fields[2][2];
|
|
|
|
|
|
|
|
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
writeUCDFilename(basename, sen->ucdFile, suffix);
|
|
|
|
|
|
|
|
u_parseDelimitedFile(filename, ';', fields, 2, singleEnumLineFn, (void *)sen, pErrorCode);
|
|
|
|
if(U_FAILURE(*pErrorCode)) {
|
|
|
|
fprintf(stderr, "error parsing %s.txt: %s\n", sen->ucdFile, u_errorName(*pErrorCode));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* parse files with multiple binary properties ------------------------------ */
|
|
|
|
|
|
|
|
struct Binary {
|
|
|
|
const char *propName;
|
|
|
|
int32_t vecWord, vecShift;
|
|
|
|
};
|
|
|
|
typedef struct Binary Binary;
|
|
|
|
|
|
|
|
struct Binaries {
|
|
|
|
const char *ucdFile;
|
|
|
|
const Binary *binaries;
|
|
|
|
int32_t binariesCount;
|
|
|
|
};
|
|
|
|
typedef struct Binaries Binaries;
|
|
|
|
|
|
|
|
static const Binary
|
|
|
|
propListNames[]={
|
|
|
|
{ "White_Space", 1, UPROPS_WHITE_SPACE },
|
|
|
|
{ "Bidi_Control", 1, UPROPS_BIDI_CONTROL },
|
|
|
|
{ "Join_Control", 1, UPROPS_JOIN_CONTROL },
|
|
|
|
{ "Dash", 1, UPROPS_DASH },
|
|
|
|
{ "Hyphen", 1, UPROPS_HYPHEN },
|
|
|
|
{ "Quotation_Mark", 1, UPROPS_QUOTATION_MARK },
|
|
|
|
{ "Terminal_Punctuation", 1, UPROPS_TERMINAL_PUNCTUATION },
|
|
|
|
{ "Hex_Digit", 1, UPROPS_HEX_DIGIT },
|
|
|
|
{ "ASCII_Hex_Digit", 1, UPROPS_ASCII_HEX_DIGIT },
|
|
|
|
{ "Ideographic", 1, UPROPS_IDEOGRAPHIC },
|
|
|
|
{ "Diacritic", 1, UPROPS_DIACRITIC },
|
|
|
|
{ "Extender", 1, UPROPS_EXTENDER },
|
|
|
|
{ "Noncharacter_Code_Point", 1, UPROPS_NONCHARACTER_CODE_POINT },
|
|
|
|
{ "Grapheme_Link", 1, UPROPS_GRAPHEME_LINK },
|
|
|
|
{ "IDS_Binary_Operator", 1, UPROPS_IDS_BINARY_OPERATOR },
|
|
|
|
{ "IDS_Trinary_Operator", 1, UPROPS_IDS_TRINARY_OPERATOR },
|
|
|
|
{ "Radical", 1, UPROPS_RADICAL },
|
|
|
|
{ "Unified_Ideograph", 1, UPROPS_UNIFIED_IDEOGRAPH },
|
|
|
|
{ "Deprecated", 1, UPROPS_DEPRECATED },
|
|
|
|
{ "Soft_Dotted", 1, UPROPS_SOFT_DOTTED },
|
2003-03-07 21:43:18 +00:00
|
|
|
{ "Logical_Order_Exception", 1, UPROPS_LOGICAL_ORDER_EXCEPTION }
|
2003-03-04 00:40:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const Binaries
|
|
|
|
propListBinaries={
|
|
|
|
"PropList", propListNames, LENGTHOF(propListNames)
|
|
|
|
};
|
|
|
|
|
|
|
|
static const Binary
|
|
|
|
derCorePropsNames[]={
|
|
|
|
{ "XID_Start", 1, UPROPS_XID_START },
|
2003-03-07 21:43:18 +00:00
|
|
|
{ "XID_Continue", 1, UPROPS_XID_CONTINUE },
|
|
|
|
|
|
|
|
/* before Unicode 4/ICU 2.6/format version 3.2, these used to be Other_XYZ from PropList.txt */
|
|
|
|
{ "Math", 1, UPROPS_MATH },
|
|
|
|
{ "Alphabetic", 1, UPROPS_ALPHABETIC },
|
|
|
|
{ "Lowercase", 1, UPROPS_LOWERCASE },
|
|
|
|
{ "Uppercase", 1, UPROPS_UPPERCASE },
|
|
|
|
{ "Grapheme_Extend", 1, UPROPS_GRAPHEME_EXTEND },
|
|
|
|
{ "Default_Ignorable_Code_Point", 1, UPROPS_DEFAULT_IGNORABLE_CODE_POINT },
|
|
|
|
|
|
|
|
/* new properties bits in ICU 2.6/format version 3.2 */
|
|
|
|
{ "ID_Start", 1, UPROPS_ID_START },
|
|
|
|
{ "ID_Continue", 1, UPROPS_ID_CONTINUE },
|
|
|
|
{ "Grapheme_Base", 1, UPROPS_GRAPHEME_BASE }
|
2003-03-04 00:40:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const Binaries
|
|
|
|
derCorePropsBinaries={
|
|
|
|
"DerivedCoreProperties", derCorePropsNames, LENGTHOF(derCorePropsNames)
|
|
|
|
};
|
|
|
|
|
|
|
|
static char ignoredProps[100][64];
|
|
|
|
static int32_t ignoredPropsCount;
|
|
|
|
|
|
|
|
static void
|
|
|
|
addIgnoredProp(char *s, char *limit) {
|
|
|
|
int32_t i;
|
|
|
|
|
|
|
|
s=trimTerminateField(s, limit);
|
|
|
|
for(i=0; i<ignoredPropsCount; ++i) {
|
|
|
|
if(0==uprv_strcmp(ignoredProps[i], s)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
uprv_strcpy(ignoredProps[ignoredPropsCount++], s);
|
|
|
|
}
|
2002-03-02 02:26:19 +00:00
|
|
|
|
2002-07-23 23:01:08 +00:00
|
|
|
static void U_CALLCONV
|
2003-03-04 00:40:44 +00:00
|
|
|
binariesLineFn(void *context,
|
2002-03-02 02:26:19 +00:00
|
|
|
char *fields[][2], int32_t fieldCount,
|
2003-03-04 00:40:44 +00:00
|
|
|
UErrorCode *pErrorCode) {
|
|
|
|
const Binaries *bin;
|
|
|
|
char *s;
|
|
|
|
uint32_t start, limit, uv;
|
|
|
|
int32_t i;
|
2002-03-01 01:58:49 +00:00
|
|
|
|
2003-03-04 00:40:44 +00:00
|
|
|
bin=(const Binaries *)context;
|
2002-03-06 23:31:11 +00:00
|
|
|
|
2003-03-04 00:40:44 +00:00
|
|
|
u_parseCodePointRange(fields[0][0], &start, &limit, pErrorCode);
|
|
|
|
if(U_FAILURE(*pErrorCode)) {
|
|
|
|
fprintf(stderr, "genprops: syntax error in %s.txt field 0 at %s\n", bin->ucdFile, fields[0][0]);
|
|
|
|
exit(*pErrorCode);
|
|
|
|
}
|
|
|
|
++limit;
|
2002-03-04 01:34:58 +00:00
|
|
|
|
2003-03-04 00:40:44 +00:00
|
|
|
/* parse binary property name */
|
|
|
|
s=(char *)u_skipWhitespace(fields[1][0]);
|
|
|
|
for(i=0;; ++i) {
|
|
|
|
if(i==bin->binariesCount) {
|
|
|
|
/* ignore unrecognized properties */
|
|
|
|
addIgnoredProp(s, fields[1][1]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(isToken(bin->binaries[i].propName, s)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(bin->binaries[i].vecShift>=32) {
|
|
|
|
fprintf(stderr, "genprops error: shift value %d>=32 for %s %s\n",
|
|
|
|
bin->binaries[i].vecShift, bin->ucdFile, bin->binaries[i].propName);
|
|
|
|
exit(U_INTERNAL_PROGRAM_ERROR);
|
|
|
|
}
|
|
|
|
uv=U_MASK(bin->binaries[i].vecShift);
|
|
|
|
|
|
|
|
if(!upvec_setValue(pv, start, limit, bin->binaries[i].vecWord, uv, uv, pErrorCode)) {
|
|
|
|
fprintf(stderr, "genprops error: unable to set %s code: %s\n",
|
|
|
|
bin->binaries[i].propName, u_errorName(*pErrorCode));
|
|
|
|
exit(*pErrorCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
parseBinariesFile(char *filename, char *basename, const char *suffix,
|
|
|
|
const Binaries *bin,
|
|
|
|
UErrorCode *pErrorCode) {
|
|
|
|
char *fields[2][2];
|
|
|
|
int32_t i;
|
|
|
|
|
|
|
|
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
writeUCDFilename(basename, bin->ucdFile, suffix);
|
|
|
|
|
|
|
|
ignoredPropsCount=0;
|
|
|
|
|
|
|
|
u_parseDelimitedFile(filename, ';', fields, 2, binariesLineFn, (void *)bin, pErrorCode);
|
|
|
|
if(U_FAILURE(*pErrorCode)) {
|
|
|
|
fprintf(stderr, "error parsing %s.txt: %s\n", bin->ucdFile, u_errorName(*pErrorCode));
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0; i<ignoredPropsCount; ++i) {
|
|
|
|
printf("genprops: ignoring property %s in %s.txt\n", ignoredProps[i], bin->ucdFile);
|
|
|
|
}
|
|
|
|
}
|
2002-07-04 17:08:34 +00:00
|
|
|
|
2002-02-25 18:48:30 +00:00
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
2002-03-04 01:34:58 +00:00
|
|
|
U_CFUNC void
|
|
|
|
initAdditionalProperties() {
|
|
|
|
pv=upvec_open(UPROPS_VECTOR_WORDS, 20000);
|
|
|
|
}
|
|
|
|
|
2002-02-25 18:48:30 +00:00
|
|
|
U_CFUNC void
|
|
|
|
generateAdditionalProperties(char *filename, const char *suffix, UErrorCode *pErrorCode) {
|
|
|
|
char *basename;
|
|
|
|
|
|
|
|
basename=filename+uprv_strlen(filename);
|
|
|
|
|
2002-03-01 01:58:49 +00:00
|
|
|
/* process various UCD .txt files */
|
2002-03-02 02:26:19 +00:00
|
|
|
parseTwoFieldFile(filename, basename, "DerivedAge", suffix, ageLineFn, pErrorCode);
|
2002-02-25 18:48:30 +00:00
|
|
|
|
2002-03-06 23:31:11 +00:00
|
|
|
/*
|
|
|
|
* UTR 24 says:
|
|
|
|
* Section 2:
|
|
|
|
* "Common - For characters that may be used
|
|
|
|
* within multiple scripts,
|
|
|
|
* or any unassigned code points."
|
|
|
|
*
|
|
|
|
* Section 4:
|
|
|
|
* "The value COMMON is the default value,
|
|
|
|
* given to all code points that are not
|
|
|
|
* explicitly mentioned in the data file."
|
2003-03-07 21:43:18 +00:00
|
|
|
*
|
|
|
|
* COMMON==USCRIPT_COMMON==0 - nothing to do
|
2002-03-06 23:31:11 +00:00
|
|
|
*/
|
2003-03-04 00:40:44 +00:00
|
|
|
parseSingleEnumFile(filename, basename, suffix, &scriptSingleEnum, pErrorCode);
|
|
|
|
|
|
|
|
parseSingleEnumFile(filename, basename, suffix, &blockSingleEnum, pErrorCode);
|
2002-03-02 02:26:19 +00:00
|
|
|
|
2003-03-04 00:40:44 +00:00
|
|
|
parseBinariesFile(filename, basename, suffix, &propListBinaries, pErrorCode);
|
2002-03-01 01:58:49 +00:00
|
|
|
|
2003-03-04 00:40:44 +00:00
|
|
|
parseBinariesFile(filename, basename, suffix, &derCorePropsBinaries, pErrorCode);
|
2002-03-06 23:31:11 +00:00
|
|
|
|
2003-03-07 21:43:18 +00:00
|
|
|
/*
|
|
|
|
* LineBreak-4.0.0.txt:
|
|
|
|
* - All code points, assigned and unassigned, that are not listed
|
|
|
|
* explicitly are given the value "XX".
|
|
|
|
*
|
|
|
|
* XX==U_LB_UNKNOWN==0 - nothing to do
|
|
|
|
*/
|
2003-03-04 00:40:44 +00:00
|
|
|
parseSingleEnumFile(filename, basename, suffix, &lineBreakSingleEnum, pErrorCode);
|
2002-07-04 17:08:34 +00:00
|
|
|
|
2003-03-07 21:43:18 +00:00
|
|
|
parseSingleEnumFile(filename, basename, suffix, &jtSingleEnum, pErrorCode);
|
|
|
|
|
|
|
|
parseSingleEnumFile(filename, basename, suffix, &jgSingleEnum, pErrorCode);
|
2002-07-04 17:08:34 +00:00
|
|
|
|
2002-03-04 01:34:58 +00:00
|
|
|
/*
|
|
|
|
* Preset East Asian Width defaults:
|
2003-03-07 21:43:18 +00:00
|
|
|
*
|
|
|
|
* http://www.unicode.org/reports/tr11/#Unassigned
|
|
|
|
* 7.1 Unassigned and Private Use characters
|
|
|
|
*
|
|
|
|
* All unassigned characters are by default classified as non-East Asian neutral,
|
|
|
|
* except for the range U+20000 to U+2FFFD,
|
|
|
|
* since all code positions from U+20000 to U+2FFFD are intended for CJK ideographs (W).
|
|
|
|
* All Private use characters are by default classified as ambiguous,
|
|
|
|
* since their definition depends on context.
|
|
|
|
*
|
|
|
|
* N for all ==0 - nothing to do
|
2002-03-04 01:34:58 +00:00
|
|
|
* A for Private Use
|
|
|
|
* W for plane 2
|
|
|
|
*/
|
2002-07-04 17:08:34 +00:00
|
|
|
*pErrorCode=U_ZERO_ERROR;
|
2003-03-07 21:43:18 +00:00
|
|
|
if( !upvec_setValue(pv, 0xe000, 0xf900, 0, (uint32_t)(U_EA_AMBIGUOUS<<UPROPS_EA_SHIFT), UPROPS_EA_MASK, pErrorCode) ||
|
2002-07-04 17:08:34 +00:00
|
|
|
!upvec_setValue(pv, 0xf0000, 0xffffe, 0, (uint32_t)(U_EA_AMBIGUOUS<<UPROPS_EA_SHIFT), UPROPS_EA_MASK, pErrorCode) ||
|
|
|
|
!upvec_setValue(pv, 0x100000, 0x10fffe, 0, (uint32_t)(U_EA_AMBIGUOUS<<UPROPS_EA_SHIFT), UPROPS_EA_MASK, pErrorCode) ||
|
|
|
|
!upvec_setValue(pv, 0x20000, 0x2fffe, 0, (uint32_t)(U_EA_WIDE<<UPROPS_EA_SHIFT), UPROPS_EA_MASK, pErrorCode)
|
2002-03-04 01:34:58 +00:00
|
|
|
) {
|
|
|
|
fprintf(stderr, "genprops: unable to set default East Asian Widths: %s\n", u_errorName(*pErrorCode));
|
|
|
|
exit(*pErrorCode);
|
|
|
|
}
|
2003-03-04 00:40:44 +00:00
|
|
|
|
2002-03-04 01:34:58 +00:00
|
|
|
/* parse EastAsianWidth.txt */
|
2003-03-04 00:40:44 +00:00
|
|
|
parseSingleEnumFile(filename, basename, suffix, &eawSingleEnum, pErrorCode);
|
2002-03-04 01:34:58 +00:00
|
|
|
|
2003-03-07 21:43:18 +00:00
|
|
|
trie=utrie_open(NULL, NULL, 50000, 0, TRUE);
|
2002-02-25 18:48:30 +00:00
|
|
|
if(trie==NULL) {
|
|
|
|
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
|
|
|
|
upvec_close(pv);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pvCount=upvec_toTrie(pv, trie, pErrorCode);
|
|
|
|
if(U_FAILURE(*pErrorCode)) {
|
|
|
|
fprintf(stderr, "genprops error: unable to build trie for additional properties: %s\n", u_errorName(*pErrorCode));
|
|
|
|
exit(*pErrorCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-01 01:58:49 +00:00
|
|
|
/* DerivedAge.txt ----------------------------------------------------------- */
|
|
|
|
|
2002-07-23 23:01:08 +00:00
|
|
|
static void U_CALLCONV
|
2002-02-25 18:48:30 +00:00
|
|
|
ageLineFn(void *context,
|
|
|
|
char *fields[][2], int32_t fieldCount,
|
|
|
|
UErrorCode *pErrorCode) {
|
|
|
|
char *s, *end;
|
|
|
|
uint32_t value, start, limit, version;
|
|
|
|
|
|
|
|
u_parseCodePointRange(fields[0][0], &start, &limit, pErrorCode);
|
|
|
|
if(U_FAILURE(*pErrorCode)) {
|
|
|
|
fprintf(stderr, "genprops: syntax error in DerivedAge.txt field 0 at %s\n", fields[0][0]);
|
|
|
|
exit(*pErrorCode);
|
|
|
|
}
|
|
|
|
++limit;
|
|
|
|
|
|
|
|
/* parse version number */
|
|
|
|
s=(char *)u_skipWhitespace(fields[1][0]);
|
|
|
|
value=(uint32_t)uprv_strtoul(s, &end, 10);
|
|
|
|
if(s==end || value==0 || value>15 || (*end!='.' && *end!=' ' && *end!='\t' && *end!=0)) {
|
|
|
|
fprintf(stderr, "genprops: syntax error in DerivedAge.txt field 1 at %s\n", fields[1][0]);
|
|
|
|
*pErrorCode=U_PARSE_ERROR;
|
|
|
|
exit(U_PARSE_ERROR);
|
|
|
|
}
|
|
|
|
version=value<<4;
|
|
|
|
|
|
|
|
/* parse minor version number */
|
|
|
|
if(*end=='.') {
|
|
|
|
s=(char *)u_skipWhitespace(end+1);
|
|
|
|
value=(uint32_t)uprv_strtoul(s, &end, 10);
|
|
|
|
if(s==end || value>15 || (*end!=' ' && *end!='\t' && *end!=0)) {
|
|
|
|
fprintf(stderr, "genprops: syntax error in DerivedAge.txt field 1 at %s\n", fields[1][0]);
|
|
|
|
*pErrorCode=U_PARSE_ERROR;
|
|
|
|
exit(U_PARSE_ERROR);
|
|
|
|
}
|
|
|
|
version|=value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!upvec_setValue(pv, start, limit, 0, version<<UPROPS_AGE_SHIFT, UPROPS_AGE_MASK, pErrorCode)) {
|
2002-03-04 01:34:58 +00:00
|
|
|
fprintf(stderr, "genprops error: unable to set character age: %s\n", u_errorName(*pErrorCode));
|
2002-02-25 18:48:30 +00:00
|
|
|
exit(*pErrorCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-01 01:58:49 +00:00
|
|
|
/* data serialization ------------------------------------------------------- */
|
|
|
|
|
2002-02-25 18:48:30 +00:00
|
|
|
U_CFUNC int32_t
|
2002-02-25 22:41:40 +00:00
|
|
|
writeAdditionalData(uint8_t *p, int32_t capacity, int32_t indexes[UPROPS_INDEX_COUNT]) {
|
2002-02-25 18:48:30 +00:00
|
|
|
int32_t length;
|
|
|
|
UErrorCode errorCode;
|
|
|
|
|
|
|
|
errorCode=U_ZERO_ERROR;
|
|
|
|
length=utrie_serialize(trie, p, capacity, getFoldedPropsValue, TRUE, &errorCode);
|
|
|
|
if(U_FAILURE(errorCode)) {
|
|
|
|
fprintf(stderr, "genprops error: unable to serialize trie for additional properties: %s\n", u_errorName(errorCode));
|
|
|
|
exit(errorCode);
|
|
|
|
}
|
|
|
|
if(p!=NULL) {
|
|
|
|
p+=length;
|
|
|
|
capacity-=length;
|
|
|
|
if(beVerbose) {
|
|
|
|
printf("size in bytes of additional props trie:%5u\n", length);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set indexes */
|
|
|
|
indexes[UPROPS_ADDITIONAL_VECTORS_INDEX]=
|
|
|
|
indexes[UPROPS_ADDITIONAL_TRIE_INDEX]+length/4;
|
2002-02-25 22:41:40 +00:00
|
|
|
indexes[UPROPS_ADDITIONAL_VECTORS_COLUMNS_INDEX]=UPROPS_VECTOR_WORDS;
|
2002-03-01 01:58:49 +00:00
|
|
|
indexes[UPROPS_RESERVED_INDEX]=
|
|
|
|
indexes[UPROPS_ADDITIONAL_VECTORS_INDEX]+pvCount;
|
2002-07-04 17:08:34 +00:00
|
|
|
|
|
|
|
indexes[UPROPS_MAX_VALUES_INDEX]=
|
2003-03-07 21:43:18 +00:00
|
|
|
(((int32_t)U_LB_COUNT-1)<<UPROPS_LB_SHIFT)|
|
|
|
|
(((int32_t)U_EA_COUNT-1)<<UPROPS_EA_SHIFT)|
|
2002-07-04 17:08:34 +00:00
|
|
|
(((int32_t)UBLOCK_COUNT-1)<<UPROPS_BLOCK_SHIFT)|
|
|
|
|
((int32_t)USCRIPT_CODE_LIMIT-1);
|
2003-03-07 21:43:18 +00:00
|
|
|
indexes[UPROPS_MAX_VALUES_2_INDEX]=
|
|
|
|
(((int32_t)U_JT_COUNT-1)<<UPROPS_JT_SHIFT)|
|
|
|
|
(((int32_t)U_JG_COUNT-1)<<UPROPS_JG_SHIFT)|
|
|
|
|
((int32_t)U_DT_COUNT-1);
|
2002-02-25 18:48:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(p!=NULL && (pvCount*4)<=capacity) {
|
|
|
|
uprv_memcpy(p, pv, pvCount*4);
|
|
|
|
if(beVerbose) {
|
|
|
|
printf("number of additional props vectors: %5u\n", pvCount/UPROPS_VECTOR_WORDS);
|
2002-02-25 22:41:40 +00:00
|
|
|
printf("number of 32-bit words per vector: %5u\n", UPROPS_VECTOR_WORDS);
|
2002-02-25 18:48:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
length+=pvCount*4;
|
|
|
|
|
|
|
|
if(p!=NULL) {
|
|
|
|
utrie_close(trie);
|
|
|
|
upvec_close(pv);
|
|
|
|
}
|
|
|
|
return length;
|
|
|
|
}
|