From: Jeff Pinyan Date: Fri, 14 Sep 2001 09:58:24 +0000 (-0400) Subject: more jumpables, and hit-bit bug X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e2d8ce26505da8717961292fe9055cf95f739ae3;p=p5sagit%2Fp5-mst-13.2.git more jumpables, and hit-bit bug Message-ID: p4raw-id: //depot/perl@12020 --- diff --git a/regexec.c b/regexec.c index 7b9f1c4..cad6a40 100644 --- a/regexec.c +++ b/regexec.c @@ -129,9 +129,18 @@ #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 diff --git a/t/op/pat.t b/t/op/pat.t index 23d9c85..2042f39 100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -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"; +} +