# define PERL_NO_GET_CONTEXT
#endif
-/*SUPPRESS 112*/
/*
* pregcomp and pregexec -- regsub and regerror are not used in perl
*
* Simple_vFAIL -- like FAIL, but marks the current location in the scan
*/
#define Simple_vFAIL(m) STMT_START { \
- IV offset = RExC_parse - RExC_precomp; \
+ const IV offset = RExC_parse - RExC_precomp; \
Perl_croak(aTHX_ "%s" REPORT_LOCATION, \
m, (int)offset, RExC_precomp, RExC_precomp + offset); \
} STMT_END
* Like Simple_vFAIL(), but accepts two arguments.
*/
#define Simple_vFAIL2(m,a1) STMT_START { \
- IV offset = RExC_parse - RExC_precomp; \
+ const IV offset = RExC_parse - RExC_precomp; \
S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, \
(int)offset, RExC_precomp, RExC_precomp + offset); \
} STMT_END
* Like Simple_vFAIL(), but accepts three arguments.
*/
#define Simple_vFAIL3(m, a1, a2) STMT_START { \
- IV offset = RExC_parse - RExC_precomp; \
+ const IV offset = RExC_parse - RExC_precomp; \
S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, a2, \
(int)offset, RExC_precomp, RExC_precomp + offset); \
} STMT_END
* Like Simple_vFAIL(), but accepts four arguments.
*/
#define Simple_vFAIL4(m, a1, a2, a3) STMT_START { \
- IV offset = RExC_parse - RExC_precomp; \
+ const IV offset = RExC_parse - RExC_precomp; \
S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, a2, a3, \
(int)offset, RExC_precomp, RExC_precomp + offset); \
} STMT_END
-/*
- * Like Simple_vFAIL(), but accepts five arguments.
- */
-#define Simple_vFAIL5(m, a1, a2, a3, a4) STMT_START { \
- IV offset = RExC_parse - RExC_precomp; \
- S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, a2, a3, a4, \
- (int)offset, RExC_precomp, RExC_precomp + offset); \
-} STMT_END
-
-
#define vWARN(loc,m) STMT_START { \
- IV offset = loc - RExC_precomp; \
+ const IV offset = loc - RExC_precomp; \
Perl_warner(aTHX_ packWARN(WARN_REGEXP), "%s" REPORT_LOCATION, \
m, (int)offset, RExC_precomp, RExC_precomp + offset); \
} STMT_END
#define vWARNdep(loc,m) STMT_START { \
- IV offset = loc - RExC_precomp; \
+ const IV offset = loc - RExC_precomp; \
Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_REGEXP), \
"%s" REPORT_LOCATION, \
m, (int)offset, RExC_precomp, RExC_precomp + offset); \
#define vWARN2(loc, m, a1) STMT_START { \
- IV offset = loc - RExC_precomp; \
+ const IV offset = loc - RExC_precomp; \
Perl_warner(aTHX_ packWARN(WARN_REGEXP), m REPORT_LOCATION, \
a1, (int)offset, RExC_precomp, RExC_precomp + offset); \
} STMT_END
#define vWARN3(loc, m, a1, a2) STMT_START { \
- IV offset = loc - RExC_precomp; \
+ const IV offset = loc - RExC_precomp; \
Perl_warner(aTHX_ packWARN(WARN_REGEXP), m REPORT_LOCATION, \
a1, a2, (int)offset, RExC_precomp, RExC_precomp + offset); \
} STMT_END
#define vWARN4(loc, m, a1, a2, a3) STMT_START { \
- IV offset = loc - RExC_precomp; \
+ const IV offset = loc - RExC_precomp; \
Perl_warner(aTHX_ packWARN(WARN_REGEXP), m REPORT_LOCATION, \
a1, a2, a3, (int)offset, RExC_precomp, RExC_precomp + offset); \
} STMT_END
#define vWARN5(loc, m, a1, a2, a3, a4) STMT_START { \
- IV offset = loc - RExC_precomp; \
+ const IV offset = loc - RExC_precomp; \
Perl_warner(aTHX_ packWARN(WARN_REGEXP), m REPORT_LOCATION, \
a1, a2, a3, a4, (int)offset, RExC_precomp, RExC_precomp + offset); \
} STMT_END
}
SvCUR_set(data->last_found, 0);
{
- SV * sv = data->last_found;
- MAGIC *mg =
+ SV * const sv = data->last_found;
+ MAGIC * const mg =
SvUTF8(sv) && SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_utf8) : NULL;
if (mg && mg->mg_len > 0)
mg->mg_len = 0;
/* Can match anything (initialization) */
STATIC int
-S_cl_is_anything(pTHX_ struct regnode_charclass_class *cl)
+S_cl_is_anything(pTHX_ const struct regnode_charclass_class *cl)
{
int value;
/* We assume that cl is not inverted */
STATIC void
S_cl_and(pTHX_ struct regnode_charclass_class *cl,
- struct regnode_charclass_class *and_with)
+ const struct regnode_charclass_class *and_with)
{
if (!(and_with->flags & ANYOF_CLASS)
&& !(cl->flags & ANYOF_CLASS)
/* 'OR' a given class with another one. Can create false positives */
/* We assume that cl is not inverted */
STATIC void
-S_cl_or(pTHX_ RExC_state_t *pRExC_state, struct regnode_charclass_class *cl, struct regnode_charclass_class *or_with)
+S_cl_or(pTHX_ RExC_state_t *pRExC_state, struct regnode_charclass_class *cl, const struct regnode_charclass_class *or_with)
{
if (or_with->flags & ANYOF_INVERT) {
/* We do not use
DEBUG_TRIE_COMPILE_r({ \
SV *tmp; \
if ( UTF ) { \
- tmp = newSVpv( "", 0 ); \
+ tmp = newSVpvn( "", 0 ); \
pv_uni_display( tmp, uc, len, 60, UNI_DISPLAY_REGEX ); \
} else { \
tmp = Perl_newSVpvf_nocontext( "%c", (int)uvc ); \
} STMT_END
#define TRIE_LIST_NEW(state) STMT_START { \
- Newz( 1023, trie->states[ state ].trans.list, \
+ Newxz( trie->states[ state ].trans.list, \
4, reg_trie_trans_le ); \
TRIE_LIST_CUR( state ) = 1; \
TRIE_LIST_LEN( state ) = 4; \
GET_RE_DEBUG_FLAGS_DECL;
- Newz( 848200, trie, 1, reg_trie_data );
+ Newxz( trie, 1, reg_trie_data );
trie->refcount = 1;
RExC_rx->data->data[ data_slot ] = (void*)trie;
- Newz( 848201, trie->charmap, 256, U16 );
+ Newxz( trie->charmap, 256, U16 );
DEBUG_r({
trie->words = newAV();
trie->revcharmap = newAV();
for ( cur = first ; cur < last ; cur = regnext( cur ) ) {
regnode *noper = NEXTOPER( cur );
const U8 *uc = (U8*)STRING( noper );
- const U8 *e = uc + STR_LEN( noper );
+ const U8 * const e = uc + STR_LEN( noper );
STRLEN foldlen = 0;
U8 foldbuf[ UTF8_MAXBYTES_CASE + 1 ];
const U8 *scan = (U8*)NULL;
DEBUG_TRIE_COMPILE_r(
PerlIO_printf( Perl_debug_log, "TRIE(%s): W:%d C:%d Uq:%d \n",
( trie->widecharmap ? "UTF8" : "NATIVE" ), trie->wordcount,
- trie->charcount, trie->uniquecharcount )
+ (int)trie->charcount, trie->uniquecharcount )
);
STRLEN transcount = 1;
- Newz( 848204, trie->states, trie->charcount + 2, reg_trie_state );
+ Newxz( trie->states, trie->charcount + 2, reg_trie_state );
TRIE_LIST_NEW(1);
next_alloc = 2;
regnode *noper = NEXTOPER( cur );
U8 *uc = (U8*)STRING( noper );
- U8 *e = uc + STR_LEN( noper );
+ const U8 * const e = uc + STR_LEN( noper );
U32 state = 1; /* required init */
U16 charid = 0; /* sanity init */
U8 *scan = (U8*)NULL; /* sanity init */
newstate = TRIE_LIST_ITEM( state, check ).newstate;
break;
}
- }
- if ( ! newstate ) {
- newstate = next_alloc++;
- TRIE_LIST_PUSH( state, charid, newstate );
- transcount++;
- }
- state = newstate;
-
+ }
+ if ( ! newstate ) {
+ newstate = next_alloc++;
+ TRIE_LIST_PUSH( state, charid, newstate );
+ transcount++;
+ }
+ state = newstate;
} else {
Perl_croak( aTHX_ "panic! In trie construction, no char mapping for %"IVdf, uvc );
}
DEBUG_TRIE_COMPILE_MORE_r({
U32 state;
- U16 charid;
- /*
- print out the table precompression.
- */
+ /* print out the table precompression. */
PerlIO_printf( Perl_debug_log, "\nState :Word | Transition Data\n" );
PerlIO_printf( Perl_debug_log, "------:-----+-----------------" );
for( state=1 ; state < next_alloc ; state ++ ) {
+ U16 charid;
PerlIO_printf( Perl_debug_log, "\n %04"UVXf" :", (UV)state );
if ( ! trie->states[ state ].wordnum ) {
for( charid = 1 ; charid <= TRIE_LIST_USED( state ) ; charid++ ) {
SV **tmp = av_fetch( trie->revcharmap, TRIE_LIST_ITEM(state,charid).forid, 0);
PerlIO_printf( Perl_debug_log, "%s:%3X=%04"UVXf" | ",
- SvPV_nolen( *tmp ),
+ SvPV_nolen_const( *tmp ),
TRIE_LIST_ITEM(state,charid).forid,
(UV)TRIE_LIST_ITEM(state,charid).newstate
);
PerlIO_printf( Perl_debug_log, "\n\n" );
});
- Newz( 848203, trie->trans, transcount ,reg_trie_trans );
+ Newxz( trie->trans, transcount ,reg_trie_trans );
{
U32 state;
- U16 idx;
U32 tp = 0;
U32 zp = 0;
if (trie->states[state].trans.list) {
U16 minid=TRIE_LIST_ITEM( state, 1).forid;
U16 maxid=minid;
-
+ U16 idx;
for( idx = 2 ; idx <= TRIE_LIST_USED( state ) ; idx++ ) {
if ( TRIE_LIST_ITEM( state, idx).forid < minid ) {
*/
- Newz( 848203, trie->trans, ( trie->charcount + 1 ) * trie->uniquecharcount + 1,
+ Newxz( trie->trans, ( trie->charcount + 1 ) * trie->uniquecharcount + 1,
reg_trie_trans );
- Newz( 848204, trie->states, trie->charcount + 2, reg_trie_state );
+ Newxz( trie->states, trie->charcount + 2, reg_trie_state );
next_alloc = trie->uniquecharcount + 1;
for ( cur = first ; cur < last ; cur = regnext( cur ) ) {
regnode *noper = NEXTOPER( cur );
- U8 *uc = (U8*)STRING( noper );
- U8 *e = uc + STR_LEN( noper );
+ const U8 *uc = (U8*)STRING( noper );
+ const U8 * const e = uc + STR_LEN( noper );
U32 state = 1; /* required init */
for( charid = 0 ; charid < trie->uniquecharcount ; charid++ ) {
SV **tmp = av_fetch( trie->revcharmap, charid, 0);
if ( tmp ) {
- PerlIO_printf( Perl_debug_log, "%4.4s ", SvPV_nolen( *tmp ) );
+ PerlIO_printf( Perl_debug_log, "%4.4s ", SvPV_nolen_const( *tmp ) );
}
}
demq
*/
- U32 laststate = TRIE_NODENUM( next_alloc );
- U32 used , state, charid;
+ const U32 laststate = TRIE_NODENUM( next_alloc );
+ U32 state, charid;
U32 pos = 0, zp=0;
trie->laststate = laststate;
for ( state = 1 ; state < laststate ; state++ ) {
U8 flag = 0;
- U32 stateidx = TRIE_NODEIDX( state );
- U32 o_used=trie->trans[ stateidx ].check;
- used = trie->trans[ stateidx ].check;
+ const U32 stateidx = TRIE_NODEIDX( state );
+ const U32 o_used = trie->trans[ stateidx ].check;
+ U32 used = trie->trans[ stateidx ].check;
trie->trans[ stateidx ].check = 0;
for ( charid = 0 ; used && charid < trie->uniquecharcount ; charid++ ) {
DEBUG_TRIE_COMPILE_MORE_r(
PerlIO_printf( Perl_debug_log,
" Alloc: %d Orig: %"IVdf" elements, Final:%"IVdf". Savings of %%%5.2f\n",
- ( ( trie->charcount + 1 ) * trie->uniquecharcount + 1 ), (IV)next_alloc, (IV)pos,
+ (int)( ( trie->charcount + 1 ) * trie->uniquecharcount + 1 ),
+ (IV)next_alloc,
+ (IV)pos,
( ( next_alloc - pos ) * 100 ) / (double)next_alloc );
);
for( state = 0 ; state < trie->uniquecharcount ; state++ ) {
SV **tmp = av_fetch( trie->revcharmap, state, 0);
if ( tmp ) {
- PerlIO_printf( Perl_debug_log, "%4.4s ", SvPV_nolen( *tmp ) );
+ PerlIO_printf( Perl_debug_log, "%4.4s ", SvPV_nolen_const( *tmp ) );
}
}
PerlIO_printf( Perl_debug_log, "\n-----:-----------------------");
PerlIO_printf( Perl_debug_log, "\n");
for( state = 1 ; state < trie->laststate ; state++ ) {
- U32 base = trie->states[ state ].trans.base;
+ const U32 base = trie->states[ state ].trans.base;
PerlIO_printf( Perl_debug_log, "#%04"UVXf" ", (UV)state);
/* REx optimizer. Converts nodes into quickier variants "in place".
Finds fixed substrings. */
-/* Stops at toplevel WHILEM as well as at `last'. At end *scanp is set
+/* Stops at toplevel WHILEM as well as at "last". At end *scanp is set
to the position after last scanned or to NULL. */
STATIC I32
-S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32 flags, U32 depth)
+S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap,
+ regnode *last, scan_data_t *data, U32 flags, U32 depth)
/* scanp: Start here (read-write). */
/* deltap: Write maxlen-minlen here. */
/* last: Stop before this one. */
SV *mysv=sv_newmortal();
regprop( mysv, scan);
PerlIO_printf(Perl_debug_log, "%*speep: %s (0x%08"UVXf")\n",
- (int)depth*2, "", SvPV_nolen(mysv), PTR2UV(scan));
+ (int)depth*2, "", SvPV_nolen_const(mysv), PTR2UV(scan));
});
if (PL_regkind[(U8)OP(scan)] == EXACT) {
n = regnext(n);
}
else if (stringok) {
- int oldl = STR_LEN(scan);
+ const int oldl = STR_LEN(scan);
regnode *nnext = regnext(n);
if (oldl + STR_LEN(n) > U8_MAX)
*/
char *s0 = STRING(scan), *s, *t;
char *s1 = s0 + STR_LEN(scan) - 1, *s2 = s1 - 4;
- const char *t0 = "\xcc\x88\xcc\x81";
- const char *t1 = t0 + 3;
+ const char * const t0 = "\xcc\x88\xcc\x81";
+ const char * const t1 = t0 + 3;
for (s = s0 + 2;
s < s2 && (t = ninstr(s, s1, t0, t1));
/* Follow the next-chain of the current node and optimize
away all the NOTHINGs from it. */
if (OP(scan) != CURLYX) {
- int max = (reg_off_by_arg[OP(scan)]
+ const int max = (reg_off_by_arg[OP(scan)]
? I32_MAX
/* I32 may be smaller than U16 on CRAYs! */
: (I32_MAX < U16_MAX ? I32_MAX : U16_MAX));
DEBUG_OPTIMISE_r({
regprop( mysv, tail );
PerlIO_printf( Perl_debug_log, "%*s%s%s%s\n",
- (int)depth * 2 + 2, "", "Tail node is:", SvPV_nolen( mysv ),
+ (int)depth * 2 + 2, "", "Tail node is:", SvPV_nolen_const( mysv ),
(RExC_seen_evals) ? "[EVAL]" : ""
);
});
/* dont use tail as the end marker for this traverse */
for ( cur = startbranch ; cur != scan ; cur = regnext( cur ) ) {
- regnode *noper = NEXTOPER( cur );
- regnode *noper_next = regnext( noper );
+ regnode * const noper = NEXTOPER( cur );
+ regnode * const noper_next = regnext( noper );
DEBUG_OPTIMISE_r({
regprop( mysv, cur);
PerlIO_printf( Perl_debug_log, "%*s%s",
- (int)depth * 2 + 2," ", SvPV_nolen( mysv ) );
+ (int)depth * 2 + 2," ", SvPV_nolen_const( mysv ) );
regprop( mysv, noper);
PerlIO_printf( Perl_debug_log, " -> %s",
- SvPV_nolen(mysv));
+ SvPV_nolen_const(mysv));
if ( noper_next ) {
regprop( mysv, noper_next );
PerlIO_printf( Perl_debug_log,"\t=> %s\t",
- SvPV_nolen(mysv));
+ SvPV_nolen_const(mysv));
}
PerlIO_printf( Perl_debug_log, "0x%p,0x%p,0x%p)\n",
first, last, cur );
if (!last ) {
regprop( mysv, first);
PerlIO_printf( Perl_debug_log, "%*s%s",
- (int)depth * 2 + 2, "F:", SvPV_nolen( mysv ) );
+ (int)depth * 2 + 2, "F:", SvPV_nolen_const( mysv ) );
regprop( mysv, NEXTOPER(first) );
PerlIO_printf( Perl_debug_log, " -> %s\n",
- SvPV_nolen( mysv ) );
+ SvPV_nolen_const( mysv ) );
}
);
last = cur;
DEBUG_OPTIMISE_r({
regprop( mysv, cur);
PerlIO_printf( Perl_debug_log, "%*s%s",
- (int)depth * 2 + 2, "N:", SvPV_nolen( mysv ) );
+ (int)depth * 2 + 2, "N:", SvPV_nolen_const( mysv ) );
regprop( mysv, noper );
PerlIO_printf( Perl_debug_log, " -> %s\n",
- SvPV_nolen( mysv ) );
+ SvPV_nolen_const( mysv ) );
});
}
} else {
regprop( mysv, cur);
PerlIO_printf( Perl_debug_log,
"%*s%s\t(0x%p,0x%p,0x%p)\n", (int)depth * 2 + 2,
- " ", SvPV_nolen( mysv ), first, last, cur);
+ " ", SvPV_nolen_const( mysv ), first, last, cur);
});
if ( last ) {
I32 l = STR_LEN(scan);
UV uc = *((U8*)STRING(scan));
if (UTF) {
- U8 *s = (U8*)STRING(scan);
+ const U8 * const s = (U8*)STRING(scan);
l = utf8_length(s, s + l);
uc = utf8_to_uvchr(s, NULL);
}
}
sv_catpvn(data->last_found, STRING(scan), STR_LEN(scan));
{
- SV * sv = data->last_found;
- MAGIC *mg = SvUTF8(sv) && SvMAGICAL(sv) ?
+ SV * const sv = data->last_found;
+ MAGIC * const mg = SvUTF8(sv) && SvMAGICAL(sv) ?
mg_find(sv, PERL_MAGIC_utf8) : NULL;
if (mg && mg->mg_len >= 0)
mg->mg_len += utf8_length((U8*)STRING(scan),
}
if (!scan) /* It was not CURLYX, but CURLY. */
scan = next;
- if (ckWARN(WARN_REGEXP)
- /* ? quantifier ok, except for (?{ ... }) */
- && (next_is_eval || !(mincount == 0 && maxcount == 1))
+ if ( /* ? quantifier ok, except for (?{ ... }) */
+ (next_is_eval || !(mincount == 0 && maxcount == 1))
&& (minnext == 0) && (deltanext == 0)
&& data && !(data->flags & (SF_HAS_PAR|SF_IN_PAR))
- && maxcount <= REG_INFTY/3) /* Complement check for big count */
+ && maxcount <= REG_INFTY/3 /* Complement check for big count */
+ && ckWARN(WARN_REGEXP))
{
vWARN(RExC_parse,
"Quantifier unexpected on zero-length expression");
#if defined(SPARC64_GCC_WORKAROUND)
I32 b = 0;
STRLEN l = 0;
- char *s = NULL;
+ const char *s = NULL;
I32 old = 0;
if (pos_before >= data->last_start_min)
b = data->last_start_min;
l = 0;
- s = SvPV(data->last_found, l);
+ s = SvPV_const(data->last_found, l);
old = b - data->last_start_min;
#else
I32 b = pos_before >= data->last_start_min
? pos_before : data->last_start_min;
STRLEN l;
- char *s = SvPV(data->last_found, l);
+ const char *s = SvPV_const(data->last_found, l);
I32 old = b - data->last_start_min;
#endif
if (mincount > 1) {
SvGROW(last_str, (mincount * l) + 1);
repeatcpy(SvPVX(last_str) + l,
- SvPVX(last_str), l, mincount - 1);
+ SvPVX_const(last_str), l, mincount - 1);
SvCUR_set(last_str, SvCUR(last_str) * mincount);
/* Add additional parts. */
SvCUR_set(data->last_found,
if (data)
data->whilem_c = data_fake.whilem_c;
if (f & SCF_DO_STCLASS_AND) {
- int was = (data->start_class->flags & ANYOF_EOS);
+ const int was = (data->start_class->flags & ANYOF_EOS);
cl_and(data->start_class, &intrnl);
if (was)
RExC_rx->data->count += n;
}
else {
- Newc(1207, RExC_rx->data, sizeof(*RExC_rx->data) + sizeof(void*) * (n - 1),
+ Newxc(RExC_rx->data, sizeof(*RExC_rx->data) + sizeof(void*) * (n - 1),
char, struct reg_data);
- New(1208, RExC_rx->data->what, n, U8);
+ Newx(RExC_rx->data->what, n, U8);
RExC_rx->data->count = n;
}
Copy(s, RExC_rx->data->what + RExC_rx->data->count - n, n, U8);
void
Perl_reginitcolors(pTHX)
{
- int i = 0;
- char *s = PerlEnv_getenv("PERL_RE_COLORS");
-
+ const char * const s = PerlEnv_getenv("PERL_RE_COLORS");
if (s) {
- PL_colors[0] = s = savepv(s);
+ char *t = savepv(s);
+ int i = 0;
+ PL_colors[0] = t;
while (++i < 6) {
- s = strchr(s, '\t');
- if (s) {
- *s = '\0';
- PL_colors[i] = ++s;
+ t = strchr(t, '\t');
+ if (t) {
+ *t = '\0';
+ PL_colors[i] = ++t;
}
else
- PL_colors[i] = s = (char *)"";
+ PL_colors[i] = t = (char *)"";
}
} else {
+ int i = 0;
while (i < 6)
PL_colors[i++] = (char *)"";
}
RExC_whilem_seen = 15;
/* Allocate space and initialize. */
- Newc(1001, r, sizeof(regexp) + (unsigned)RExC_size * sizeof(regnode),
+ Newxc(r, sizeof(regexp) + (unsigned)RExC_size * sizeof(regnode),
char, regexp);
if (r == NULL)
FAIL("Regexp out of space");
r->prelen = xend - exp;
r->precomp = savepvn(RExC_precomp, r->prelen);
r->subbeg = NULL;
-#ifdef PERL_COPY_ON_WRITE
+#ifdef PERL_OLD_COPY_ON_WRITE
r->saved_copy = Nullsv;
#endif
r->reganch = pm->op_pmflags & PMf_COMPILETIME;
r->startp = 0; /* Useful during FAIL. */
r->endp = 0; /* Useful during FAIL. */
- Newz(1304, r->offsets, 2*RExC_size+1, U32); /* MJD 20001228 */
+ Newxz(r->offsets, 2*RExC_size+1, U32); /* MJD 20001228 */
if (r->offsets) {
r->offsets[0] = RExC_size;
}
/* XXXX To minimize changes to RE engine we always allocate
3-units-long substrs field. */
- Newz(1004, r->substrs, 1, struct reg_substr_data);
+ Newxz(r->substrs, 1, struct reg_substr_data);
StructCopy(&zero_scan_data, &data, scan_data_t);
/* XXXX Should not we check for something else? Usually it is OPEN1... */
!(r->reganch & ROPT_ANCH) )
{
/* turn .* into ^.* with an implied $*=1 */
- int type = OP(NEXTOPER(first));
-
- if (type == REG_ANY)
- type = ROPT_ANCH_MBOL;
- else
- type = ROPT_ANCH_SBOL;
-
+ const int type =
+ (OP(NEXTOPER(first)) == REG_ANY)
+ ? ROPT_ANCH_MBOL
+ : ROPT_ANCH_SBOL;
r->reganch |= type | ROPT_IMPLICIT;
first = NEXTOPER(first);
goto again;
&& !(data.start_class->flags & ANYOF_EOS)
&& !cl_is_anything(data.start_class))
{
- I32 n = add_data(pRExC_state, 1, "f");
+ const I32 n = add_data(pRExC_state, 1, "f");
- New(1006, RExC_rx->data->data[n], 1,
+ Newx(RExC_rx->data->data[n], 1,
struct regnode_charclass_class);
StructCopy(data.start_class,
(struct regnode_charclass_class*)RExC_rx->data->data[n],
DEBUG_COMPILE_r({ SV *sv = sv_newmortal();
regprop(sv, (regnode*)data.start_class);
PerlIO_printf(Perl_debug_log,
- "synthetic stclass `%s'.\n",
- SvPVX(sv));});
+ "synthetic stclass \"%s\".\n",
+ SvPVX_const(sv));});
}
/* A temporary algorithm prefers floated substr to fixed one to dig more info. */
if (!(data.start_class->flags & ANYOF_EOS)
&& !cl_is_anything(data.start_class))
{
- I32 n = add_data(pRExC_state, 1, "f");
+ const I32 n = add_data(pRExC_state, 1, "f");
- New(1006, RExC_rx->data->data[n], 1,
+ Newx(RExC_rx->data->data[n], 1,
struct regnode_charclass_class);
StructCopy(data.start_class,
(struct regnode_charclass_class*)RExC_rx->data->data[n],
DEBUG_COMPILE_r({ SV* sv = sv_newmortal();
regprop(sv, (regnode*)data.start_class);
PerlIO_printf(Perl_debug_log,
- "synthetic stclass `%s'.\n",
- SvPVX(sv));});
+ "synthetic stclass \"%s\".\n",
+ SvPVX_const(sv));});
}
}
r->reganch |= ROPT_EVAL_SEEN;
if (RExC_seen & REG_SEEN_CANY)
r->reganch |= ROPT_CANY_SEEN;
- Newz(1002, r->startp, RExC_npar, I32);
- Newz(1002, r->endp, RExC_npar, I32);
+ Newxz(r->startp, RExC_npar, I32);
+ Newxz(r->endp, RExC_npar, I32);
PL_regdata = r->data; /* for regprop() */
DEBUG_COMPILE_r(regdump(r));
return(r);
wasted_c = 0x04;
char * parse_start = RExC_parse; /* MJD */
- char *oregcomp_parse = RExC_parse;
+ char * const oregcomp_parse = RExC_parse;
char c;
*flagp = 0; /* Tentatively. */
U32 posflags = 0, negflags = 0;
U32 *flagsp = &posflags;
int logical = 0;
- char *seqstart = RExC_parse;
+ const char * const seqstart = RExC_parse;
RExC_parse++;
paren = *RExC_parse++;
register char op;
register char *next;
I32 flags;
- char *origparse = RExC_parse;
+ const char * const origparse = RExC_parse;
char *maxpos;
I32 min;
I32 max = REG_INFTY;
goto do_curly;
}
nest_check:
- if (ckWARN(WARN_REGEXP) && !SIZE_ONLY && !(flags&HASWIDTH) && max > REG_INFTY/3) {
+ if (!SIZE_ONLY && !(flags&HASWIDTH) && max > REG_INFTY/3 && ckWARN(WARN_REGEXP)) {
vWARN3(RExC_parse,
"%.*s matches null string many times",
RExC_parse - origparse,
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
{
- I32 num = atoi(RExC_parse);
+ const I32 num = atoi(RExC_parse);
if (num > 9 && num >= RExC_npar)
goto defchar;
FAIL("Trailing \\");
/* FALL THROUGH */
default:
- /* Do not generate `unrecognized' warnings here, we fall
+ /* Do not generate "unrecognized" warnings here, we fall
back into the quick-grab loop below */
parse_start--;
goto defchar;
register UV ender;
register char *p;
char *oldp, *s;
- STRLEN numlen;
STRLEN foldlen;
U8 tmpbuf[UTF8_MAXBYTES_CASE+1], *foldbuf;
break;
case 'x':
if (*++p == '{') {
- char* e = strchr(p, '}');
+ char* const e = strchr(p, '}');
if (!e) {
RExC_parse = p + 1;
else {
I32 flags = PERL_SCAN_ALLOW_UNDERSCORES
| PERL_SCAN_DISALLOW_PREFIX;
- numlen = e - p - 1;
+ STRLEN numlen = e - p - 1;
ender = grok_hex(p + 1, &numlen, &flags, NULL);
if (ender > 0xff)
RExC_utf8 = 1;
}
else {
I32 flags = PERL_SCAN_DISALLOW_PREFIX;
- numlen = 2;
+ STRLEN numlen = 2;
ender = grok_hex(p, &numlen, &flags, NULL);
p += numlen;
}
if (*p == '0' ||
(isDIGIT(p[1]) && atoi(p) >= RExC_npar) ) {
I32 flags = 0;
- numlen = 3;
+ STRLEN numlen = 3;
ender = grok_oct(p, &numlen, &flags, NULL);
p += numlen;
}
FAIL("Trailing \\");
/* FALL THROUGH */
default:
- if (!SIZE_ONLY && ckWARN(WARN_REGEXP) && isALPHA(*p))
+ if (!SIZE_ONLY&& isALPHA(*p) && ckWARN(WARN_REGEXP))
vWARN2(p + 1, "Unrecognized escape \\%c passed through", UCHARAT(p));
goto normal_default;
}
default:
normal_default:
if (UTF8_IS_START(*p) && UTF) {
+ STRLEN numlen;
ender = utf8n_to_uvchr((U8*)p, RExC_end - p,
&numlen, 0);
p += numlen;
if (FOLD) {
/* Emit all the Unicode characters. */
+ STRLEN numlen;
for (foldbuf = tmpbuf;
foldlen;
foldlen -= numlen) {
if (FOLD) {
/* Emit all the Unicode characters. */
+ STRLEN numlen;
for (foldbuf = tmpbuf;
foldlen;
foldlen -= numlen) {
if (RExC_utf8)
SvUTF8_on(sv);
if (sv_utf8_downgrade(sv, TRUE)) {
- char *s = sv_recode_to_utf8(sv, PL_encoding);
- STRLEN newlen = SvCUR(sv);
+ const char * const s = sv_recode_to_utf8(sv, PL_encoding);
+ const STRLEN newlen = SvCUR(sv);
if (SvUTF8(sv))
RExC_utf8 = 1;
}
STATIC char *
-S_regwhite(pTHX_ char *p, char *e)
+S_regwhite(pTHX_ char *p, const char *e)
{
while (p < e) {
if (isSPACE(*p))
STATIC I32
S_regpposixcc(pTHX_ RExC_state_t *pRExC_state, I32 value)
{
- char *posixcc = 0;
I32 namedclass = OOB_NAMEDCLASS;
if (value == '[' && RExC_parse + 1 < RExC_end &&
/* I smell either [: or [= or [. -- POSIX has been here, right? */
POSIXCC(UCHARAT(RExC_parse))) {
- char c = UCHARAT(RExC_parse);
+ const char c = UCHARAT(RExC_parse);
char* s = RExC_parse++;
while (RExC_parse < RExC_end && UCHARAT(RExC_parse) != c)
/* Grandfather lone [:, [=, [. */
RExC_parse = s;
else {
- char* t = RExC_parse++; /* skip over the c */
+ const char* t = RExC_parse++; /* skip over the c */
+ const char *posixcc;
assert(*t == c);
RExC_parse++; /* skip over the ending ] */
posixcc = s + 1;
if (*s == ':') {
- I32 complement = *posixcc == '^' ? *posixcc++ : 0;
- I32 skip = t - posixcc;
+ const I32 complement = *posixcc == '^' ? *posixcc++ : 0;
+ const I32 skip = t - posixcc;
/* Initially switch on the length of the name. */
switch (skip) {
S_checkposixcc(pTHX_ RExC_state_t *pRExC_state)
{
if (!SIZE_ONLY && POSIXCC(UCHARAT(RExC_parse))) {
- char *s = RExC_parse;
- char c = *s++;
+ const char *s = RExC_parse;
+ const char c = *s++;
while(*s && isALNUM(*s))
s++;
if (RExC_parse >= RExC_end)
vFAIL2("Empty \\%c{}", (U8)value);
if (*RExC_parse == '{') {
- U8 c = (U8)value;
+ const U8 c = (U8)value;
e = strchr(RExC_parse++, '}');
if (!e)
vFAIL2("Missing right brace on \\%c{}", c);
break;
}
default:
- if (!SIZE_ONLY && ckWARN(WARN_REGEXP) && isALPHA(value))
+ if (!SIZE_ONLY && isALPHA(value) && ckWARN(WARN_REGEXP))
vWARN2(RExC_parse,
"Unrecognized escape \\%c in character class passed through",
(int)value);
IV i;
if (prevvalue < 256) {
- IV ceilvalue = value < 256 ? value : 255;
+ const IV ceilvalue = value < 256 ? value : 255;
#ifdef EBCDIC
/* In EBCDIC [\x89-\x91] should include
ANYOF_BITMAP_SET(ret, i);
}
if (value > 255 || UTF) {
- UV prevnatvalue = NATIVE_TO_UNI(prevvalue);
- UV natvalue = NATIVE_TO_UNI(value);
+ const UV prevnatvalue = NATIVE_TO_UNI(prevvalue);
+ const UV natvalue = NATIVE_TO_UNI(value);
ANYOF_FLAGS(ret) |= ANYOF_UNICODE;
if (prevnatvalue < natvalue) { /* what about > ? */
if (FOLD) {
U8 foldbuf[UTF8_MAXBYTES_CASE+1];
STRLEN foldlen;
- UV f = to_uni_fold(natvalue, foldbuf, &foldlen);
+ const UV f = to_uni_fold(natvalue, foldbuf, &foldlen);
/* If folding and foldable and a single
* character, insert also the folded version
STATIC regnode * /* Location. */
S_reg_node(pTHX_ RExC_state_t *pRExC_state, U8 op)
{
- register regnode *ret;
register regnode *ptr;
+ regnode * const ret = RExC_emit;
- ret = RExC_emit;
if (SIZE_ONLY) {
SIZE_ALIGN(RExC_size);
RExC_size += 1;
STATIC regnode * /* Location. */
S_reganode(pTHX_ RExC_state_t *pRExC_state, U8 op, U32 arg)
{
- register regnode *ret;
register regnode *ptr;
+ regnode * const ret = RExC_emit;
- ret = RExC_emit;
if (SIZE_ONLY) {
SIZE_ALIGN(RExC_size);
RExC_size += 2;
- reguni - emit (if appropriate) a Unicode character
*/
STATIC void
-S_reguni(pTHX_ RExC_state_t *pRExC_state, UV uv, char* s, STRLEN* lenp)
+S_reguni(pTHX_ const RExC_state_t *pRExC_state, UV uv, char* s, STRLEN* lenp)
{
*lenp = SIZE_ONLY ? UNISKIP(uv) : (uvchr_to_utf8((U8*)s, uv) - (U8*)s);
}
register regnode *src;
register regnode *dst;
register regnode *place;
- register int offset = regarglen[(U8)op];
+ const int offset = regarglen[(U8)op];
/* (PL_regkind[(U8)op] == CURLY ? EXTRA_STEP_2ARGS : 0); */
S_regtail(pTHX_ RExC_state_t *pRExC_state, regnode *p, regnode *val)
{
register regnode *scan;
- register regnode *temp;
if (SIZE_ONLY)
return;
/* Find last node. */
scan = p;
for (;;) {
- temp = regnext(scan);
+ regnode * const temp = regnext(scan);
if (temp == NULL)
break;
scan = temp;
- regcurly - a little FSA that accepts {\d+,?\d*}
*/
STATIC I32
-S_regcurly(pTHX_ register char *s)
+S_regcurly(pTHX_ register const char *s)
{
if (*s++ != '{')
return FALSE;
}
-#ifdef DEBUGGING
-
-STATIC regnode *
-S_dumpuntil(pTHX_ regnode *start, regnode *node, regnode *last, SV* sv, I32 l)
-{
- register U8 op = EXACT; /* Arbitrary non-END op. */
- register regnode *next;
-
- while (op != END && (!last || node < last)) {
- /* While that wasn't END last time... */
-
- NODE_ALIGN(node);
- op = OP(node);
- if (op == CLOSE)
- l--;
- next = regnext(node);
- /* Where, what. */
- if (OP(node) == OPTIMIZED)
- goto after_print;
- regprop(sv, node);
- PerlIO_printf(Perl_debug_log, "%4"IVdf":%*s%s", (IV)(node - start),
- (int)(2*l + 1), "", SvPVX(sv));
- if (next == NULL) /* Next ptr. */
- PerlIO_printf(Perl_debug_log, "(0)");
- else
- PerlIO_printf(Perl_debug_log, "(%"IVdf")", (IV)(next - start));
- (void)PerlIO_putc(Perl_debug_log, '\n');
- after_print:
- if (PL_regkind[(U8)op] == BRANCHJ) {
- register regnode *nnode = (OP(next) == LONGJMP
- ? regnext(next)
- : next);
- if (last && nnode > last)
- nnode = last;
- node = dumpuntil(start, NEXTOPER(NEXTOPER(node)), nnode, sv, l + 1);
- }
- else if (PL_regkind[(U8)op] == BRANCH) {
- node = dumpuntil(start, NEXTOPER(node), next, sv, l + 1);
- }
- else if ( PL_regkind[(U8)op] == TRIE ) {
- const I32 n = ARG(node);
- const reg_trie_data *trie = (reg_trie_data*)PL_regdata->data[n];
- const I32 arry_len = av_len(trie->words)+1;
- I32 word_idx;
- PerlIO_printf(Perl_debug_log,
- "%*s[Words:%d Chars Stored:%d Unique Chars:%d States:%"IVdf"%s]\n",
- (int)(2*(l+3)), "",
- trie->wordcount,
- trie->charcount,
- trie->uniquecharcount,
- (IV)trie->laststate-1,
- node->flags ? " EVAL mode" : "");
-
- for (word_idx=0; word_idx < arry_len; word_idx++) {
- SV **elem_ptr=av_fetch(trie->words,word_idx,0);
- if (elem_ptr) {
- PerlIO_printf(Perl_debug_log, "%*s<%s%s%s>\n",
- (int)(2*(l+4)), "",
- PL_colors[0],
- SvPV_nolen(*elem_ptr),
- PL_colors[1]
- );
- /*
- if (next == NULL)
- PerlIO_printf(Perl_debug_log, "(0)\n");
- else
- PerlIO_printf(Perl_debug_log, "(%"IVdf")\n", (IV)(next - start));
- */
- }
-
- }
-
- node = NEXTOPER(node);
- node += regarglen[(U8)op];
-
- }
- else if ( op == CURLY) { /* `next' might be very big: optimizer */
- node = dumpuntil(start, NEXTOPER(node) + EXTRA_STEP_2ARGS,
- NEXTOPER(node) + EXTRA_STEP_2ARGS + 1, sv, l + 1);
- }
- else if (PL_regkind[(U8)op] == CURLY && op != CURLYX) {
- node = dumpuntil(start, NEXTOPER(node) + EXTRA_STEP_2ARGS,
- next, sv, l + 1);
- }
- else if ( op == PLUS || op == STAR) {
- node = dumpuntil(start, NEXTOPER(node), NEXTOPER(node) + 1, sv, l + 1);
- }
- else if (op == ANYOF) {
- /* arglen 1 + class block */
- node += 1 + ((ANYOF_FLAGS(node) & ANYOF_LARGE)
- ? ANYOF_CLASS_SKIP : ANYOF_SKIP);
- node = NEXTOPER(node);
- }
- else if (PL_regkind[(U8)op] == EXACT) {
- /* Literal string, where present. */
- node += NODE_SZ_STR(node) - 1;
- node = NEXTOPER(node);
- }
- else {
- node = NEXTOPER(node);
- node += regarglen[(U8)op];
- }
- if (op == CURLYX || op == OPEN)
- l++;
- else if (op == WHILEM)
- l--;
- }
- return node;
-}
-
-#endif /* DEBUGGING */
-
/*
- regdump - dump a regexp onto Perl_debug_log in vaguely comprehensible form
*/
/* Header fields of interest. */
if (r->anchored_substr)
PerlIO_printf(Perl_debug_log,
- "anchored `%s%.*s%s'%s at %"IVdf" ",
+ "anchored \"%s%.*s%s\"%s at %"IVdf" ",
PL_colors[0],
(int)(SvCUR(r->anchored_substr) - (SvTAIL(r->anchored_substr)!=0)),
- SvPVX(r->anchored_substr),
+ SvPVX_const(r->anchored_substr),
PL_colors[1],
SvTAIL(r->anchored_substr) ? "$" : "",
(IV)r->anchored_offset);
else if (r->anchored_utf8)
PerlIO_printf(Perl_debug_log,
- "anchored utf8 `%s%.*s%s'%s at %"IVdf" ",
+ "anchored utf8 \"%s%.*s%s\"%s at %"IVdf" ",
PL_colors[0],
(int)(SvCUR(r->anchored_utf8) - (SvTAIL(r->anchored_utf8)!=0)),
- SvPVX(r->anchored_utf8),
+ SvPVX_const(r->anchored_utf8),
PL_colors[1],
SvTAIL(r->anchored_utf8) ? "$" : "",
(IV)r->anchored_offset);
if (r->float_substr)
PerlIO_printf(Perl_debug_log,
- "floating `%s%.*s%s'%s at %"IVdf"..%"UVuf" ",
+ "floating \"%s%.*s%s\"%s at %"IVdf"..%"UVuf" ",
PL_colors[0],
(int)(SvCUR(r->float_substr) - (SvTAIL(r->float_substr)!=0)),
- SvPVX(r->float_substr),
+ SvPVX_const(r->float_substr),
PL_colors[1],
SvTAIL(r->float_substr) ? "$" : "",
(IV)r->float_min_offset, (UV)r->float_max_offset);
else if (r->float_utf8)
PerlIO_printf(Perl_debug_log,
- "floating utf8 `%s%.*s%s'%s at %"IVdf"..%"UVuf" ",
+ "floating utf8 \"%s%.*s%s\"%s at %"IVdf"..%"UVuf" ",
PL_colors[0],
(int)(SvCUR(r->float_utf8) - (SvTAIL(r->float_utf8)!=0)),
- SvPVX(r->float_utf8),
+ SvPVX_const(r->float_utf8),
PL_colors[1],
SvTAIL(r->float_utf8) ? "$" : "",
(IV)r->float_min_offset, (UV)r->float_max_offset);
if (r->regstclass) {
regprop(sv, r->regstclass);
- PerlIO_printf(Perl_debug_log, "stclass `%s' ", SvPVX(sv));
+ PerlIO_printf(Perl_debug_log, "stclass \"%s\" ", SvPVX_const(sv));
}
if (r->reganch & ROPT_ANCH) {
PerlIO_printf(Perl_debug_log, "anchored");
PerlIO_printf(Perl_debug_log, "with eval ");
PerlIO_printf(Perl_debug_log, "\n");
if (r->offsets) {
- U32 i;
const U32 len = r->offsets[0];
GET_RE_DEBUG_FLAGS_DECL;
DEBUG_OFFSETS_r({
+ U32 i;
PerlIO_printf(Perl_debug_log, "Offsets: [%"UVuf"]\n\t", (UV)r->offsets[0]);
for (i = 1; i <= len; i++)
PerlIO_printf(Perl_debug_log, "%"UVuf"[%"UVuf"] ",
#endif /* DEBUGGING */
}
-#ifdef DEBUGGING
-
-STATIC void
-S_put_byte(pTHX_ SV *sv, int c)
-{
- if (isCNTRL(c) || c == 255 || !isPRINT(c))
- Perl_sv_catpvf(aTHX_ sv, "\\%o", c);
- else if (c == '-' || c == ']' || c == '\\' || c == '^')
- Perl_sv_catpvf(aTHX_ sv, "\\%c", c);
- else
- Perl_sv_catpvf(aTHX_ sv, "%c", c);
-}
-
-#endif /* DEBUGGING */
-
-
/*
- regprop - printable representation of opcode
*/
void
-Perl_regprop(pTHX_ SV *sv, regnode *o)
+Perl_regprop(pTHX_ SV *sv, const regnode *o)
{
#ifdef DEBUGGING
register int k;
/* Using is_utf8_string() is a crude hack but it may
* be the best for now since we have no flag "this EXACTish
* node was UTF-8" --jhi */
- bool do_utf8 = is_utf8_string((U8*)STRING(o), STR_LEN(o));
- char *s = do_utf8 ?
+ const bool do_utf8 = is_utf8_string((U8*)STRING(o), STR_LEN(o));
+ const char *s = do_utf8 ?
pv_uni_display(dsv, (U8*)STRING(o), STR_LEN(o), 60,
UNI_DISPLAY_REGEX) :
STRING(o);
U8 s[UTF8_MAXBYTES_CASE+1];
for (i = 0; i <= 256; i++) { /* just the first 256 */
- U8 *e = uvchr_to_utf8(s, i);
+ uvchr_to_utf8(s, i);
if (i < 256 && swash_fetch(sw, s, TRUE)) {
if (rangestart == -1)
if (i <= rangestart + 3)
for (; rangestart < i; rangestart++) {
+ U8 *e;
for(e = uvchr_to_utf8(s, rangestart), p = s; p < e; p++)
put_byte(sv, *p);
}
else {
+ U8 *e;
for (e = uvchr_to_utf8(s, rangestart), p = s; p < e; p++)
put_byte(sv, *p);
sv_catpv(sv, "-");
- for (e = uvchr_to_utf8(s, i - 1), p = s; p < e; p++)
- put_byte(sv, *p);
+ for (e = uvchr_to_utf8(s, i - 1), p = s; p < e; p++)
+ put_byte(sv, *p);
}
rangestart = -1;
}
while(*s && *s != '\n') s++;
if (*s == '\n') {
- char *t = ++s;
+ const char *t = ++s;
while (*s) {
if (*s == '\n')
{ /* Assume that RE_INTUIT is set */
GET_RE_DEBUG_FLAGS_DECL;
DEBUG_COMPILE_r(
- { STRLEN n_a;
- char *s = SvPV(prog->check_substr
- ? prog->check_substr : prog->check_utf8, n_a);
+ {
+ const char *s = SvPV_nolen_const(prog->check_substr
+ ? prog->check_substr : prog->check_utf8);
if (!PL_colorset) reginitcolors();
PerlIO_printf(Perl_debug_log,
- "%sUsing REx %ssubstr:%s `%s%.60s%s%s'\n",
+ "%sUsing REx %ssubstr:%s \"%s%.60s%s%s\"\n",
PL_colors[4],
prog->check_substr ? "" : "utf8 ",
PL_colors[5],PL_colors[0],
len > 60 ? "..." : "");
});
- if (r->precomp)
- Safefree(r->precomp);
- if (r->offsets) /* 20010421 MJD */
- Safefree(r->offsets);
+ /* gcov results gave these as non-null 100% of the time, so there's no
+ optimisation in checking them before calling Safefree */
+ Safefree(r->precomp);
+ Safefree(r->offsets); /* 20010421 MJD */
RX_MATCH_COPY_FREE(r);
-#ifdef PERL_COPY_ON_WRITE
+#ifdef PERL_OLD_COPY_ON_WRITE
if (r->saved_copy)
SvREFCNT_dec(r->saved_copy);
#endif
refcount = trie->refcount--;
OP_REFCNT_UNLOCK;
if ( !refcount ) {
- if (trie->charmap)
- Safefree(trie->charmap);
+ Safefree(trie->charmap);
if (trie->widecharmap)
SvREFCNT_dec((SV*)trie->widecharmap);
- if (trie->states)
- Safefree(trie->states);
- if (trie->trans)
- Safefree(trie->trans);
+ Safefree(trie->states);
+ Safefree(trie->trans);
#ifdef DEBUGGING
if (trie->words)
SvREFCNT_dec((SV*)trie->words);
#endif
msv = vmess(buf, &args);
va_end(args);
- message = SvPV(msv,l1);
+ message = SvPV_const(msv,l1);
if (l1 > 512)
l1 = 512;
Copy(message, buf, l1 , char);
PL_reg_oldsaved = Nullch;
SAVEI32(PL_reg_oldsavedlen); /* old length of saved substr during match */
PL_reg_oldsavedlen = 0;
-#ifdef PERL_COPY_ON_WRITE
+#ifdef PERL_OLD_COPY_ON_WRITE
SAVESPTR(PL_nrs);
PL_nrs = Nullsv;
#endif
{
/* Save $1..$n (#18107: UTF-8 s/(\w+)/uc($1)/e); AMS 20021106. */
- U32 i;
- GV *mgv;
REGEXP *rx;
- char digits[TYPE_CHARS(long)];
if (PL_curpm && (rx = PM_GETRE(PL_curpm))) {
+ U32 i;
for (i = 1; i <= rx->nparens; i++) {
+ GV *mgv;
+ char digits[TYPE_CHARS(long)];
sprintf(digits, "%lu", (long)i);
if ((mgv = gv_fetchpv(digits, FALSE, SVt_PV)))
save_scalar(mgv);
ReREFCNT_dec((regexp *)r);
}
+#ifdef DEBUGGING
+
+STATIC void
+S_put_byte(pTHX_ SV *sv, int c)
+{
+ if (isCNTRL(c) || c == 255 || !isPRINT(c))
+ Perl_sv_catpvf(aTHX_ sv, "\\%o", c);
+ else if (c == '-' || c == ']' || c == '\\' || c == '^')
+ Perl_sv_catpvf(aTHX_ sv, "\\%c", c);
+ else
+ Perl_sv_catpvf(aTHX_ sv, "%c", c);
+}
+
+
+STATIC regnode *
+S_dumpuntil(pTHX_ regnode *start, regnode *node, regnode *last, SV* sv, I32 l)
+{
+ register U8 op = EXACT; /* Arbitrary non-END op. */
+ register regnode *next;
+
+ while (op != END && (!last || node < last)) {
+ /* While that wasn't END last time... */
+
+ NODE_ALIGN(node);
+ op = OP(node);
+ if (op == CLOSE)
+ l--;
+ next = regnext(node);
+ /* Where, what. */
+ if (OP(node) == OPTIMIZED)
+ goto after_print;
+ regprop(sv, node);
+ PerlIO_printf(Perl_debug_log, "%4"IVdf":%*s%s", (IV)(node - start),
+ (int)(2*l + 1), "", SvPVX_const(sv));
+ if (next == NULL) /* Next ptr. */
+ PerlIO_printf(Perl_debug_log, "(0)");
+ else
+ PerlIO_printf(Perl_debug_log, "(%"IVdf")", (IV)(next - start));
+ (void)PerlIO_putc(Perl_debug_log, '\n');
+ after_print:
+ if (PL_regkind[(U8)op] == BRANCHJ) {
+ register regnode *nnode = (OP(next) == LONGJMP
+ ? regnext(next)
+ : next);
+ if (last && nnode > last)
+ nnode = last;
+ node = dumpuntil(start, NEXTOPER(NEXTOPER(node)), nnode, sv, l + 1);
+ }
+ else if (PL_regkind[(U8)op] == BRANCH) {
+ node = dumpuntil(start, NEXTOPER(node), next, sv, l + 1);
+ }
+ else if ( PL_regkind[(U8)op] == TRIE ) {
+ const I32 n = ARG(node);
+ const reg_trie_data * const trie = (reg_trie_data*)PL_regdata->data[n];
+ const I32 arry_len = av_len(trie->words)+1;
+ I32 word_idx;
+ PerlIO_printf(Perl_debug_log,
+ "%*s[Words:%d Chars Stored:%d Unique Chars:%d States:%"IVdf"%s]\n",
+ (int)(2*(l+3)),
+ "",
+ trie->wordcount,
+ (int)trie->charcount,
+ trie->uniquecharcount,
+ (IV)trie->laststate-1,
+ node->flags ? " EVAL mode" : "");
+
+ for (word_idx=0; word_idx < arry_len; word_idx++) {
+ SV **elem_ptr=av_fetch(trie->words,word_idx,0);
+ if (elem_ptr) {
+ PerlIO_printf(Perl_debug_log, "%*s<%s%s%s>\n",
+ (int)(2*(l+4)), "",
+ PL_colors[0],
+ SvPV_nolen_const(*elem_ptr),
+ PL_colors[1]
+ );
+ /*
+ if (next == NULL)
+ PerlIO_printf(Perl_debug_log, "(0)\n");
+ else
+ PerlIO_printf(Perl_debug_log, "(%"IVdf")\n", (IV)(next - start));
+ */
+ }
+
+ }
+
+ node = NEXTOPER(node);
+ node += regarglen[(U8)op];
+
+ }
+ else if ( op == CURLY) { /* "next" might be very big: optimizer */
+ node = dumpuntil(start, NEXTOPER(node) + EXTRA_STEP_2ARGS,
+ NEXTOPER(node) + EXTRA_STEP_2ARGS + 1, sv, l + 1);
+ }
+ else if (PL_regkind[(U8)op] == CURLY && op != CURLYX) {
+ node = dumpuntil(start, NEXTOPER(node) + EXTRA_STEP_2ARGS,
+ next, sv, l + 1);
+ }
+ else if ( op == PLUS || op == STAR) {
+ node = dumpuntil(start, NEXTOPER(node), NEXTOPER(node) + 1, sv, l + 1);
+ }
+ else if (op == ANYOF) {
+ /* arglen 1 + class block */
+ node += 1 + ((ANYOF_FLAGS(node) & ANYOF_LARGE)
+ ? ANYOF_CLASS_SKIP : ANYOF_SKIP);
+ node = NEXTOPER(node);
+ }
+ else if (PL_regkind[(U8)op] == EXACT) {
+ /* Literal string, where present. */
+ node += NODE_SZ_STR(node) - 1;
+ node = NEXTOPER(node);
+ }
+ else {
+ node = NEXTOPER(node);
+ node += regarglen[(U8)op];
+ }
+ if (op == CURLYX || op == OPEN)
+ l++;
+ else if (op == WHILEM)
+ l--;
+ }
+ return node;
+}
+
+#endif /* DEBUGGING */
+
/*
* Local variables:
* c-indentation-style: bsd
* indent-tabs-mode: t
* End:
*
- * vim: shiftwidth=4:
-*/
+ * ex: set ts=8 sts=4 sw=4 noet:
+ */