pp_next/pp_last/pp_redo problems
[p5sagit/p5-mst-13.2.git] / regcomp.c
index 0915af6..70682ae 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -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) {