Change 29916 by [EMAIL PROTECTED] on 2007/01/22 16:26:58
Integrate:
[ 27526]
reduce S_regrepeat_hard() callers from 3 to 1
[ 27534]
inline, then delete, S_regrepeat_hard()
[ 27535]
Restore a bit of change 27533 that change 27534 inadvertently unwound.
[ 27569]
remove idential code branch from regmatch()
Affected files ...
... //depot/maint-5.8/perl/embed.fnc#176 integrate
... //depot/maint-5.8/perl/embed.h#131 integrate
... //depot/maint-5.8/perl/proto.h#165 integrate
... //depot/maint-5.8/perl/regexec.c#68 integrate
Differences ...
==== //depot/maint-5.8/perl/embed.fnc#176 (text) ====
Index: perl/embed.fnc
--- perl/embed.fnc#175~29915~ 2007-01-22 07:49:59.000000000 -0800
+++ perl/embed.fnc 2007-01-22 08:26:58.000000000 -0800
@@ -1261,7 +1261,6 @@
#if defined(PERL_IN_REGEXEC_C) || defined(PERL_DECL_PROT)
ERs |I32 |regmatch |NN regnode *prog
ERs |I32 |regrepeat |NN const regnode *p|I32 max
-ERs |I32 |regrepeat_hard |NN regnode *p|I32 max|NN I32 *lp
ERs |I32 |regtry |NN regexp *prog|NN char *startpos
ERs |bool |reginclass |NN const regnode *n|NN const U8 *p|NULLOK
STRLEN *lenp\
|bool do_utf8sv_is_utf8
==== //depot/maint-5.8/perl/embed.h#131 (text+w) ====
Index: perl/embed.h
--- perl/embed.h#130~29904~ 2007-01-20 16:30:14.000000000 -0800
+++ perl/embed.h 2007-01-22 08:26:58.000000000 -0800
@@ -1291,7 +1291,6 @@
#if defined(PERL_CORE) || defined(PERL_EXT)
#define regmatch S_regmatch
#define regrepeat S_regrepeat
-#define regrepeat_hard S_regrepeat_hard
#define regtry S_regtry
#define reginclass S_reginclass
#define regcppush S_regcppush
@@ -3366,7 +3365,6 @@
#if defined(PERL_CORE) || defined(PERL_EXT)
#define regmatch(a) S_regmatch(aTHX_ a)
#define regrepeat(a,b) S_regrepeat(aTHX_ a,b)
-#define regrepeat_hard(a,b,c) S_regrepeat_hard(aTHX_ a,b,c)
#define regtry(a,b) S_regtry(aTHX_ a,b)
#define reginclass(a,b,c,d) S_reginclass(aTHX_ a,b,c,d)
#define regcppush(a) S_regcppush(aTHX_ a)
==== //depot/maint-5.8/perl/proto.h#165 (text+w) ====
Index: perl/proto.h
--- perl/proto.h#164~29915~ 2007-01-22 07:49:59.000000000 -0800
+++ perl/proto.h 2007-01-22 08:26:58.000000000 -0800
@@ -1845,9 +1845,6 @@
STATIC I32 S_regrepeat(pTHX_ const regnode *p, I32 max)
__attribute__warn_unused_result__;
-STATIC I32 S_regrepeat_hard(pTHX_ regnode *p, I32 max, I32 *lp)
- __attribute__warn_unused_result__;
-
STATIC I32 S_regtry(pTHX_ regexp *prog, char *startpos)
__attribute__warn_unused_result__;
==== //depot/maint-5.8/perl/regexec.c#68 (text) ====
Index: perl/regexec.c
--- perl/regexec.c#67~29915~ 2007-01-22 07:49:59.000000000 -0800
+++ perl/regexec.c 2007-01-22 08:26:58.000000000 -0800
@@ -3399,7 +3399,9 @@
case CURLYM:
{
I32 l = 0;
+ I32 matches = 0;
CHECKPOINT lastcp;
+ I32 maxwanted;
/* We suppose that the next guy does not need
backtracking: in particular, it is of constant non-zero length,
@@ -3417,11 +3419,38 @@
if (paren)
scan += NEXT_OFF(scan); /* Skip former OPEN. */
PL_reginput = locinput;
+ maxwanted = minmod ? ln : n;
+ if (maxwanted) {
+ while (PL_reginput < PL_regeol && matches < maxwanted) {
+ if (!regmatch(scan))
+ break;
+ /* on first match, determine length, l */
+ if (!matches++) {
+ if (PL_reg_match_utf8) {
+ char *s = locinput;
+ while (s < PL_reginput) {
+ l++;
+ s += UTF8SKIP(s);
+ }
+ }
+ else {
+ l = PL_reginput - locinput;
+ }
+ if (l == 0) {
+ matches = maxwanted;
+ break;
+ }
+ }
+ locinput = PL_reginput;
+ }
+ }
+
+ PL_reginput = locinput;
+
if (minmod) {
minmod = 0;
- if (ln && regrepeat_hard(scan, ln, &l) < ln)
+ if (ln && matches < ln)
sayNO;
- locinput = PL_reginput;
if (HAS_TEXT(next) || JUMPABLE(next)) {
regnode *text_node = next;
@@ -3467,7 +3496,7 @@
}
/* Couldn't or didn't -- move forward. */
PL_reginput = locinput;
- if (regrepeat_hard(scan, 1, &l)) {
+ if (regmatch(scan)) {
ln++;
locinput = PL_reginput;
}
@@ -3476,15 +3505,13 @@
}
}
else {
- n = regrepeat_hard(scan, n, &l);
- locinput = PL_reginput;
DEBUG_r(
PerlIO_printf(Perl_debug_log,
"%*s matched %"IVdf" times,
len=%"IVdf"...\n",
(int)(REPORT_CODE_OFF+PL_regindent*2), "",
- (IV) n, (IV)l)
+ (IV) matches, (IV)l)
);
- if (n >= ln) {
+ if (matches >= ln) {
if (HAS_TEXT(next) || JUMPABLE(next)) {
regnode *text_node = next;
@@ -3511,19 +3538,20 @@
}
assume_ok_REG:
REGCP_SET(lastcp);
- while (n >= ln) {
+ while (matches >= ln) {
/* If it could work, try it. */
if (c1 == -1000 ||
UCHARAT(PL_reginput) == c1 ||
UCHARAT(PL_reginput) == c2)
{
DEBUG_r(
- PerlIO_printf(Perl_debug_log,
- "%*s trying tail with
n=%"IVdf"...\n",
-
(int)(REPORT_CODE_OFF+PL_regindent*2), "", (IV)n)
+ PerlIO_printf(Perl_debug_log,
+ "%*s trying tail with matches=%"IVdf"...\n",
+ (int)(REPORT_CODE_OFF+PL_regindent*2),
+ "", (IV)matches)
);
if (paren) {
- if (n) {
+ if (matches) {
PL_regstartp[paren] = HOPc(PL_reginput, -l) -
PL_bostr;
PL_regendp[paren] = PL_reginput - PL_bostr;
}
@@ -3535,7 +3563,7 @@
REGCP_UNWIND(lastcp);
}
/* Couldn't or didn't -- back up. */
- n--;
+ matches--;
locinput = HOPc(locinput, -l);
PL_reginput = locinput;
}
@@ -3770,29 +3798,7 @@
ln--;
}
REGCP_SET(lastcp);
- if (paren) {
- UV c = 0;
- while (n >= ln) {
- if (c1 != -1000) {
- if (do_utf8)
- c = utf8n_to_uvchr((U8*)PL_reginput,
- UTF8_MAXBYTES, 0,
- uniflags);
- else
- c = UCHARAT(PL_reginput);
- }
- /* If it could work, try it. */
- if (c1 == -1000 || c == (UV)c1 || c == (UV)c2)
- {
- TRYPAREN(paren, n, PL_reginput);
- REGCP_UNWIND(lastcp);
- }
- /* Couldn't or didn't -- back up. */
- n--;
- PL_reginput = locinput = HOPc(locinput, -1);
- }
- }
- else {
+ {
UV c = 0;
while (n >= ln) {
if (c1 != -1000) {
@@ -4274,57 +4280,6 @@
return(c);
}
-/*
- - regrepeat_hard - repeatedly match something, report total lenth and length
- *
- * The repeater is supposed to have constant non-zero length.
- */
-
-STATIC I32
-S_regrepeat_hard(pTHX_ regnode *p, I32 max, I32 *lp)
-{
- register char *scan = NULL;
- register char *start;
- register char *loceol = PL_regeol;
- I32 l = 0;
- I32 count = 0, res = 1;
-
- if (!max)
- return 0;
-
- start = PL_reginput;
- if (PL_reg_match_utf8) {
- while (PL_reginput < loceol && (scan = PL_reginput, res = regmatch(p)))
{
- if (!count++) {
- l = 0;
- while (start < PL_reginput) {
- l++;
- start += UTF8SKIP(start);
- }
- *lp = l;
- if (l == 0)
- return max;
- }
- if (count == max)
- return count;
- }
- }
- else {
- while (PL_reginput < loceol && (scan = PL_reginput, res = regmatch(p)))
{
- if (!count++) {
- *lp = l = PL_reginput - start;
- if (max != REG_INFTY && l*max < loceol - scan)
- loceol = scan + l*max;
- if (l == 0)
- return max;
- }
- }
- }
- if (!res)
- PL_reginput = scan;
-
- return count;
-}
/*
- regclass_swash - prepare the utf8 swash
End of Patch.