diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 1998-12-01 10:13:03 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 1998-12-01 10:13:03 +0000 |
commit | 620e46c53f8c7c9f3fd77bcea9cd19e919047cba (patch) | |
tree | 1ac83266794480a3e4791c127dc810eaad53faf7 /regcomp.c | |
parent | cb8d882010745c11cc0ef19c46a72272356cf758 (diff) | |
download | perl-620e46c53f8c7c9f3fd77bcea9cd19e919047cba.tar.gz |
Separated the [:foo:] parsing to its own function.
Passes all tests.
p4raw-id: //depot/cfgperl@2426
Diffstat (limited to 'regcomp.c')
-rw-r--r-- | regcomp.c | 97 |
1 files changed, 44 insertions, 53 deletions
@@ -2093,6 +2093,44 @@ regwhite(char *p, char *e) return p; } +/* parse POSIX character classes like [[:foo:]] */ +STATIC char* +regpposixcc(I32 value) +{ + char *posixcc = 0; + + if (value == '[' && PL_regcomp_parse + 1 < PL_regxend && + /* I smell either [: or [= or [. -- POSIX has been here, right? */ + (*PL_regcomp_parse == ':' || + *PL_regcomp_parse == '=' || + *PL_regcomp_parse == '.')) { + char c = *PL_regcomp_parse; + char* s = PL_regcomp_parse++; + + while (PL_regcomp_parse < PL_regxend && *PL_regcomp_parse != c) + PL_regcomp_parse++; + if (PL_regcomp_parse == PL_regxend) + /* Grandfather lone [:, [=, [. */ + PL_regcomp_parse = s; + else { + PL_regcomp_parse++; /* skip over the c */ + if (*PL_regcomp_parse == ']') { + /* Not Implemented Yet. + * (POSIX Extended Character Classes, that is) + * The text between e.g. [: and :] would start + * at s + 1 and stop at regcomp_parse - 2. */ + if (ckWARN(WARN_UNSAFE) && !SIZE_ONLY) + warner(WARN_UNSAFE, + "Character class syntax [%c %c] is reserved for future extensions", c, c); + PL_regcomp_parse++; /* skip over the ending ] */ + posixcc = s + 1; + } + } + } + + return posixcc; +} + STATIC regnode * regclass(void) { @@ -2130,32 +2168,9 @@ regclass(void) while (PL_regcomp_parse < PL_regxend && *PL_regcomp_parse != ']') { skipcond: value = UCHARAT(PL_regcomp_parse++); - if (value == '[' && PL_regcomp_parse + 1 < PL_regxend && - /* I smell either [: or [= or [. -- POSIX has been here, right? */ - (*PL_regcomp_parse == ':' || *PL_regcomp_parse == '=' || *PL_regcomp_parse == '.')) { - char posixccc = *PL_regcomp_parse; - char* posixccs = PL_regcomp_parse++; - - while (PL_regcomp_parse < PL_regxend && *PL_regcomp_parse != posixccc) - PL_regcomp_parse++; - if (PL_regcomp_parse == PL_regxend) - /* Grandfather lone [:, [=, [. */ - PL_regcomp_parse = posixccs; - else { - PL_regcomp_parse++; /* skip over the posixccc */ - if (*PL_regcomp_parse == ']') { - /* Not Implemented Yet. - * (POSIX Extended Character Classes, that is) - * The text between e.g. [: and :] would start - * at posixccs + 1 and stop at regcomp_parse - 2. */ - if (ckWARN(WARN_UNSAFE) && !SIZE_ONLY) - warner(WARN_UNSAFE, - "Character class syntax [%c %c] is reserved for future extensions", posixccc, posixccc); - PL_regcomp_parse++; /* skip over the ending ] */ - } - } - } - if (value == '\\') { + if (value == '[') + (void)regpposixcc(value); /* ignore the return value for now */ + else if (value == '\\') { value = UCHARAT(PL_regcomp_parse++); switch (value) { case 'w': @@ -2350,33 +2365,9 @@ regclassutf8(void) value = utf8_to_uv((U8*)PL_regcomp_parse, &numlen); PL_regcomp_parse += numlen; - if (value == '[' && PL_regcomp_parse + 1 < PL_regxend && - /* I smell either [: or [= or [. -- POSIX has been here, right? */ - (*PL_regcomp_parse == ':' || *PL_regcomp_parse == '=' || *PL_regcomp_parse == '.')) { - char posixccc = *PL_regcomp_parse; - char* posixccs = PL_regcomp_parse++; - - while (PL_regcomp_parse < PL_regxend && *PL_regcomp_parse != posixccc) - PL_regcomp_parse++; - if (PL_regcomp_parse == PL_regxend) - /* Grandfather lone [:, [=, [. */ - PL_regcomp_parse = posixccs; - else { - PL_regcomp_parse++; /* skip over the posixccc */ - if (*PL_regcomp_parse == ']') { - /* Not Implemented Yet. - * (POSIX Extended Character Classes, that is) - * The text between e.g. [: and :] would start - * at posixccs + 1 and stop at regcomp_parse - 2. */ - if (ckWARN(WARN_UNSAFE) && !SIZE_ONLY) - warner(WARN_UNSAFE, - "Character class syntax [%c %c] is reserved for future extensions", posixccc, posixccc); - PL_regcomp_parse++; /* skip over the ending ] */ - } - } - } - - if (value == '\\') { + if (value == '[') + (void)regpposixcc(value); /* ignore the return value for now */ + else if (value == '\\') { value = utf8_to_uv((U8*)PL_regcomp_parse, &numlen); PL_regcomp_parse += numlen; switch (value) { |