summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2005-03-21 23:29:09 +0100
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-03-21 21:33:16 +0000
commitcc601c3163078dbee18369839db37a81c9f1d02a (patch)
treed62d2ced4239e667a2b0367b266ae38575053ae9
parentefcaa95b05d30c10585967bb358126b84bd75b53 (diff)
downloadperl-cc601c3163078dbee18369839db37a81c9f1d02a.tar.gz
Re: regexp trie fails compile on VMS
Message-ID: <9b18b311050321132917a4b1c7@mail.gmail.com> p4raw-id: //depot/perl@24059
-rw-r--r--regcomp.c17
-rw-r--r--regcomp.h1
-rw-r--r--regexec.c7
3 files changed, 16 insertions, 9 deletions
diff --git a/regcomp.c b/regcomp.c
index 1f9161a4a3..5bfcd70f8a 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -1160,8 +1160,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
*/
trie->states[ state ].trans.base=base;
}
- Renew( trie->trans, tp + 1, reg_trie_trans );
-
+ trie->lasttrans = tp + 1;
}
} else {
/*
@@ -1409,7 +1408,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
}
}
}
- Renew( trie->trans, pos + 1, reg_trie_trans);
+ trie->lasttrans = pos + 1;
Renew( trie->states, laststate + 1, reg_trie_state);
DEBUG_TRIE_COMPILE_MORE_r(
PerlIO_printf( Perl_debug_log, " Alloc: %d Orig: %d elements, Final:%d. Savings of %%%5.2f\n",
@@ -1419,6 +1418,8 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
} /* end table compress */
}
+ /* resize the trans array to remove unused space */
+ Renew( trie->trans, trie->lasttrans, reg_trie_trans);
DEBUG_TRIE_COMPILE_r({
U32 state;
@@ -1436,9 +1437,11 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
}
}
PerlIO_printf( Perl_debug_log, "\n-----:-----------------------");
+
for( state = 0 ; state < trie->uniquecharcount ; state++ )
PerlIO_printf( Perl_debug_log, "-----");
PerlIO_printf( Perl_debug_log, "\n");
+
for( state = 1 ; state < trie->laststate ; state++ ) {
U32 base = trie->states[ state ].trans.base;
@@ -1455,14 +1458,16 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
if ( base ) {
U32 ofs = 0;
- while( ( base + ofs - trie->uniquecharcount ) >=0 &&
- trie->trans[ base + ofs - trie->uniquecharcount ].check != state )
+ while( ( base + ofs < trie->uniquecharcount ) ||
+ ( base + ofs - trie->uniquecharcount < trie->lasttrans
+ && trie->trans[ base + ofs - trie->uniquecharcount ].check != state))
ofs++;
PerlIO_printf( Perl_debug_log, "+%02X[ ", ofs);
for ( ofs = 0 ; ofs < trie->uniquecharcount ; ofs++ ) {
- if ( ( base + ofs - trie->uniquecharcount>=0) &&
+ if ( ( base + ofs >= trie->uniquecharcount ) &&
+ ( base + ofs - trie->uniquecharcount < trie->lasttrans ) &&
trie->trans[ base + ofs - trie->uniquecharcount ].check == state )
{
PerlIO_printf( Perl_debug_log, "%04X ",
diff --git a/regcomp.h b/regcomp.h
index 94e54e84cc..dbf55f556d 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -463,6 +463,7 @@ struct _reg_trie_data {
U16 wordcount;
STRLEN charcount;
U32 laststate;
+ U32 lasttrans;
U16 *charmap;
HV *widecharmap;
reg_trie_state *states;
diff --git a/regexec.c b/regexec.c
index 9efb4794b2..fb455a68a9 100644
--- a/regexec.c
+++ b/regexec.c
@@ -2361,7 +2361,8 @@ typedef union re_unwind_t {
} \
} \
if ( charid && \
- ( base + charid - 1 - trie->uniquecharcount ) >=0 && \
+ ( base + charid > trie->uniquecharcount ) && \
+ ( base + charid - 1 - trie->uniquecharcount < trie->lasttrans) && \
trie->trans[ base + charid - 1 - trie->uniquecharcount ].check == state ) \
{ \
state = trie->trans[ base + charid - 1 - trie->uniquecharcount ].next; \
@@ -2731,7 +2732,7 @@ S_regmatch(pTHX_ regnode *prog)
tmp ? SvPV_nolen( *tmp ) : "not compiled under -Dr",
PL_colors[5] );
});
- PL_reginput = accept_buff[ 0 ].endpos;
+ PL_reginput = (char *)accept_buff[ 0 ].endpos;
/* in this case we free tmps/leave before we call regmatch
as we wont be using accept_buff again. */
FREETMPS;
@@ -2772,7 +2773,7 @@ S_regmatch(pTHX_ regnode *prog)
accept_buff[ accepted ] = tmp;
best = accepted;
}
- PL_reginput = accept_buff[ best ].endpos;
+ PL_reginput = (char *)accept_buff[ best ].endpos;
/*
as far as I can tell we only need the SAVETMPS/FREETMPS