diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-05-11 13:04:25 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-05-11 13:04:25 +0200 |
commit | 784fb061643781b4b68d3c996e931339ae85be2b (patch) | |
tree | 89c38e923d5b2282fd6864d6e168a3aa78ab67e8 /libxsde | |
parent | 9c8e44df7f2ca4fb77e5725c4b81742e77d503b2 (diff) |
By default use abridges char table in serializer
Diffstat (limited to 'libxsde')
-rw-r--r-- | libxsde/xsde/c/genx/char-props.c | 30 | ||||
-rw-r--r-- | libxsde/xsde/c/genx/genx.c | 16 | ||||
-rw-r--r-- | libxsde/xsde/c/genx/genx.h | 6 |
3 files changed, 42 insertions, 10 deletions
diff --git a/libxsde/xsde/c/genx/char-props.c b/libxsde/xsde/c/genx/char-props.c index 0756fbd..123f4d5 100644 --- a/libxsde/xsde/c/genx/char-props.c +++ b/libxsde/xsde/c/genx/char-props.c @@ -29,15 +29,19 @@ void genxSetCharProps(char * p) { int i; - for (i = 0; i <= 0xffff; i++) + for (i = 0; i < GENX_CHAR_TABLE_SIZE; i++) p[i] = 0; /* per XML 1.0 */ charProp(p, 0x9, GENX_XML_CHAR); charProp(p, 0xa, GENX_XML_CHAR); charProp(p, 0xd, GENX_XML_CHAR); - rangeProp(p, 0x20, 0xd7ff, GENX_XML_CHAR); + rangeProp(p, 0x20, 0xff, GENX_XML_CHAR); + +#if GENX_CHAR_TABLE_SIZE == 0x10000 + rangeProp(p, 0x0100, 0xd7ff, GENX_XML_CHAR); rangeProp(p, 0xe000, 0xfffd, GENX_XML_CHAR); +#endif /* Letter ::= BaseChar | Ideographic */ rangeProp(p, 0x0041, 0x005A, GENX_LETTER|GENX_NAMECHAR); @@ -45,6 +49,9 @@ void genxSetCharProps(char * p) rangeProp(p, 0x00C0, 0x00D6, GENX_LETTER|GENX_NAMECHAR); rangeProp(p, 0x00D8, 0x00F6, GENX_LETTER|GENX_NAMECHAR); rangeProp(p, 0x00F8, 0x00FF, GENX_LETTER|GENX_NAMECHAR); + +#if GENX_CHAR_TABLE_SIZE == 0x10000 + rangeProp(p, 0x0100, 0x0131, GENX_LETTER|GENX_NAMECHAR); rangeProp(p, 0x0134, 0x013E, GENX_LETTER|GENX_NAMECHAR); rangeProp(p, 0x0141, 0x0148, GENX_LETTER|GENX_NAMECHAR); @@ -246,11 +253,22 @@ void genxSetCharProps(char * p) charProp(p, 0x3007, GENX_LETTER|GENX_NAMECHAR); rangeProp(p, 0x3021, 0x3029, GENX_LETTER|GENX_NAMECHAR); +#endif // GENX_CHAR_TABLE_SIZE == 0x10000 + /* * NameChar ::= * Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender */ + + charProp(p, '.', GENX_NAMECHAR); + charProp(p, '-', GENX_NAMECHAR); + charProp(p, '_', GENX_NAMECHAR); + rangeProp(p, 0x0030, 0x0039, GENX_NAMECHAR); + charProp(p, 0x00B7, GENX_LETTER|GENX_NAMECHAR); + +#if GENX_CHAR_TABLE_SIZE == 0x10000 + rangeProp(p, 0x0660, 0x0669, GENX_NAMECHAR); rangeProp(p, 0x06F0, 0x06F9, GENX_NAMECHAR); rangeProp(p, 0x0966, 0x096F, GENX_NAMECHAR); @@ -265,11 +283,6 @@ void genxSetCharProps(char * p) rangeProp(p, 0x0E50, 0x0E59, GENX_NAMECHAR); rangeProp(p, 0x0ED0, 0x0ED9, GENX_NAMECHAR); rangeProp(p, 0x0F20, 0x0F29, GENX_NAMECHAR); - - charProp(p, '.', GENX_NAMECHAR); - charProp(p, '-', GENX_NAMECHAR); - charProp(p, '_', GENX_NAMECHAR); - rangeProp(p, 0x0300, 0x0345, GENX_NAMECHAR); rangeProp(p, 0x0360, 0x0361, GENX_NAMECHAR); rangeProp(p, 0x0483, 0x0486, GENX_NAMECHAR); @@ -366,7 +379,6 @@ void genxSetCharProps(char * p) charProp(p, 0x3099, GENX_LETTER|GENX_NAMECHAR); charProp(p, 0x309A, GENX_LETTER|GENX_NAMECHAR); - charProp(p, 0x00B7, GENX_LETTER|GENX_NAMECHAR); charProp(p, 0x02D0, GENX_LETTER|GENX_NAMECHAR); charProp(p, 0x02D1, GENX_LETTER|GENX_NAMECHAR); charProp(p, 0x0387, GENX_LETTER|GENX_NAMECHAR); @@ -377,4 +389,6 @@ void genxSetCharProps(char * p) rangeProp(p, 0x3031, 0x3035, GENX_NAMECHAR); rangeProp(p, 0x309D, 0x309E, GENX_NAMECHAR); rangeProp(p, 0x30FC, 0x30FE, GENX_NAMECHAR); + +#endif // GENX_CHAR_TABLE_SIZE == 0x10000 } diff --git a/libxsde/xsde/c/genx/genx.c b/libxsde/xsde/c/genx/genx.c index 6596f81..bf998b3 100644 --- a/libxsde/xsde/c/genx/genx.c +++ b/libxsde/xsde/c/genx/genx.c @@ -115,7 +115,7 @@ struct genxWriter_rec genxSender * sender; genxStatus status; writerSequence sequence; - char xmlChars[0x10000]; + char xmlChars[GENX_CHAR_TABLE_SIZE]; void * userData; int nextPrefix; utf8 empty; @@ -502,7 +502,7 @@ static Boolean isXMLChar(genxWriter w, int c) { if (c < 0) return False; - else if (c < 0x10000) + else if (c < GENX_CHAR_TABLE_SIZE) return (int) w->xmlChars[c]; else return (c <= 0x10ffff); @@ -513,7 +513,13 @@ static Boolean isLetter(genxWriter w, int c) if (c < 0 || c > 0xffff) return False; else + { +#if GENX_CHAR_TABLE_SIZE == 0x10000 return w->xmlChars[c] & GENX_LETTER; +#else + return c < GENX_CHAR_TABLE_SIZE ? (w->xmlChars[c] & GENX_LETTER) : True; +#endif + } } static Boolean isNameChar(genxWriter w, int c) @@ -521,7 +527,13 @@ static Boolean isNameChar(genxWriter w, int c) if (c < 0 || c > 0xffff) return False; else + { +#if GENX_CHAR_TABLE_SIZE == 0x10000 return w->xmlChars[c] & GENX_NAMECHAR; +#else + return c < GENX_CHAR_TABLE_SIZE ? (w->xmlChars[c] & GENX_NAMECHAR) : True; +#endif + } } /******************************* diff --git a/libxsde/xsde/c/genx/genx.h b/libxsde/xsde/c/genx/genx.h index 8c7bc5a..5b155cc 100644 --- a/libxsde/xsde/c/genx/genx.h +++ b/libxsde/xsde/c/genx/genx.h @@ -55,6 +55,12 @@ typedef enum #define GENX_LETTER 2 #define GENX_NAMECHAR 4 +/* The size of the character table. Valid values are 0x100 (first 255 + chars are checked) and 0x10000 (all chars are checked). */ +#ifndef GENX_CHAR_TABLE_SIZE +# define GENX_CHAR_TABLE_SIZE 0x100 +#endif + /* a UTF-8 string */ typedef unsigned char * utf8; typedef const unsigned char * constUtf8; |