Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | [Bug 3464428] string is graph \u0120 is wrong |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | core-8-4-branch |
Files: | files | file ages | folders |
SHA1: |
a0c0feafe98ee7b31470ec34d9a61af2 |
User & Date: | jan.nijtmans 2012-01-09 19:59:47 |
Context
2012-01-13
| ||
11:45 |
* library/http/http.tcl (http::Connect): [Bug 3472316]: Ensure that we only try to read the socket...check-in: 07438ee67a user: dkf tags: core-8-4-branch | |
2012-01-09
| ||
20:31 | [Bug 3464428] string is graph \u0120 is wrong check-in: 14fc5c19b7 user: jan.nijtmans tags: core-8-5-branch | |
19:59 | [Bug 3464428] string is graph \u0120 is wrong check-in: a0c0feafe9 user: jan.nijtmans tags: core-8-4-branch | |
2011-12-23
| ||
23:31 | [Bug 3464428] string is graph \u0120 is wrong check-in: 13071df962 user: jan.nijtmans tags: core-8-4-branch | |
Changes
Changes to ChangeLog.
1 2 3 4 5 6 7 | 2011-12-23 Jan Nijtmans <[email protected]> * generic/tclUtf.c: [Bug 3464428] string is graph \u0120 is wrong * generic/tclUniData.c: * generic/regc_locale.c: * tests/utf.test: * tools/uniParse.tcl: clean up some unused stuff, and be more robust | > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 2012-01-09 Jan Nijtmans <[email protected]> * generic/tclUtf.c: [Bug 3464428] string is graph \u0120 is wrong * generic/regcomp.c: Remove some unused code * generic/regc_locale.c: Add table for Unicode [:cntrl:] class * tools/uniClass.tcl: Generate Unicode [:cntrl:] class table * tests/utf.test: * doc/re_syntax: Fix [:print:] class description 2011-12-23 Jan Nijtmans <[email protected]> * generic/tclUtf.c: [Bug 3464428] string is graph \u0120 is wrong * generic/tclUniData.c: * generic/regc_locale.c: * tests/utf.test: * tools/uniParse.tcl: clean up some unused stuff, and be more robust |
︙ | ︙ |
Changes to doc/re_syntax.n.
︙ | ︙ | |||
281 282 283 284 285 286 287 | .nf \fBalpha\fR A letter. \fBupper\fR An upper-case letter. \fBlower\fR A lower-case letter. \fBdigit\fR A decimal digit. \fBxdigit\fR A hexadecimal digit. \fBalnum\fR An alphanumeric (letter or digit). | | | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | .nf \fBalpha\fR A letter. \fBupper\fR An upper-case letter. \fBlower\fR A lower-case letter. \fBdigit\fR A decimal digit. \fBxdigit\fR A hexadecimal digit. \fBalnum\fR An alphanumeric (letter or digit). \fBprint\fR A "printable" (same as graph, except also including space). \fBblank\fR A space or tab character. \fBspace\fR A character producing white space in displayed text. \fBpunct\fR A punctuation character. \fBgraph\fR A character with a visible representation. \fBcntrl\fR A control character. .fi .RE |
︙ | ︙ |
Changes to generic/regc_cvec.c.
1 2 3 4 5 | /* * Utility functions for handling cvecs * This file is #included by regcomp.c. * * Copyright (c) 1998, 1999 Henry Spencer. All rights reserved. | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /* * Utility functions for handling cvecs * This file is #included by regcomp.c. * * Copyright (c) 1998, 1999 Henry Spencer. All rights reserved. * * Development of this software was funded, in part, by Cray Research Inc., * UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics * Corporation, none of whom are responsible for the results. The author * thanks all of them. * * Redistribution and use in source and binary forms -- with or without * modification -- are permitted for any purpose, provided that * redistributions in source form retain this entire copyright notice and * indicate the origin and nature of any modifications. * * I'd appreciate being given credit for this package in the documentation * of software which uses it, but that is not a requirement. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * HENRY SPENCER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
︙ | ︙ | |||
108 109 110 111 112 113 114 | { assert(cv->nranges < cv->rangespace); cv->ranges[cv->nranges*2] = (chr)from; cv->ranges[cv->nranges*2 + 1] = (chr)to; cv->nranges++; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | { assert(cv->nranges < cv->rangespace); cv->ranges[cv->nranges*2] = (chr)from; cv->ranges[cv->nranges*2 + 1] = (chr)to; cv->nranges++; } /* - haschr - does a cvec contain this chr? ^ static int haschr(struct cvec *, pchr); */ static int /* predicate */ haschr(cv, c) struct cvec *cv; /* character vector */ |
︙ | ︙ | |||
167 168 169 170 171 172 173 | } } return 0; } /* - getcvec - get a cvec, remembering it as v->cv | | | < | | | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | } } return 0; } /* - getcvec - get a cvec, remembering it as v->cv ^ static struct cvec *getcvec(struct vars *, int, int); */ static struct cvec * getcvec(v, nchrs, nranges) struct vars *v; /* context */ int nchrs; /* to hold this many chrs... */ int nranges; /* ... and this many ranges... */ { if (v->cv != NULL && nchrs <= v->cv->chrspace && nranges <= v->cv->rangespace) { return clearcvec(v->cv); } if (v->cv != NULL) { freecvec(v->cv); } v->cv = newcvec(nchrs, nranges, 0); if (v->cv == NULL) { ERR(REG_ESPACE); } return v->cv; } |
︙ | ︙ |
Changes to generic/regc_locale.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* ASCII character-name table */ | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* ASCII character-name table */ static CONST struct cname { CONST char *name; CONST char code; } cnames[] = { {"NUL", '\0'}, {"SOH", '\001'}, {"STX", '\002'}, {"ETX", '\003'}, |
︙ | ︙ | |||
219 220 221 222 223 224 225 226 227 228 229 230 231 232 | 0x2e2f, 0x3005, 0x3006, 0x303b, 0x303c, 0xa62a, 0xa62b, 0xa790, 0xa791, 0xa8fb, 0xa9cf, 0xaa7a, 0xaab1, 0xaab5, 0xaab6, 0xaac0, 0xaac2, 0xfb1d, 0xfb3e, 0xfb40, 0xfb41, 0xfb43, 0xfb44 }; #define NUM_ALPHA_CHAR (sizeof(alphaCharTable)/sizeof(chr)) /* * Unicode: decimal digit characters. */ static CONST crange digitRangeTable[] = { {0x0030, 0x0039}, {0x0660, 0x0669}, {0x06f0, 0x06f9}, {0x07c0, 0x07c9}, {0x0966, 0x096f}, {0x09e6, 0x09ef}, {0x0a66, 0x0a6f}, {0x0ae6, 0x0aef}, | > > > > > > > > > > > > > > > > > | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | 0x2e2f, 0x3005, 0x3006, 0x303b, 0x303c, 0xa62a, 0xa62b, 0xa790, 0xa791, 0xa8fb, 0xa9cf, 0xaa7a, 0xaab1, 0xaab5, 0xaab6, 0xaac0, 0xaac2, 0xfb1d, 0xfb3e, 0xfb40, 0xfb41, 0xfb43, 0xfb44 }; #define NUM_ALPHA_CHAR (sizeof(alphaCharTable)/sizeof(chr)) /* * Unicode: control characters. */ static CONST crange controlRangeTable[] = { {0x007f, 0x009f}, {0x0600, 0x0603}, {0x200b, 0x200f}, {0x202a, 0x202e}, {0x2060, 0x2064}, {0x206a, 0x206f}, {0xe000, 0xf8ff}, {0xfff9, 0xfffb} }; #define NUM_CONTROL_RANGE (sizeof(controlRangeTable)/sizeof(crange)) static CONST chr controlCharTable[] = { 0x00ad, 0x06dd, 0x070f, 0x17b4, 0x17b5, 0xfeff }; #define NUM_CONTROL_CHAR (sizeof(controlCharTable)/sizeof(chr)) /* * Unicode: decimal digit characters. */ static CONST crange digitRangeTable[] = { {0x0030, 0x0039}, {0x0660, 0x0669}, {0x06f0, 0x06f9}, {0x07c0, 0x07c9}, {0x0966, 0x096f}, {0x09e6, 0x09ef}, {0x0a66, 0x0a6f}, {0x0ae6, 0x0aef}, |
︙ | ︙ | |||
474 475 476 477 478 479 480 | #define NUM_UPPER_CHAR (sizeof(upperCharTable)/sizeof(chr)) /* * Unicode: unicode print characters excluding space. */ static CONST crange graphRangeTable[] = { | | | 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 | #define NUM_UPPER_CHAR (sizeof(upperCharTable)/sizeof(chr)) /* * Unicode: unicode print characters excluding space. */ static CONST crange graphRangeTable[] = { {0x0021, 0x007e}, {0x00a1, 0x00ac}, {0x00ae, 0x0377}, {0x037a, 0x037e}, {0x0384, 0x038a}, {0x038e, 0x03a1}, {0x03a3, 0x0527}, {0x0531, 0x0556}, {0x0559, 0x055f}, {0x0561, 0x0587}, {0x0591, 0x05c7}, {0x05d0, 0x05ea}, {0x05f0, 0x05f4}, {0x0606, 0x061b}, {0x061e, 0x06dc}, {0x06de, 0x070d}, {0x0710, 0x074a}, {0x074d, 0x07b1}, {0x07c0, 0x07fa}, {0x0800, 0x082d}, {0x0830, 0x083e}, {0x0840, 0x085b}, {0x0900, 0x0977}, {0x0979, 0x097f}, {0x0981, 0x0983}, {0x0985, 0x098c}, {0x0993, 0x09a8}, {0x09aa, 0x09b0}, {0x09b6, 0x09b9}, {0x09bc, 0x09c4}, {0x09cb, 0x09ce}, {0x09df, 0x09e3}, |
︙ | ︙ | |||
509 510 511 512 513 514 515 | {0x0ea1, 0x0ea3}, {0x0ead, 0x0eb9}, {0x0ebb, 0x0ebd}, {0x0ec0, 0x0ec4}, {0x0ec8, 0x0ecd}, {0x0ed0, 0x0ed9}, {0x0f00, 0x0f47}, {0x0f49, 0x0f6c}, {0x0f71, 0x0f97}, {0x0f99, 0x0fbc}, {0x0fbe, 0x0fcc}, {0x0fce, 0x0fda}, {0x1000, 0x10c5}, {0x10d0, 0x10fc}, {0x1100, 0x1248}, {0x124a, 0x124d}, {0x1250, 0x1256}, {0x125a, 0x125d}, {0x1260, 0x1288}, {0x128a, 0x128d}, {0x1290, 0x12b0}, {0x12b2, 0x12b5}, {0x12b8, 0x12be}, {0x12c2, 0x12c5}, {0x12c8, 0x12d6}, {0x12d8, 0x1310}, {0x1312, 0x1315}, {0x1318, 0x135a}, | | | | | | | | | | | | | | | | | | 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | {0x0ea1, 0x0ea3}, {0x0ead, 0x0eb9}, {0x0ebb, 0x0ebd}, {0x0ec0, 0x0ec4}, {0x0ec8, 0x0ecd}, {0x0ed0, 0x0ed9}, {0x0f00, 0x0f47}, {0x0f49, 0x0f6c}, {0x0f71, 0x0f97}, {0x0f99, 0x0fbc}, {0x0fbe, 0x0fcc}, {0x0fce, 0x0fda}, {0x1000, 0x10c5}, {0x10d0, 0x10fc}, {0x1100, 0x1248}, {0x124a, 0x124d}, {0x1250, 0x1256}, {0x125a, 0x125d}, {0x1260, 0x1288}, {0x128a, 0x128d}, {0x1290, 0x12b0}, {0x12b2, 0x12b5}, {0x12b8, 0x12be}, {0x12c2, 0x12c5}, {0x12c8, 0x12d6}, {0x12d8, 0x1310}, {0x1312, 0x1315}, {0x1318, 0x135a}, {0x135d, 0x137c}, {0x1380, 0x1399}, {0x13a0, 0x13f4}, {0x1400, 0x167f}, {0x1681, 0x169c}, {0x16a0, 0x16f0}, {0x1700, 0x170c}, {0x170e, 0x1714}, {0x1720, 0x1736}, {0x1740, 0x1753}, {0x1760, 0x176c}, {0x176e, 0x1770}, {0x1780, 0x17b3}, {0x17b6, 0x17dd}, {0x17e0, 0x17e9}, {0x17f0, 0x17f9}, {0x1800, 0x180d}, {0x1810, 0x1819}, {0x1820, 0x1877}, {0x1880, 0x18aa}, {0x18b0, 0x18f5}, {0x1900, 0x191c}, {0x1920, 0x192b}, {0x1930, 0x193b}, {0x1944, 0x196d}, {0x1970, 0x1974}, {0x1980, 0x19ab}, {0x19b0, 0x19c9}, {0x19d0, 0x19da}, {0x19de, 0x1a1b}, {0x1a1e, 0x1a5e}, {0x1a60, 0x1a7c}, {0x1a7f, 0x1a89}, {0x1a90, 0x1a99}, {0x1aa0, 0x1aad}, {0x1b00, 0x1b4b}, {0x1b50, 0x1b7c}, {0x1b80, 0x1baa}, {0x1bae, 0x1bb9}, {0x1bc0, 0x1bf3}, {0x1bfc, 0x1c37}, {0x1c3b, 0x1c49}, {0x1c4d, 0x1c7f}, {0x1cd0, 0x1cf2}, {0x1d00, 0x1de6}, {0x1dfc, 0x1f15}, {0x1f18, 0x1f1d}, {0x1f20, 0x1f45}, {0x1f48, 0x1f4d}, {0x1f50, 0x1f57}, {0x1f5f, 0x1f7d}, {0x1f80, 0x1fb4}, {0x1fb6, 0x1fc4}, {0x1fc6, 0x1fd3}, {0x1fd6, 0x1fdb}, {0x1fdd, 0x1fef}, {0x1ff2, 0x1ff4}, {0x1ff6, 0x1ffe}, {0x2010, 0x2027}, {0x2030, 0x205e}, {0x2074, 0x208e}, {0x2090, 0x209c}, {0x20a0, 0x20b9}, {0x20d0, 0x20f0}, {0x2100, 0x2189}, {0x2190, 0x23f3}, {0x2400, 0x2426}, {0x2440, 0x244a}, {0x2460, 0x26ff}, {0x2701, 0x27ca}, {0x27ce, 0x2b4c}, {0x2b50, 0x2b59}, {0x2c00, 0x2c2e}, {0x2c30, 0x2c5e}, {0x2c60, 0x2cf1}, {0x2cf9, 0x2d25}, {0x2d30, 0x2d65}, {0x2d7f, 0x2d96}, {0x2da0, 0x2da6}, {0x2da8, 0x2dae}, {0x2db0, 0x2db6}, {0x2db8, 0x2dbe}, {0x2dc0, 0x2dc6}, {0x2dc8, 0x2dce}, {0x2dd0, 0x2dd6}, {0x2dd8, 0x2dde}, {0x2de0, 0x2e31}, {0x2e80, 0x2e99}, {0x2e9b, 0x2ef3}, {0x2f00, 0x2fd5}, {0x2ff0, 0x2ffb}, {0x3001, 0x303f}, {0x3041, 0x3096}, {0x3099, 0x30ff}, {0x3105, 0x312d}, {0x3131, 0x318e}, {0x3190, 0x31ba}, {0x31c0, 0x31e3}, {0x31f0, 0x321e}, {0x3220, 0x32fe}, {0x3300, 0x4db5}, {0x4dc0, 0x9fcb}, {0xa000, 0xa48c}, {0xa490, 0xa4c6}, {0xa4d0, 0xa62b}, {0xa640, 0xa673}, {0xa67c, 0xa697}, {0xa6a0, 0xa6f7}, {0xa700, 0xa78e}, {0xa7a0, 0xa7a9}, {0xa7fa, 0xa82b}, {0xa830, 0xa839}, {0xa840, 0xa877}, {0xa880, 0xa8c4}, {0xa8ce, 0xa8d9}, {0xa8e0, 0xa8fb}, {0xa900, 0xa953}, {0xa95f, 0xa97c}, {0xa980, 0xa9cd}, {0xa9cf, 0xa9d9}, |
︙ | ︙ | |||
577 578 579 580 581 582 583 | /* * End of auto-generated Unicode character ranges declarations. */ #define CH NOCELT | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | /* * End of auto-generated Unicode character ranges declarations. */ #define CH NOCELT /* - element - map collating-element name to celt ^ static celt element(struct vars *, CONST chr *, CONST chr *); */ static celt element(v, startp, endp) struct vars *v; /* context */ |
︙ | ︙ | |||
686 687 688 689 690 691 692 | if (a != b && !before(a, b)) { ERR(REG_ERANGE); return NULL; } if (!cases) { /* easy version */ | | | | 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 | if (a != b && !before(a, b)) { ERR(REG_ERANGE); return NULL; } if (!cases) { /* easy version */ cv = getcvec(v, 0, 1); NOERRN(); addrange(cv, a, b); return cv; } /* * When case-independent, it's hard to decide when cvec ranges are usable, * so for now at least, we won't try. We allocate enough space for two * case variants plus a little extra for the two title case variants. */ nchrs = (b - a + 1)*2 + 4; cv = getcvec(v, nchrs, 0); NOERRN(); for (c=a; c<=b; c++) { addchr(cv, c); lc = Tcl_UniCharToLower((chr)c); uc = Tcl_UniCharToUpper((chr)c); tc = Tcl_UniCharToTitle((chr)c); |
︙ | ︙ | |||
755 756 757 758 759 760 761 | struct cvec *cv; /* * Crude fake equivalence class for testing. */ if ((v->cflags®_FAKE) && c == 'x') { | | | | 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | struct cvec *cv; /* * Crude fake equivalence class for testing. */ if ((v->cflags®_FAKE) && c == 'x') { cv = getcvec(v, 4, 0); addchr(cv, (chr)'x'); addchr(cv, (chr)'y'); if (cases) { addchr(cv, (chr)'X'); addchr(cv, (chr)'Y'); } return cv; } /* * Otherwise, none. */ if (cases) { return allcases(v, c); } cv = getcvec(v, 1, 0); assert(cv != NULL); addchr(cv, (chr)c); return cv; } /* - cclass - supply cvec for a character class |
︙ | ︙ | |||
820 821 822 823 824 825 826 | * Extract the class name */ len = endp - startp; Tcl_DStringInit(&ds); np = Tcl_UniCharToUtfDString(startp, (int)len, &ds); | < < < < < < < < < > > > > > > > > < | | | | | | > | > > > > > > | | > | | | | > > > > > > > > > > > > > > > > > > > | | 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 | * Extract the class name */ len = endp - startp; Tcl_DStringInit(&ds); np = Tcl_UniCharToUtfDString(startp, (int)len, &ds); /* * Map the name to the corresponding enumerated value. */ index = -1; for (namePtr=classNames,i=0 ; *namePtr!=NULL ; namePtr++,i++) { if ((strlen(*namePtr) == len) && (strncmp(*namePtr, np, len) == 0)) { index = i; break; } } Tcl_DStringFree(&ds); if (index == -1) { ERR(REG_ECTYPE); return NULL; } /* * Remap lower and upper to alpha if the match is case insensitive. */ if (cases && ((index == CC_LOWER) || (index == CC_UPPER))) { index = CC_ALNUM; } /* * Now compute the character class contents. */ switch((enum classes) index) { case CC_ALNUM: 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]); } for (i=0 ; (size_t)i<NUM_ALPHA_RANGE ; i++) { addrange(cv, alphaRangeTable[i].start, alphaRangeTable[i].end); } for (i=0 ; (size_t)i<NUM_DIGIT_RANGE ; i++) { addrange(cv, digitRangeTable[i].start, digitRangeTable[i].end); } } break; case CC_ALPHA: 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, alphaRangeTable[i].end); } for (i=0 ; (size_t)i<NUM_ALPHA_CHAR ; i++) { addchr(cv, alphaCharTable[i]); } } break; case CC_ASCII: cv = getcvec(v, 0, 1); if (cv) { addrange(cv, 0, 0x7f); } break; case CC_BLANK: cv = getcvec(v, 2, 0); addchr(cv, '\t'); addchr(cv, ' '); break; case CC_CNTRL: cv = getcvec(v, NUM_CONTROL_CHAR, NUM_CONTROL_RANGE); if (cv) { for (i=0 ; (size_t)i<NUM_CONTROL_RANGE ; i++) { addrange(cv, controlRangeTable[i].start, controlRangeTable[i].end); } for (i=0 ; (size_t)i<NUM_CONTROL_CHAR ; i++) { addchr(cv, controlCharTable[i]); } } break; case CC_DIGIT: cv = getcvec(v, 0, NUM_DIGIT_RANGE); if (cv) { for (i=0 ; (size_t)i<NUM_DIGIT_RANGE ; i++) { addrange(cv, digitRangeTable[i].start, digitRangeTable[i].end); } } break; case CC_PUNCT: 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, punctRangeTable[i].end); } for (i=0 ; (size_t)i<NUM_PUNCT_CHAR ; i++) { addchr(cv, punctCharTable[i]); } } break; case CC_XDIGIT: /* * This is a 3 instead of (NUM_DIGIT_RANGE+2) because I've no idea how * to define the digits 'a' through 'f' in non-western locales. The * concept is quite possibly non portable, or only used in contextx * where the characters used would be the western ones anyway! * Whatever is actually the case, the number of ranges is fixed (until * someone comes up with a better arrangement!) */ cv = getcvec(v, 0, 3); if (cv) { addrange(cv, '0', '9'); addrange(cv, 'a', 'f'); addrange(cv, 'A', 'F'); } break; case CC_SPACE: 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, spaceRangeTable[i].end); } for (i=0 ; (size_t)i<NUM_SPACE_CHAR ; i++) { addchr(cv, spaceCharTable[i]); } } break; case CC_LOWER: 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, lowerRangeTable[i].end); } for (i=0 ; (size_t)i<NUM_LOWER_CHAR ; i++) { addchr(cv, lowerCharTable[i]); } } break; case CC_UPPER: 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, upperRangeTable[i].end); } for (i=0 ; (size_t)i<NUM_UPPER_CHAR ; i++) { addchr(cv, upperCharTable[i]); } } break; case CC_PRINT: cv = getcvec(v, NUM_SPACE_CHAR + NUM_GRAPH_CHAR, NUM_SPACE_RANGE + NUM_GRAPH_RANGE - 1); if (cv) { for (i=1 ; (size_t)i<NUM_SPACE_RANGE ; i++) { addrange(cv, spaceRangeTable[i].start, spaceRangeTable[i].end); } for (i=0 ; (size_t)i<NUM_SPACE_CHAR ; i++) { addchr(cv, spaceCharTable[i]); } for (i=0 ; (size_t)i<NUM_GRAPH_RANGE ; i++) { addrange(cv, graphRangeTable[i].start, graphRangeTable[i].end); } for (i=0 ; (size_t)i<NUM_GRAPH_CHAR ; i++) { addchr(cv, graphCharTable[i]); } } break; case CC_GRAPH: cv = getcvec(v, NUM_GRAPH_CHAR, NUM_GRAPH_RANGE); if (cv) { for (i=0 ; (size_t)i<NUM_GRAPH_RANGE ; i++) { addrange(cv, graphRangeTable[i].start, graphRangeTable[i].end); } for (i=0 ; (size_t)i<NUM_GRAPH_CHAR ; i++) { addchr(cv, graphCharTable[i]); |
︙ | ︙ | |||
1008 1009 1010 1011 1012 1013 1014 | chr lc, uc, tc; lc = Tcl_UniCharToLower((chr)c); uc = Tcl_UniCharToUpper((chr)c); tc = Tcl_UniCharToTitle((chr)c); if (tc != uc) { | | | | 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 | chr lc, uc, tc; lc = Tcl_UniCharToLower((chr)c); uc = Tcl_UniCharToUpper((chr)c); tc = Tcl_UniCharToTitle((chr)c); if (tc != uc) { cv = getcvec(v, 3, 0); addchr(cv, tc); } else { cv = getcvec(v, 2, 0); } addchr(cv, lc); if (lc != uc) { addchr(cv, uc); } return cv; } |
︙ | ︙ |
Changes to generic/regcomp.c.
1 2 3 4 5 | /* * re_*comp and friends - compile REs * This file #includes several others (see the bottom). * * Copyright (c) 1998, 1999 Henry Spencer. All rights reserved. | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /* * re_*comp and friends - compile REs * This file #includes several others (see the bottom). * * Copyright (c) 1998, 1999 Henry Spencer. All rights reserved. * * Development of this software was funded, in part, by Cray Research Inc., * UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics * Corporation, none of whom are responsible for the results. The author * thanks all of them. * * Redistribution and use in source and binary forms -- with or without * modification -- are permitted for any purpose, provided that * redistributions in source form retain this entire copyright notice and * indicate the origin and nature of any modifications. * * I'd appreciate being given credit for this package in the documentation * of software which uses it, but that is not a requirement. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * HENRY SPENCER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
︙ | ︙ | |||
49 50 51 52 53 54 55 | static VOID word _ANSI_ARGS_((struct vars *, int, struct state *, struct state *)); static int scannum _ANSI_ARGS_((struct vars *)); static VOID repeat _ANSI_ARGS_((struct vars *, struct state *, struct state *, int, int)); static VOID bracket _ANSI_ARGS_((struct vars *, struct state *, struct state *)); static VOID cbracket _ANSI_ARGS_((struct vars *, struct state *, struct state *)); static VOID brackpart _ANSI_ARGS_((struct vars *, struct state *, struct state *)); static chr *scanplain _ANSI_ARGS_((struct vars *)); | < | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | static VOID word _ANSI_ARGS_((struct vars *, int, struct state *, struct state *)); static int scannum _ANSI_ARGS_((struct vars *)); static VOID repeat _ANSI_ARGS_((struct vars *, struct state *, struct state *, int, int)); static VOID bracket _ANSI_ARGS_((struct vars *, struct state *, struct state *)); static VOID cbracket _ANSI_ARGS_((struct vars *, struct state *, struct state *)); static VOID brackpart _ANSI_ARGS_((struct vars *, struct state *, struct state *)); static chr *scanplain _ANSI_ARGS_((struct vars *)); static VOID onechr _ANSI_ARGS_((struct vars *, pchr, struct state *, struct state *)); static VOID dovec _ANSI_ARGS_((struct vars *, struct cvec *, struct state *, struct state *)); static celt nextleader _ANSI_ARGS_((struct vars *, pchr, pchr)); static VOID wordchrs _ANSI_ARGS_((struct vars *)); static struct subre *subre _ANSI_ARGS_((struct vars *, int, int, struct state *, struct state *)); static VOID freesubre _ANSI_ARGS_((struct vars *, struct subre *)); static VOID freesrnode _ANSI_ARGS_((struct vars *, struct subre *)); |
︙ | ︙ | |||
167 168 169 170 171 172 173 | static VOID dumpcstate _ANSI_ARGS_((int, struct carc *, struct cnfa *, FILE *)); #endif /* === regc_cvec.c === */ static struct cvec *newcvec _ANSI_ARGS_((int, int, int)); static struct cvec *clearcvec _ANSI_ARGS_((struct cvec *)); static VOID addchr _ANSI_ARGS_((struct cvec *, pchr)); static VOID addrange _ANSI_ARGS_((struct cvec *, pchr, pchr)); | < | < < < | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | static VOID dumpcstate _ANSI_ARGS_((int, struct carc *, struct cnfa *, FILE *)); #endif /* === regc_cvec.c === */ static struct cvec *newcvec _ANSI_ARGS_((int, int, int)); static struct cvec *clearcvec _ANSI_ARGS_((struct cvec *)); static VOID addchr _ANSI_ARGS_((struct cvec *, pchr)); static VOID addrange _ANSI_ARGS_((struct cvec *, pchr, pchr)); static int haschr _ANSI_ARGS_((struct cvec *, pchr)); static struct cvec *getcvec _ANSI_ARGS_((struct vars *, int, int)); static VOID freecvec _ANSI_ARGS_((struct cvec *)); /* === regc_locale.c === */ static celt element _ANSI_ARGS_((struct vars *, CONST chr *, CONST chr *)); static struct cvec *range _ANSI_ARGS_((struct vars *, celt, celt, int)); static int before _ANSI_ARGS_((celt, celt)); static struct cvec *eclass _ANSI_ARGS_((struct vars *, celt, int)); static struct cvec *cclass _ANSI_ARGS_((struct vars *, CONST chr *, CONST chr *, int)); static struct cvec *allcases _ANSI_ARGS_((struct vars *, pchr)); static int cmp _ANSI_ARGS_((CONST chr *, CONST chr *, size_t)); |
︙ | ︙ | |||
347 348 349 350 351 352 353 | g->nlacons = 0; ZAPCNFA(g->search); v->nfa = newnfa(v, v->cm, (struct nfa *)NULL); CNOERR(); v->cv = newcvec(100, 20, 10); if (v->cv == NULL) return freev(v, REG_ESPACE); | < < < < < < < < | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | g->nlacons = 0; ZAPCNFA(g->search); v->nfa = newnfa(v, v->cm, (struct nfa *)NULL); CNOERR(); v->cv = newcvec(100, 20, 10); if (v->cv == NULL) return freev(v, REG_ESPACE); CNOERR(); /* parsing */ lexstart(v); /* also handles prefixes */ if ((v->cflags®_NLSTOP) || (v->cflags®_NLANCH)) { /* assign newline a unique color */ v->nlcolor = subcolor(v->cm, newline()); |
︙ | ︙ | |||
1352 1353 1354 1355 1356 1357 1358 | delsub(v->nfa, left, right); assert(left->nouts == 0); freestate(v->nfa, left); assert(right->nins == 0); freestate(v->nfa, right); } | | | 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 | delsub(v->nfa, left, right); assert(left->nouts == 0); freestate(v->nfa, left); assert(right->nins == 0); freestate(v->nfa, right); } /* - brackpart - handle one item (or range) within a bracket expression ^ static VOID brackpart(struct vars *, struct state *, struct state *); */ static VOID brackpart(v, lp, rp) struct vars *v; |
︙ | ︙ | |||
1488 1489 1490 1491 1492 1493 1494 | assert(SEE(END) || ISERR()); NEXT(); return endp; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 | assert(SEE(END) || ISERR()); NEXT(); return endp; } /* - onechr - fill in arcs for a plain character, and possible case complements * This is mostly a shortcut for efficient handling of the common case. ^ static VOID onechr(struct vars *, pchr, struct state *, struct state *); */ static VOID onechr(v, c, lp, rp) |
︙ | ︙ | |||
1577 1578 1579 1580 1581 1582 1583 | color co; struct cvec *leads; struct arc *a; struct arc *pa; /* arc in prototype */ struct state *s; struct state *ps; /* state in prototype */ | < < < < < < < < < < < < | | 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 | color co; struct cvec *leads; struct arc *a; struct arc *pa; /* arc in prototype */ struct state *s; struct state *ps; /* state in prototype */ leads = NULL; /* first, get the ordinary characters out of the way */ for (p = cv->chrs, i = cv->nchrs; i > 0; p++, i--) { ch = *p; if (!ISCELEADER(v, ch)) newarc(v->nfa, PLAIN, subcolor(v->cm, ch), lp, rp); else { |
︙ | ︙ | |||
2063 2064 2065 2066 2067 2068 2069 | } g = (struct guts *)re->re_guts; if (g->magic != GUTSMAGIC) fprintf(f, "bad guts magic number (0x%x not 0x%x)\n", g->magic, GUTSMAGIC); fprintf(f, "\n\n\n========= DUMP ==========\n"); | | | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 | } g = (struct guts *)re->re_guts; if (g->magic != GUTSMAGIC) fprintf(f, "bad guts magic number (0x%x not 0x%x)\n", g->magic, GUTSMAGIC); fprintf(f, "\n\n\n========= DUMP ==========\n"); fprintf(f, "nsub %d, info 0%lo, csize %d, ntree %d\n", re->re_nsub, re->re_info, re->re_csize, g->ntree); dumpcolors(&g->cmap, f); if (!NULLCNFA(g->search)) { printf("\nsearch:\n"); dumpcnfa(&g->search, f); } |
︙ | ︙ |
Changes to generic/tclUtf.c.
︙ | ︙ | |||
17 18 19 20 21 22 23 | #include "tclUniData.c" /* * The following macros are used for fast character category tests. The * x_BITS values are shifted right by the category value to determine whether * the given category is included in the set. | | > > < < | < < < < < < < < > > > > > > > | | | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #include "tclUniData.c" /* * The following macros are used for fast character category tests. The * x_BITS values are shifted right by the category value to determine whether * the given category is included in the set. */ #define ALPHA_BITS ((1 << UPPERCASE_LETTER) | (1 << LOWERCASE_LETTER) \ | (1 << TITLECASE_LETTER) | (1 << MODIFIER_LETTER) | (1 << OTHER_LETTER)) #define CONTROL_BITS ((1 << CONTROL) | (1 << FORMAT) | (1 << PRIVATE_USE)) #define DIGIT_BITS (1 << DECIMAL_DIGIT_NUMBER) #define SPACE_BITS ((1 << SPACE_SEPARATOR) | (1 << LINE_SEPARATOR) \ | (1 << PARAGRAPH_SEPARATOR)) #define WORD_BITS (ALPHA_BITS | DIGIT_BITS | (1 << CONNECTOR_PUNCTUATION)) #define PUNCT_BITS ((1 << CONNECTOR_PUNCTUATION) | \ (1 << DASH_PUNCTUATION) | (1 << OPEN_PUNCTUATION) | \ (1 << CLOSE_PUNCTUATION) | (1 << INITIAL_QUOTE_PUNCTUATION) | \ (1 << FINAL_QUOTE_PUNCTUATION) | (1 << OTHER_PUNCTUATION)) #define GRAPH_BITS (WORD_BITS | PUNCT_BITS | \ (1 << NON_SPACING_MARK) | (1 << ENCLOSING_MARK) | \ (1 << COMBINING_SPACING_MARK) | (1 << LETTER_NUMBER) | \ (1 << OTHER_NUMBER) | \ (1 << MATH_SYMBOL) | (1 << CURRENCY_SYMBOL) | \ (1 << MODIFIER_SYMBOL) | (1 << OTHER_SYMBOL)) /* * Unicode characters less than this value are represented by themselves * in UTF-8 strings. */ #define UNICODE_SELF 0x80 /* * The following structures are used when mapping between Unicode (UCS-2) * and UTF-8. |
︙ | ︙ | |||
104 105 106 107 108 109 110 | * The return values is the number of bytes in the Utf character "ch". * * Side effects: * None. * *--------------------------------------------------------------------------- */ | | | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | * The return values is the number of bytes in the Utf character "ch". * * Side effects: * None. * *--------------------------------------------------------------------------- */ INLINE static int UtfCount(ch) int ch; /* The Tcl_UniChar whose size is returned. */ { if ((ch > 0) && (ch < UNICODE_SELF)) { return 1; } |
︙ | ︙ | |||
142 143 144 145 146 147 148 | * Tcl_UniCharToUtf -- * * Store the given Tcl_UniChar as a sequence of UTF-8 bytes in the * provided buffer. Equivalent to Plan 9 runetochar(). * * Results: * The return values is the number of bytes in the buffer that | | | | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | * Tcl_UniCharToUtf -- * * Store the given Tcl_UniChar as a sequence of UTF-8 bytes in the * provided buffer. Equivalent to Plan 9 runetochar(). * * Results: * The return values is the number of bytes in the buffer that * were consumed. * * Side effects: * None. * *--------------------------------------------------------------------------- */ INLINE int Tcl_UniCharToUtf(ch, str) int ch; /* The Tcl_UniChar to be stored in the * buffer. */ char *str; /* Buffer in which the UTF-8 representation * of the Tcl_UniChar is stored. Buffer must * be large enough to hold the UTF-8 character |
︙ | ︙ | |||
226 227 228 229 230 231 232 | * end of dsPtr. * * Side effects: * None. * *--------------------------------------------------------------------------- */ | | | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | * end of dsPtr. * * Side effects: * None. * *--------------------------------------------------------------------------- */ char * Tcl_UniCharToUtfDString(wString, numChars, dsPtr) CONST Tcl_UniChar *wString; /* Unicode string to convert to UTF-8. */ int numChars; /* Length of Unicode string in Tcl_UniChars * (must be >= 0). */ Tcl_DString *dsPtr; /* UTF-8 representation of string is * appended to this previously initialized |
︙ | ︙ | |||
285 286 287 288 289 290 291 | * number of bytes from the UTF-8 string that were consumed. * * Side effects: * None. * *--------------------------------------------------------------------------- */ | | | | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | * number of bytes from the UTF-8 string that were consumed. * * Side effects: * None. * *--------------------------------------------------------------------------- */ int Tcl_UtfToUniChar(str, chPtr) register CONST char *str; /* The UTF-8 string. */ register Tcl_UniChar *chPtr; /* Filled with the Tcl_UniChar represented * by the UTF-8 string. */ { register int byte; /* * Unroll 1 to 3 byte UTF-8 sequences, use loop to handle longer ones. */ byte = *((unsigned char *) str); if (byte < 0xC0) { /* |
︙ | ︙ | |||
330 331 332 333 334 335 336 | return 1; } else if (byte < 0xF0) { if (((str[1] & 0xC0) == 0x80) && ((str[2] & 0xC0) == 0x80)) { /* * Three-byte-character lead byte followed by two trail bytes. */ | | | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | return 1; } else if (byte < 0xF0) { if (((str[1] & 0xC0) == 0x80) && ((str[2] & 0xC0) == 0x80)) { /* * Three-byte-character lead byte followed by two trail bytes. */ *chPtr = (Tcl_UniChar) (((byte & 0x0F) << 12) | ((str[1] & 0x3F) << 6) | (str[2] & 0x3F)); return 3; } /* * A three-byte-character lead-byte not followed by two trail-bytes * represents itself. */ |
︙ | ︙ | |||
470 471 472 473 474 475 476 | * Tcl_NumUtfChars -- * * Returns the number of characters (not bytes) in the UTF-8 string, * not including the terminating NULL byte. This is equivalent to * Plan 9 utflen() and utfnlen(). * * Results: | | | | | 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | * Tcl_NumUtfChars -- * * Returns the number of characters (not bytes) in the UTF-8 string, * not including the terminating NULL byte. This is equivalent to * Plan 9 utflen() and utfnlen(). * * Results: * As above. * * Side effects: * None. * *--------------------------------------------------------------------------- */ int Tcl_NumUtfChars(str, len) register CONST char *str; /* The UTF-8 string to measure. */ int len; /* The length of the string in bytes, or -1 * for strlen(string). */ { Tcl_UniChar ch; register Tcl_UniChar *chPtr = &ch; |
︙ | ︙ | |||
545 546 547 548 549 550 551 | CONST char * Tcl_UtfFindFirst(string, ch) CONST char *string; /* The UTF-8 string to be searched. */ int ch; /* The Tcl_UniChar to search for. */ { int len; Tcl_UniChar find; | | | 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | CONST char * Tcl_UtfFindFirst(string, ch) CONST char *string; /* The UTF-8 string to be searched. */ int ch; /* The Tcl_UniChar to search for. */ { int len; Tcl_UniChar find; while (1) { len = TclUtfToUniChar(string, &find); if (find == ch) { return string; } if (*string == '\0') { return NULL; |
︙ | ︙ | |||
586 587 588 589 590 591 592 | Tcl_UtfFindLast(string, ch) CONST char *string; /* The UTF-8 string to be searched. */ int ch; /* The Tcl_UniChar to search for. */ { int len; Tcl_UniChar find; CONST char *last; | | | 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | Tcl_UtfFindLast(string, ch) CONST char *string; /* The UTF-8 string to be searched. */ int ch; /* The Tcl_UniChar to search for. */ { int len; Tcl_UniChar find; CONST char *last; last = NULL; while (1) { len = TclUtfToUniChar(string, &find); if (find == ch) { last = string; } if (*string == '\0') { |
︙ | ︙ | |||
620 621 622 623 624 625 626 | * the UTF-8 string. * * Side effects: * None. * *--------------------------------------------------------------------------- */ | | | | 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | * the UTF-8 string. * * Side effects: * None. * *--------------------------------------------------------------------------- */ CONST char * Tcl_UtfNext(str) CONST char *str; /* The current location in the string. */ { Tcl_UniChar ch; return str + TclUtfToUniChar(str, &ch); } |
︙ | ︙ | |||
660 661 662 663 664 665 666 | CONST char *str; /* The current location in the string. */ CONST char *start; /* Pointer to the beginning of the * string, to avoid going backwards too * far. */ { CONST char *look; int i, byte; | | | | | 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | CONST char *str; /* The current location in the string. */ CONST char *start; /* Pointer to the beginning of the * string, to avoid going backwards too * far. */ { CONST char *look; int i, byte; str--; look = str; for (i = 0; i < TCL_UTF_MAX; i++) { if (look < start) { if (str < start) { str = start; } break; } byte = *((unsigned char *) look); if (byte < 0x80) { break; } if (byte >= 0xC0) { return look; } look--; } return str; } /* *--------------------------------------------------------------------------- * * Tcl_UniCharAtIndex -- * * Returns the Unicode character represented at the specified * character (not byte) position in the UTF-8 string. * * Results: * As above. * * Side effects: * None. * *--------------------------------------------------------------------------- */ Tcl_UniChar Tcl_UniCharAtIndex(src, index) register CONST char *src; /* The UTF-8 string to dereference. */ register int index; /* The position of the desired character. */ { Tcl_UniChar ch; |
︙ | ︙ | |||
736 737 738 739 740 741 742 | CONST char * Tcl_UtfAtIndex(src, index) register CONST char *src; /* The UTF-8 string. */ register int index; /* The position of the desired character. */ { Tcl_UniChar ch; | | | | 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 | CONST char * Tcl_UtfAtIndex(src, index) register CONST char *src; /* The UTF-8 string. */ register int index; /* The position of the desired character. */ { Tcl_UniChar ch; while (index > 0) { index--; src += TclUtfToUniChar(src, &ch); } return src; } /* *--------------------------------------------------------------------------- * * Tcl_UtfBackslash -- * * Figure out how to handle a backslash sequence. * * Results: * Stores the bytes represented by the backslash sequence in dst and * returns the number of bytes written to dst. At most TCL_UTF_MAX * bytes are written to dst; dst must have been large enough to accept * those bytes. If readPtr isn't NULL then it is filled in with a * count of the number of bytes in the backslash sequence. * * Side effects: * The maximum number of bytes it takes to represent a Unicode * character in UTF-8 is guaranteed to be less than the number of * bytes used to express the backslash sequence that represents * that Unicode character. If the target buffer into which the * caller is going to store the bytes that represent the Unicode |
︙ | ︙ | |||
835 836 837 838 839 840 841 | upChar = Tcl_UniCharToUpper(ch); /* * To keep badly formed Utf strings from getting inflated by * the conversion (thereby causing a segfault), only copy the * upper case char to dst if its size is <= the original char. */ | | | 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 | upChar = Tcl_UniCharToUpper(ch); /* * To keep badly formed Utf strings from getting inflated by * the conversion (thereby causing a segfault), only copy the * upper case char to dst if its size is <= the original char. */ if (bytes < UtfCount(upChar)) { memcpy(dst, src, (size_t) bytes); dst += bytes; } else { dst += Tcl_UniCharToUtf(upChar, dst); } src += bytes; |
︙ | ︙ | |||
873 874 875 876 877 878 879 | int Tcl_UtfToLower(str) char *str; /* String to convert in place. */ { Tcl_UniChar ch, lowChar; char *src, *dst; int bytes; | | | | 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 | int Tcl_UtfToLower(str) char *str; /* String to convert in place. */ { Tcl_UniChar ch, lowChar; char *src, *dst; int bytes; /* * Iterate over the string until we hit the terminating null. */ src = dst = str; while (*src) { bytes = TclUtfToUniChar(src, &ch); lowChar = Tcl_UniCharToLower(ch); /* * To keep badly formed Utf strings from getting inflated by * the conversion (thereby causing a segfault), only copy the * lower case char to dst if its size is <= the original char. */ if (bytes < UtfCount(lowChar)) { memcpy(dst, src, (size_t) bytes); dst += bytes; } else { dst += Tcl_UniCharToUtf(lowChar, dst); } src += bytes; |
︙ | ︙ | |||
927 928 929 930 931 932 933 | int Tcl_UtfToTitle(str) char *str; /* String to convert in place. */ { Tcl_UniChar ch, titleChar, lowChar; char *src, *dst; int bytes; | | | 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 | int Tcl_UtfToTitle(str) char *str; /* String to convert in place. */ { Tcl_UniChar ch, titleChar, lowChar; char *src, *dst; int bytes; /* * Capitalize the first character and then lowercase the rest of the * characters until we get to a null. */ src = dst = str; |
︙ | ︙ | |||
1212 1213 1214 1215 1216 1217 1218 | */ int Tcl_UniCharLen(str) CONST Tcl_UniChar *str; /* Unicode string to find length of. */ { int len = 0; | | | 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 | */ int Tcl_UniCharLen(str) CONST Tcl_UniChar *str; /* Unicode string to find length of. */ { int len = 0; while (*str != '\0') { len++; str++; } return len; } |
︙ | ︙ | |||
1318 1319 1320 1321 1322 1323 1324 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsAlnum(ch) int ch; /* Unicode character to test. */ { | < < | | 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsAlnum(ch) int ch; /* Unicode character to test. */ { return (((ALPHA_BITS | DIGIT_BITS) >> GetCategory(ch)) & 1); } /* *---------------------------------------------------------------------- * * Tcl_UniCharIsAlpha -- * |
︙ | ︙ | |||
1343 1344 1345 1346 1347 1348 1349 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsAlpha(ch) int ch; /* Unicode character to test. */ { | < | | 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsAlpha(ch) int ch; /* Unicode character to test. */ { return ((ALPHA_BITS >> GetCategory(ch)) & 1); } /* *---------------------------------------------------------------------- * * Tcl_UniCharIsControl -- * |
︙ | ︙ | |||
1367 1368 1369 1370 1371 1372 1373 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsControl(ch) int ch; /* Unicode character to test. */ { | | | 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsControl(ch) int ch; /* Unicode character to test. */ { return ((CONTROL_BITS >> GetCategory(ch)) & 1); } /* *---------------------------------------------------------------------- * * Tcl_UniCharIsDigit -- * |
︙ | ︙ | |||
1390 1391 1392 1393 1394 1395 1396 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsDigit(ch) int ch; /* Unicode character to test. */ { | < | | 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsDigit(ch) int ch; /* Unicode character to test. */ { return (GetCategory(ch) == DECIMAL_DIGIT_NUMBER); } /* *---------------------------------------------------------------------- * * Tcl_UniCharIsGraph -- * |
︙ | ︙ | |||
1414 1415 1416 1417 1418 1419 1420 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsGraph(ch) int ch; /* Unicode character to test. */ { | < | | 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsGraph(ch) int ch; /* Unicode character to test. */ { return ((GRAPH_BITS >> GetCategory(ch)) & 1); } /* *---------------------------------------------------------------------- * * Tcl_UniCharIsLower -- * |
︙ | ︙ | |||
1438 1439 1440 1441 1442 1443 1444 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsLower(ch) int ch; /* Unicode character to test. */ { | | | 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsLower(ch) int ch; /* Unicode character to test. */ { return (GetCategory(ch) == LOWERCASE_LETTER); } /* *---------------------------------------------------------------------- * * Tcl_UniCharIsPrint -- * |
︙ | ︙ | |||
1461 1462 1463 1464 1465 1466 1467 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsPrint(ch) int ch; /* Unicode character to test. */ { | < | | 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsPrint(ch) int ch; /* Unicode character to test. */ { return (((GRAPH_BITS|SPACE_BITS) >> GetCategory(ch)) & 1); } /* *---------------------------------------------------------------------- * * Tcl_UniCharIsPunct -- * |
︙ | ︙ | |||
1485 1486 1487 1488 1489 1490 1491 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsPunct(ch) int ch; /* Unicode character to test. */ { | < | | 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsPunct(ch) int ch; /* Unicode character to test. */ { return ((PUNCT_BITS >> GetCategory(ch)) & 1); } /* *---------------------------------------------------------------------- * * Tcl_UniCharIsSpace -- * |
︙ | ︙ | |||
1509 1510 1511 1512 1513 1514 1515 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsSpace(ch) int ch; /* Unicode character to test. */ { | < < | < | | 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsSpace(ch) int ch; /* Unicode character to test. */ { /* * If the character is within the first 127 characters, just use the * standard C function, otherwise consult the Unicode table. */ if (((Tcl_UniChar) ch) < ((Tcl_UniChar) 0x80)) { return isspace(UCHAR(ch)); /* INTL: ISO space */ } else { return ((SPACE_BITS >> GetCategory(ch)) & 1); } } /* *---------------------------------------------------------------------- * * Tcl_UniCharIsUpper -- |
︙ | ︙ | |||
1544 1545 1546 1547 1548 1549 1550 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsUpper(ch) int ch; /* Unicode character to test. */ { | | | 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsUpper(ch) int ch; /* Unicode character to test. */ { return (GetCategory(ch) == UPPERCASE_LETTER); } /* *---------------------------------------------------------------------- * * Tcl_UniCharIsWordChar -- * |
︙ | ︙ | |||
1568 1569 1570 1571 1572 1573 1574 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsWordChar(ch) int ch; /* Unicode character to test. */ { | < | < | 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 | *---------------------------------------------------------------------- */ int Tcl_UniCharIsWordChar(ch) int ch; /* Unicode character to test. */ { return ((WORD_BITS >> GetCategory(ch)) & 1); } /* *---------------------------------------------------------------------- * * Tcl_UniCharCaseMatch -- * |
︙ | ︙ | |||
1605 1606 1607 1608 1609 1610 1611 | Tcl_UniCharCaseMatch(string, pattern, nocase) CONST Tcl_UniChar *string; /* Unicode String. */ CONST Tcl_UniChar *pattern; /* Pattern, which may contain special * characters. */ int nocase; /* 0 for case sensitive, 1 for insensitive */ { Tcl_UniChar ch1, p; | | | | | | 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 | Tcl_UniCharCaseMatch(string, pattern, nocase) CONST Tcl_UniChar *string; /* Unicode String. */ CONST Tcl_UniChar *pattern; /* Pattern, which may contain special * characters. */ int nocase; /* 0 for case sensitive, 1 for insensitive */ { Tcl_UniChar ch1, p; while (1) { p = *pattern; /* * See if we're at the end of both the pattern and the string. If * so, we succeeded. If we're at the end of the pattern but not at * the end of the string, we failed. */ if (p == 0) { return (*string == 0); } if ((*string == 0) && (p != '*')) { return 0; } /* * Check for a "*" as the next pattern character. It matches any * substring. We handle this by skipping all the characters up to the * next matching one in the pattern, and then calling ourselves * recursively for each postfix of string, until either we match or we * reach the end of the string. */ if (p == '*') { /* * Skip all successive *'s in the pattern */ while (*(++pattern) == '*') {} p = *pattern; if (p == 0) { |
︙ | ︙ | |||
1684 1685 1686 1687 1688 1689 1690 | } /* * Check for a "[" as the next pattern character. It is followed * by a list of characters that are acceptable, or by a range * (two characters separated by "-"). */ | | | 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 | } /* * Check for a "[" as the next pattern character. It is followed * by a list of characters that are acceptable, or by a range * (two characters separated by "-"). */ if (p == '[') { Tcl_UniChar startChar, endChar; pattern++; ch1 = (nocase ? Tcl_UniCharToLower(*string) : *string); string++; while (1) { |
︙ | ︙ | |||
1814 1815 1816 1817 1818 1819 1820 | /* * Check for a "*" as the next pattern character. It matches any * substring. We handle this by skipping all the characters up to the * next matching one in the pattern, and then calling ourselves * recursively for each postfix of string, until either we match or we * reach the end of the string. */ | | | 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 | /* * Check for a "*" as the next pattern character. It matches any * substring. We handle this by skipping all the characters up to the * next matching one in the pattern, and then calling ourselves * recursively for each postfix of string, until either we match or we * reach the end of the string. */ if (p == '*') { /* * Skip all successive *'s in the pattern */ while (*(++pattern) == '*') {} if (pattern == patternEnd) { return 1; |
︙ | ︙ | |||
1872 1873 1874 1875 1876 1877 1878 | } /* * Check for a "[" as the next pattern character. It is followed * by a list of characters that are acceptable, or by a range * (two characters separated by "-"). */ | | | 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 | } /* * Check for a "[" as the next pattern character. It is followed * by a list of characters that are acceptable, or by a range * (two characters separated by "-"). */ if (p == '[') { Tcl_UniChar ch1, startChar, endChar; pattern++; ch1 = (nocase ? Tcl_UniCharToLower(*string) : *string); string++; while (1) { |
︙ | ︙ |
Changes to tests/utf.test.
︙ | ︙ | |||
288 289 290 291 292 293 294 295 296 297 298 299 300 301 | test utf-21.4 {TclUniCharIsGraph} { # [Bug 3464428] string is graph \u0120 } {1} test utf-21.5 {unicode graph char in regc_locale.c} { # [Bug 3464428] regexp {^[[:graph:]]+$} \u0120 } {1} test utf-22.1 {TclUniCharIsWordChar} { string wordend "xyz123_bar fg" 0 } 10 test utf-22.2 {TclUniCharIsWordChar} { string wordend "x\u5080z123_bar\u203c fg" 0 | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | test utf-21.4 {TclUniCharIsGraph} { # [Bug 3464428] string is graph \u0120 } {1} test utf-21.5 {unicode graph char in regc_locale.c} { # [Bug 3464428] regexp {^[[:graph:]]+$} \u0120 } {1} test utf-21.6 {TclUniCharIsGraph} { # [Bug 3464428] string is graph \u00a0 } {0} test utf-21.7 {unicode graph char in regc_locale.c} { # [Bug 3464428] regexp {[[:graph:]]} \u0020\u00a0\u2028\u2029 } {0} test utf-21.8 {TclUniCharIsPrint} { # [Bug 3464428] string is print \u0009 } {0} test utf-21.9 {unicode print char in regc_locale.c} { # [Bug 3464428] regexp {[[:print:]]} \u0009 } {0} test utf-21.10 {unicode print char in regc_locale.c} { # [Bug 3464428] regexp {[[:print:]]} \u0009 } {0} test utf-21.11 {TclUniCharIsControl} { # [Bug 3464428] string is control \u00ad } {1} test utf-21.12 {unicode control char in regc_locale.c} { # [Bug 3464428] regexp {^[[:cntrl:]]$} \u00ad } {1} test utf-22.1 {TclUniCharIsWordChar} { string wordend "xyz123_bar fg" 0 } 10 test utf-22.2 {TclUniCharIsWordChar} { string wordend "x\u5080z123_bar\u203c fg" 0 |
︙ | ︙ |
Changes to tools/uniClass.tcl.
︙ | ︙ | |||
83 84 85 86 87 88 89 90 91 92 93 94 95 96 | * is automatically generated by the tools/uniClass.tcl script * and used in generic/regc_locale.c. Do not modify by hand. */ " foreach {type desc} { alpha "alphabetic characters" digit "decimal digit characters" punct "punctuation characters" space "white space characters" lower "lowercase characters" upper "uppercase characters" graph "unicode print characters excluding space" } { | > | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | * is automatically generated by the tools/uniClass.tcl script * and used in generic/regc_locale.c. Do not modify by hand. */ " foreach {type desc} { alpha "alphabetic characters" control "control characters" digit "decimal digit characters" punct "punctuation characters" space "white space characters" lower "lowercase characters" upper "uppercase characters" graph "unicode print characters excluding space" } { |
︙ | ︙ |