diff options
Diffstat (limited to 'generic/regc_locale.c')
-rw-r--r-- | generic/regc_locale.c | 195 |
1 files changed, 81 insertions, 114 deletions
diff --git a/generic/regc_locale.c b/generic/regc_locale.c index 77cfd8e..f652f0e 100644 --- a/generic/regc_locale.c +++ b/generic/regc_locale.c @@ -12,9 +12,9 @@ /* ASCII character-name table */ -static struct cname { - CONST char *name; - CONST char code; +static const struct cname { + const char *name; + const char code; } cnames[] = { {"NUL", '\0'}, {"SOH", '\001'}, @@ -133,7 +133,7 @@ typedef struct crange { * Unicode: alphabetic characters. */ -static CONST crange alphaRangeTable[] = { +static const crange alphaRangeTable[] = { {0x0041, 0x005a}, {0x0061, 0x007a}, {0x00c0, 0x00d6}, {0x00d8, 0x00f6}, {0x00f8, 0x02c1}, {0x02c6, 0x02d1}, {0x02e0, 0x02e4}, {0x0370, 0x0374}, {0x037a, 0x037d}, {0x0388, 0x038a}, {0x038e, 0x03a1}, {0x03a3, 0x03f5}, @@ -200,7 +200,7 @@ static CONST crange alphaRangeTable[] = { #define NUM_ALPHA_RANGE (sizeof(alphaRangeTable)/sizeof(crange)) -static CONST chr alphaCharTable[] = { +static const chr alphaCharTable[] = { 0x00aa, 0x00b5, 0x00ba, 0x02ec, 0x02ee, 0x0376, 0x0377, 0x0386, 0x038c, 0x0559, 0x066e, 0x066f, 0x06d5, 0x06e5, 0x06e6, 0x06ee, 0x06ef, 0x06ff, 0x0710, 0x07b1, 0x07f4, 0x07f5, 0x07fa, 0x081a, 0x0824, 0x0828, 0x093d, @@ -227,7 +227,7 @@ static CONST chr alphaCharTable[] = { * Unicode: decimal digit characters. */ -static CONST crange digitRangeTable[] = { +static const crange digitRangeTable[] = { {0x0030, 0x0039}, {0x0660, 0x0669}, {0x06f0, 0x06f9}, {0x07c0, 0x07c9}, {0x0966, 0x096f}, {0x09e6, 0x09ef}, {0x0a66, 0x0a6f}, {0x0ae6, 0x0aef}, {0x0b66, 0x0b6f}, {0x0be6, 0x0bef}, {0x0c66, 0x0c6f}, {0x0ce6, 0x0cef}, @@ -249,7 +249,7 @@ static CONST crange digitRangeTable[] = { * Unicode: punctuation characters. */ -static CONST crange punctRangeTable[] = { +static const crange punctRangeTable[] = { {0x0021, 0x0023}, {0x0025, 0x002a}, {0x002c, 0x002f}, {0x005b, 0x005d}, {0x055a, 0x055f}, {0x066a, 0x066d}, {0x0700, 0x070d}, {0x07f7, 0x07f9}, {0x0830, 0x083e}, {0x0f04, 0x0f12}, {0x0f3a, 0x0f3d}, {0x0fd0, 0x0fd4}, @@ -267,7 +267,7 @@ static CONST crange punctRangeTable[] = { #define NUM_PUNCT_RANGE (sizeof(punctRangeTable)/sizeof(crange)) -static CONST chr punctCharTable[] = { +static const chr punctCharTable[] = { 0x003a, 0x003b, 0x003f, 0x0040, 0x005f, 0x007b, 0x007d, 0x00a1, 0x00ab, 0x00b7, 0x00bb, 0x00bf, 0x037e, 0x0387, 0x0589, 0x058a, 0x05be, 0x05c0, 0x05c3, 0x05c6, 0x05f3, 0x05f4, 0x0609, 0x060a, 0x060c, 0x060d, 0x061b, @@ -288,13 +288,13 @@ static CONST chr punctCharTable[] = { * Unicode: white space characters. */ -static CONST crange spaceRangeTable[] = { +static const crange spaceRangeTable[] = { {0x0009, 0x000d}, {0x2000, 0x200a} }; #define NUM_SPACE_RANGE (sizeof(spaceRangeTable)/sizeof(crange)) -static CONST chr spaceCharTable[] = { +static const chr spaceCharTable[] = { 0x0020, 0x00a0, 0x1680, 0x180e, 0x2028, 0x2029, 0x202f, 0x205f, 0x3000 }; @@ -304,7 +304,7 @@ static CONST chr spaceCharTable[] = { * Unicode: lowercase characters. */ -static CONST crange lowerRangeTable[] = { +static const crange lowerRangeTable[] = { {0x0061, 0x007a}, {0x00df, 0x00f6}, {0x00f8, 0x00ff}, {0x017e, 0x0180}, {0x0199, 0x019b}, {0x01bd, 0x01bf}, {0x0233, 0x0239}, {0x024f, 0x0293}, {0x0295, 0x02af}, {0x037b, 0x037d}, {0x03ac, 0x03ce}, {0x03d5, 0x03d7}, @@ -320,7 +320,7 @@ static CONST crange lowerRangeTable[] = { #define NUM_LOWER_RANGE (sizeof(lowerRangeTable)/sizeof(crange)) -static CONST chr lowerCharTable[] = { +static const chr lowerCharTable[] = { 0x00aa, 0x00b5, 0x00ba, 0x0101, 0x0103, 0x0105, 0x0107, 0x0109, 0x010b, 0x010d, 0x010f, 0x0111, 0x0113, 0x0115, 0x0117, 0x0119, 0x011b, 0x011d, 0x011f, 0x0121, 0x0123, 0x0125, 0x0127, 0x0129, 0x012b, 0x012d, 0x012f, @@ -391,7 +391,7 @@ static CONST chr lowerCharTable[] = { * Unicode: uppercase characters. */ -static CONST crange upperRangeTable[] = { +static const crange upperRangeTable[] = { {0x0041, 0x005a}, {0x00c0, 0x00d6}, {0x00d8, 0x00de}, {0x0189, 0x018b}, {0x018e, 0x0191}, {0x0196, 0x0198}, {0x01b1, 0x01b3}, {0x01f6, 0x01f8}, {0x0243, 0x0246}, {0x0388, 0x038a}, {0x0391, 0x03a1}, {0x03a3, 0x03ab}, @@ -406,7 +406,7 @@ static CONST crange upperRangeTable[] = { #define NUM_UPPER_RANGE (sizeof(upperRangeTable)/sizeof(crange)) -static CONST chr upperCharTable[] = { +static const chr upperCharTable[] = { 0x0100, 0x0102, 0x0104, 0x0106, 0x0108, 0x010a, 0x010c, 0x010e, 0x0110, 0x0112, 0x0114, 0x0116, 0x0118, 0x011a, 0x011c, 0x011e, 0x0120, 0x0122, 0x0124, 0x0126, 0x0128, 0x012a, 0x012c, 0x012e, 0x0130, 0x0132, 0x0134, @@ -477,7 +477,7 @@ static CONST chr upperCharTable[] = { * Unicode: unicode print characters excluding space. */ -static CONST crange graphRangeTable[] = { +static const crange graphRangeTable[] = { {0x0021, 0x007e}, {0x00a0, 0x00ac}, {0x00ae, 0x0377}, {0x037a, 0x037e}, {0x0384, 0x038a}, {0x038e, 0x03a1}, {0x03a3, 0x0527}, {0x0531, 0x0556}, {0x0559, 0x055f}, {0x0561, 0x0587}, {0x0591, 0x05c7}, {0x05d0, 0x05ea}, @@ -558,7 +558,7 @@ static CONST crange graphRangeTable[] = { #define NUM_GRAPH_RANGE (sizeof(graphRangeTable)/sizeof(crange)) -static CONST chr graphCharTable[] = { +static const chr graphCharTable[] = { 0x038c, 0x0589, 0x058a, 0x085e, 0x098f, 0x0990, 0x09b2, 0x09c7, 0x09c8, 0x09d7, 0x09dc, 0x09dd, 0x0a0f, 0x0a10, 0x0a32, 0x0a33, 0x0a35, 0x0a36, 0x0a38, 0x0a39, 0x0a3c, 0x0a47, 0x0a48, 0x0a51, 0x0a5e, 0x0ab2, 0x0ab3, @@ -582,56 +582,19 @@ static CONST chr graphCharTable[] = { #define CH NOCELT /* - - nmcces - how many distinct MCCEs are there? - ^ static int nmcces(struct vars *); - */ -static int -nmcces(v) - struct vars *v; /* context */ -{ - /* - * No multi-character collating elements defined at the moment. - */ - return 0; -} - -/* - - nleaders - how many chrs can be first chrs of MCCEs? - ^ static int nleaders(struct vars *); - */ -static int -nleaders(v) - struct vars *v; /* context */ -{ - return 0; -} - -/* - - allmcces - return a cvec with all the MCCEs of the locale - ^ static struct cvec *allmcces(struct vars *, struct cvec *); - */ -static struct cvec * -allmcces(v, cv) - struct vars *v; /* context */ - struct cvec *cv; /* this is supposed to have enough room */ -{ - return clearcvec(cv); -} - -/* - element - map collating-element name to celt - ^ static celt element(struct vars *, CONST chr *, CONST chr *); + ^ static celt element(struct vars *, const chr *, const chr *); */ static celt -element(v, startp, endp) - struct vars *v; /* context */ - CONST chr *startp; /* points to start of name */ - CONST chr *endp; /* points just past end of name */ +element( + struct vars *v, /* context */ + const chr *startp, /* points to start of name */ + const chr *endp) /* points just past end of name */ { - CONST struct cname *cn; + const struct cname *cn; size_t len; Tcl_DString ds; - CONST char *np; + const char *np; /* * Generic: one-chr names stand for themselves. @@ -674,11 +637,11 @@ element(v, startp, endp) ^ static struct cvec *range(struct vars *, celt, celt, int); */ static struct cvec * -range(v, a, b, cases) - struct vars *v; /* context */ - celt a; /* range start */ - celt b; /* range end, might equal a */ - int cases; /* case-independent? */ +range( + struct vars *v, /* context */ + celt a, /* range start */ + celt b, /* range end, might equal a */ + int cases) /* case-independent? */ { int nchrs; struct cvec *cv; @@ -690,7 +653,7 @@ range(v, a, b, cases) } if (!cases) { /* easy version */ - cv = getcvec(v, 0, 1, 0); + cv = getcvec(v, 0, 1); NOERRN(); addrange(cv, a, b); return cv; @@ -704,7 +667,7 @@ range(v, a, b, cases) nchrs = (b - a + 1)*2 + 4; - cv = getcvec(v, nchrs, 0, 0); + cv = getcvec(v, nchrs, 0); NOERRN(); for (c=a; c<=b; c++) { @@ -731,8 +694,8 @@ range(v, a, b, cases) ^ static int before(celt, celt); */ static int /* predicate */ -before(x, y) - celt x, y; /* collating elements */ +before( + celt x, celt y) /* collating elements */ { if (x < y) { return 1; @@ -746,11 +709,11 @@ before(x, y) ^ static struct cvec *eclass(struct vars *, celt, int); */ static struct cvec * -eclass(v, c, cases) - struct vars *v; /* context */ - celt c; /* Collating element representing - * the equivalence class. */ - int cases; /* all cases? */ +eclass( + struct vars *v, /* context */ + celt c, /* Collating element representing the + * equivalence class. */ + int cases) /* all cases? */ { struct cvec *cv; @@ -759,7 +722,7 @@ eclass(v, c, cases) */ if ((v->cflags®_FAKE) && c == 'x') { - cv = getcvec(v, 4, 0, 0); + cv = getcvec(v, 4, 0); addchr(cv, (chr)'x'); addchr(cv, (chr)'y'); if (cases) { @@ -776,7 +739,7 @@ eclass(v, c, cases) if (cases) { return allcases(v, c); } - cv = getcvec(v, 1, 0, 0); + cv = getcvec(v, 1, 0); assert(cv != NULL); addchr(cv, (chr)c); return cv; @@ -785,27 +748,27 @@ eclass(v, c, cases) /* - cclass - supply cvec for a character class * Must include case counterparts on request. - ^ static struct cvec *cclass(struct vars *, CONST chr *, CONST chr *, int); + ^ static struct cvec *cclass(struct vars *, const chr *, const chr *, int); */ static struct cvec * -cclass(v, startp, endp, cases) - struct vars *v; /* context */ - CONST chr *startp; /* where the name starts */ - CONST chr *endp; /* just past the end of the name */ - int cases; /* case-independent? */ +cclass( + struct vars *v, /* context */ + const chr *startp, /* where the name starts */ + const chr *endp, /* just past the end of the name */ + int cases) /* case-independent? */ { size_t len; struct cvec *cv = NULL; Tcl_DString ds; - CONST char *np; - CONST char *CONST *namePtr; + const char *np; + const char *const *namePtr; int i, index; /* * The following arrays define the valid character class names. */ - static CONST char *CONST classNames[] = { + static const char *const classNames[] = { "alnum", "alpha", "ascii", "blank", "cntrl", "digit", "graph", "lower", "print", "punct", "space", "upper", "xdigit", NULL }; @@ -855,9 +818,8 @@ cclass(v, startp, endp, cases) */ switch((enum classes) index) { - case CC_PRINT: case CC_ALNUM: - cv = getcvec(v, NUM_ALPHA_CHAR, NUM_DIGIT_RANGE + NUM_ALPHA_RANGE, 0); + cv = getcvec(v, NUM_ALPHA_CHAR, NUM_DIGIT_RANGE + NUM_ALPHA_RANGE); if (cv) { for (i=0 ; (size_t)i<NUM_ALPHA_CHAR ; i++) { addchr(cv, alphaCharTable[i]); @@ -873,7 +835,7 @@ cclass(v, startp, endp, cases) } break; case CC_ALPHA: - cv = getcvec(v, NUM_ALPHA_CHAR, NUM_ALPHA_RANGE, 0); + cv = getcvec(v, NUM_ALPHA_CHAR, NUM_ALPHA_RANGE); if (cv) { for (i=0 ; (size_t)i<NUM_ALPHA_RANGE ; i++) { addrange(cv, alphaRangeTable[i].start, @@ -885,23 +847,23 @@ cclass(v, startp, endp, cases) } break; case CC_ASCII: - cv = getcvec(v, 0, 1, 0); + cv = getcvec(v, 0, 1); if (cv) { addrange(cv, 0, 0x7f); } break; case CC_BLANK: - cv = getcvec(v, 2, 0, 0); + cv = getcvec(v, 2, 0); addchr(cv, '\t'); addchr(cv, ' '); break; case CC_CNTRL: - cv = getcvec(v, 0, 2, 0); + cv = getcvec(v, 0, 2); addrange(cv, 0x0, 0x1f); addrange(cv, 0x7f, 0x9f); break; case CC_DIGIT: - cv = getcvec(v, 0, NUM_DIGIT_RANGE, 0); + cv = getcvec(v, 0, NUM_DIGIT_RANGE); if (cv) { for (i=0 ; (size_t)i<NUM_DIGIT_RANGE ; i++) { addrange(cv, digitRangeTable[i].start, @@ -910,7 +872,7 @@ cclass(v, startp, endp, cases) } break; case CC_PUNCT: - cv = getcvec(v, NUM_PUNCT_CHAR, NUM_PUNCT_RANGE, 0); + cv = getcvec(v, NUM_PUNCT_CHAR, NUM_PUNCT_RANGE); if (cv) { for (i=0 ; (size_t)i<NUM_PUNCT_RANGE ; i++) { addrange(cv, punctRangeTable[i].start, @@ -930,7 +892,8 @@ cclass(v, startp, endp, cases) * Whatever is actually the case, the number of ranges is fixed (until * someone comes up with a better arrangement!) */ - cv = getcvec(v, 0, 3, 0); + + cv = getcvec(v, 0, 3); if (cv) { addrange(cv, '0', '9'); addrange(cv, 'a', 'f'); @@ -938,7 +901,7 @@ cclass(v, startp, endp, cases) } break; case CC_SPACE: - cv = getcvec(v, NUM_SPACE_CHAR, NUM_SPACE_RANGE, 0); + cv = getcvec(v, NUM_SPACE_CHAR, NUM_SPACE_RANGE); if (cv) { for (i=0 ; (size_t)i<NUM_SPACE_RANGE ; i++) { addrange(cv, spaceRangeTable[i].start, @@ -950,7 +913,7 @@ cclass(v, startp, endp, cases) } break; case CC_LOWER: - cv = getcvec(v, NUM_LOWER_CHAR, NUM_LOWER_RANGE, 0); + cv = getcvec(v, NUM_LOWER_CHAR, NUM_LOWER_RANGE); if (cv) { for (i=0 ; (size_t)i<NUM_LOWER_RANGE ; i++) { addrange(cv, lowerRangeTable[i].start, @@ -962,7 +925,7 @@ cclass(v, startp, endp, cases) } break; case CC_UPPER: - cv = getcvec(v, NUM_UPPER_CHAR, NUM_UPPER_RANGE, 0); + cv = getcvec(v, NUM_UPPER_CHAR, NUM_UPPER_RANGE); if (cv) { for (i=0 ; (size_t)i<NUM_UPPER_RANGE ; i++) { addrange(cv, upperRangeTable[i].start, @@ -973,10 +936,14 @@ cclass(v, startp, endp, cases) } } break; + case CC_PRINT: case CC_GRAPH: - cv = getcvec(v, NUM_GRAPH_CHAR, NUM_GRAPH_RANGE, 0); + cv = getcvec(v, NUM_GRAPH_CHAR, NUM_GRAPH_RANGE); if (cv) { - for (i=0 ; (size_t)i<NUM_GRAPH_RANGE ; i++) { + /* For CC_PRINT, include space as well */ + addrange(cv, graphRangeTable[0].start - (index == CC_PRINT), + graphRangeTable[0].end); + for (i=1 ; (size_t)i<NUM_GRAPH_RANGE ; i++) { addrange(cv, graphRangeTable[i].start, graphRangeTable[i].end); } @@ -999,9 +966,9 @@ cclass(v, startp, endp, cases) ^ static struct cvec *allcases(struct vars *, pchr); */ static struct cvec * -allcases(v, pc) - struct vars *v; /* context */ - pchr pc; /* character to get case equivs of */ +allcases( + struct vars *v, /* context */ + pchr pc) /* character to get case equivs of */ { struct cvec *cv; chr c = (chr)pc; @@ -1012,10 +979,10 @@ allcases(v, pc) tc = Tcl_UniCharToTitle((chr)c); if (tc != uc) { - cv = getcvec(v, 3, 0, 0); + cv = getcvec(v, 3, 0); addchr(cv, tc); } else { - cv = getcvec(v, 2, 0, 0); + cv = getcvec(v, 2, 0); } addchr(cv, lc); if (lc != uc) { @@ -1030,12 +997,12 @@ allcases(v, pc) * Note that it does not need to report anything except equal/unequal. * Note also that the length is exact, and the comparison should not * stop at embedded NULs! - ^ static int cmp(CONST chr *, CONST chr *, size_t); + ^ static int cmp(const chr *, const chr *, size_t); */ -static int /* 0 for equal, nonzero for unequal */ -cmp(x, y, len) - CONST chr *x, *y; /* strings to compare */ - size_t len; /* exact length of comparison */ +static int /* 0 for equal, nonzero for unequal */ +cmp( + const chr *x, const chr *y, /* strings to compare */ + size_t len) /* exact length of comparison */ { return memcmp(VS(x), VS(y), len*sizeof(chr)); } @@ -1046,12 +1013,12 @@ cmp(x, y, len) * Note that it does not need to report anything except equal/unequal. * Note also that the length is exact, and the comparison should not * stop at embedded NULs! - ^ static int casecmp(CONST chr *, CONST chr *, size_t); + ^ static int casecmp(const chr *, const chr *, size_t); */ -static int /* 0 for equal, nonzero for unequal */ -casecmp(x, y, len) - CONST chr *x, *y; /* strings to compare */ - size_t len; /* exact length of comparison */ +static int /* 0 for equal, nonzero for unequal */ +casecmp( + const chr *x, const chr *y, /* strings to compare */ + size_t len) /* exact length of comparison */ { for (; len > 0; len--, x++, y++) { if ((*x!=*y) && (Tcl_UniCharToLower(*x) != Tcl_UniCharToLower(*y))) { |