This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
more jumpables, and hit-bit bug
authorJeff Pinyan <japhy@pobox.com>
Fri, 14 Sep 2001 09:58:24 +0000 (05:58 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Fri, 14 Sep 2001 14:10:44 +0000 (14:10 +0000)
Message-ID: <Pine.GSO.4.21.0109140955250.12393-100000@crusoe.crusoe.net>

p4raw-id: //depot/perl@12020

regexec.c
t/op/pat.t

index 7b9f1c4..cad6a40 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,7 +3282,7 @@ S_regmatch(pTHX_ regnode *prog)
                        /* Find place 'next' could work */
                        if (!do_utf8) {
                            if (c1 == c2) {
-                               while (locinput <= e && *locinput != c1)
+                               while (locinput <= e && (U8) *locinput != (U8) c1)
                                    locinput++;
                            } else {
                                while (locinput <= e
index 23d9c85..2042f39 100755 (executable)
@@ -6,7 +6,7 @@
 
 $| = 1;
 
-print "1..714\n";
+print "1..715\n";
 
 BEGIN {
     chdir 't' if -d 't';
@@ -2009,6 +2009,7 @@ print "ok 683\n" if @a == 9 && "@a" eq "f o o \n $a $b b a r";
     print "ok 686\n";
 }
 
+
 my $test = 687;
 
 # Force scalar context on the patern match
@@ -2118,3 +2119,11 @@ sub ok ($$) {
     $x = "\x9b" . "y";
     ok ($x =~ /^[\x{09b}y]{2}$/, "\\x{09b} is to be treated as \\x9b");
 }
+
+{
+  # high bit bug -- japhy
+  my $x = "ab\200d";
+  $x =~ /.*?\200/ or print "not ";
+  print "ok 715\n";
+}
+