Unicode properties: support \p{(?:Is)?L&} as an alias for \pL.
[p5sagit/p5-mst-13.2.git] / regexec.c
index 7b9f1c4..b691162 100644 (file)
--- a/regexec.c
+++ b/regexec.c
 #define LOAD_UTF8_CHARCLASS(a,b) STMT_START { if (!CAT2(PL_utf8_,a)) (void)CAT2(is_utf8_, a)((U8*)b); } STMT_END
 
 /* for use after a quantifier and before an EXACT-like node -- japhy */
-#define NEXT_IMPT(to_rn) STMT_START { \
-    while (OP(to_rn) == OPEN || OP(to_rn) == CLOSE || OP(to_rn) == EVAL) \
-       to_rn += NEXT_OFF(to_rn); \
+#define JUMPABLE(rn) ( \
+    OP(rn) == OPEN || OP(rn) == CLOSE || OP(rn) == EVAL || \
+    OP(rn) == SUSPEND || OP(rn) == IFMATCH \
+)
+
+#define NEAR_EXACT(rn) (PL_regkind[(U8)OP(rn)] == EXACT || JUMPABLE(rn))
+
+#define NEXT_IMPT(rn) STMT_START { \
+    while (JUMPABLE(rn)) \
+       if (OP(rn) == SUSPEND || OP(rn) == IFMATCH) \
+           rn = NEXTOPER(NEXTOPER(rn)); \
+       else rn += NEXT_OFF(rn); \
 } STMT_END 
 
 static void restore_pos(pTHX_ void *arg);
@@ -3043,12 +3052,7 @@ S_regmatch(pTHX_ regnode *prog)
                if (ln && l == 0)
                    n = ln;     /* don't backtrack */
                locinput = PL_reginput;
-               if (
-                   PL_regkind[(U8)OP(next)] == EXACT ||
-                   OP(next) == OPEN ||
-                   OP(next) == CLOSE ||
-                   OP(next) == EVAL
-               ) {
+               if (NEAR_EXACT(next)) {
                    regnode *text_node = next;
 
                    if (PL_regkind[(U8)OP(next)] != EXACT)
@@ -3117,12 +3121,7 @@ S_regmatch(pTHX_ regnode *prog)
                                  (IV) n, (IV)l)
                    );
                if (n >= ln) {
-                   if (
-                       PL_regkind[(U8)OP(next)] == EXACT ||
-                       OP(next) == OPEN ||
-                       OP(next) == CLOSE ||
-                       OP(next) == EVAL
-                   ) {
+                   if (NEAR_EXACT(next)) {
                        regnode *text_node = next;
 
                        if (PL_regkind[(U8)OP(next)] != EXACT)
@@ -3216,12 +3215,7 @@ S_regmatch(pTHX_ regnode *prog)
            * of the quantifier and the EXACT-like node.  -- japhy
            */
 
-           if (
-               PL_regkind[(U8)OP(next)] == EXACT ||
-               OP(next) == OPEN ||
-               OP(next) == CLOSE ||
-               OP(next) == EVAL
-           ) {
+           if (NEAR_EXACT(next)) {
                U8 *s;
                regnode *text_node = next;
 
@@ -3288,12 +3282,13 @@ S_regmatch(pTHX_ regnode *prog)
                        /* Find place 'next' could work */
                        if (!do_utf8) {
                            if (c1 == c2) {
-                               while (locinput <= e && *locinput != c1)
+                               while (locinput <= e &&
+                                      UCHARAT(locinput) != c1)
                                    locinput++;
                            } else {
                                while (locinput <= e
-                                      && *locinput != c1
-                                      && *locinput != c2)
+                                      && UCHARAT(locinput) != c1
+                                      && UCHARAT(locinput) != c2)
                                    locinput++;
                            }
                            count = locinput - old;