Change 12020 by jhi@alpha on 2001/09/14 14:10:44
Subject: [PATCH regexec.c] more jumpables, and hit-bit bug
From: "Jeff 'japhy/Marillion' Pinyan" <[EMAIL PROTECTED]>
Date: Fri, 14 Sep 2001 09:58:24 -0400 (EDT)
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/regexec.c#188 edit
... //depot/perl/t/op/pat.t#119 edit
Differences ...
==== //depot/perl/regexec.c#188 (text) ====
Index: perl/regexec.c
--- perl/regexec.c.~1~ Fri Sep 14 08:15:05 2001
+++ perl/regexec.c Fri Sep 14 08:15:05 2001
@@ -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 @@
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 @@
(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 @@
* 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 @@
/* 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
==== //depot/perl/t/op/pat.t#119 (xtext) ====
Index: perl/t/op/pat.t
--- perl/t/op/pat.t.~1~ Fri Sep 14 08:15:05 2001
+++ perl/t/op/pat.t Fri Sep 14 08:15:05 2001
@@ -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 686\n";
}
+
my $test = 687;
# Force scalar context on the patern match
@@ -2118,3 +2119,11 @@
$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";
+}
+
End of Patch.