nwc10+ (Nicholas Clark)
2007-03-03 12:30:03 UTC
Change 30451 by ***@nicholas-saigo on 2007/03/03 12:22:19
Define and initialise reg_name only once.
This allows re to be a static extension.
As it's now no-longer a static variable in regcomp.c, it needs a PL_
prefix.
Affected files ...
... //depot/perl/regcomp.c#563 edit
... //depot/perl/regcomp.pl#18 edit
... //depot/perl/regexec.c#520 edit
... //depot/perl/regnodes.h#39 edit
Differences ...
==== //depot/perl/regcomp.c#563 (text) ====
Index: perl/regcomp.c
--- perl/regcomp.c#562~30424~ 2007-02-28 00:54:05.000000000 -0800
+++ perl/regcomp.c 2007-03-03 04:22:19.000000000 -0800
@@ -7900,7 +7900,7 @@
if (RExC_offsets) { /* MJD */
MJD_OFFSET_DEBUG(("%s:%d: (op %s) %s %"UVuf" (len %"UVuf") (max %"UVuf").\n",
"reg_node", __LINE__,
- reg_name[op],
+ PL_reg_name[op],
(UV)(RExC_emit - RExC_emit_start) > RExC_offsets[0]
? "Overwriting end of array!\n" : "OK",
(UV)(RExC_emit - RExC_emit_start),
@@ -7954,7 +7954,7 @@
MJD_OFFSET_DEBUG(("%s(%d): (op %s) %s %"UVuf" <- %"UVuf" (max %"UVuf").\n",
"reganode",
__LINE__,
- reg_name[op],
+ PL_reg_name[op],
(UV)(RExC_emit - RExC_emit_start) > RExC_offsets[0] ?
"Overwriting end of array!\n" : "OK",
(UV)(RExC_emit - RExC_emit_start),
@@ -7994,7 +7994,7 @@
GET_RE_DEBUG_FLAGS_DECL;
PERL_UNUSED_ARG(depth);
/* (PL_regkind[(U8)op] == CURLY ? EXTRA_STEP_2ARGS : 0); */
- DEBUG_PARSE_FMT("inst"," - %s",reg_name[op]);
+ DEBUG_PARSE_FMT("inst"," - %s",PL_reg_name[op]);
if (SIZE_ONLY) {
RExC_size += size;
return;
@@ -8029,7 +8029,7 @@
MJD_OFFSET_DEBUG(("%s(%d): (op %s) %s copy %"UVuf" -> %"UVuf" (max %"UVuf").\n",
"reg_insert",
__LINE__,
- reg_name[op],
+ PL_reg_name[op],
(UV)(dst - RExC_emit_start) > RExC_offsets[0]
? "Overwriting end of array!\n" : "OK",
(UV)(src - RExC_emit_start),
@@ -8048,7 +8048,7 @@
MJD_OFFSET_DEBUG(("%s(%d): (op %s) %s %"UVuf" <- %"UVuf" (max %"UVuf").\n",
"reginsert",
__LINE__,
- reg_name[op],
+ PL_reg_name[op],
(UV)(place - RExC_emit_start) > RExC_offsets[0]
? "Overwriting end of array!\n" : "OK",
(UV)(place - RExC_emit_start),
@@ -8092,7 +8092,7 @@
PerlIO_printf(Perl_debug_log, "~ %s (%d) %s %s\n",
SvPV_nolen_const(mysv), REG_NODE_NUM(scan),
(temp == NULL ? "->" : ""),
- (temp == NULL ? reg_name[OP(val)] : "")
+ (temp == NULL ? PL_reg_name[OP(val)] : "")
);
});
if (temp == NULL)
@@ -8173,7 +8173,7 @@
PerlIO_printf(Perl_debug_log, "~ %s (%d) -> %s\n",
SvPV_nolen_const(mysv),
REG_NODE_NUM(scan),
- reg_name[exact]);
+ PL_reg_name[exact]);
});
if (temp == NULL)
break;
@@ -8331,7 +8331,7 @@
/* It would be nice to FAIL() here, but this may be called from
regexec.c, and it would be hard to supply pRExC_state. */
Perl_croak(aTHX_ "Corrupted regexp opcode %d > %d", (int)OP(o), (int)REGNODE_MAX);
- sv_catpv(sv, reg_name[OP(o)]); /* Take off const! */
+ sv_catpv(sv, PL_reg_name[OP(o)]); /* Take off const! */
k = PL_regkind[OP(o)];
@@ -8360,7 +8360,7 @@
const reg_trie_data * const trie
= (reg_trie_data*)progi->data->data[!IS_TRIE_AC(op) ? n : ac->trie];
- Perl_sv_catpvf(aTHX_ sv, "-%s",reg_name[o->flags]);
+ Perl_sv_catpvf(aTHX_ sv, "-%s",PL_reg_name[o->flags]);
DEBUG_TRIE_COMPILE_r(
Perl_sv_catpvf(aTHX_ sv,
"<S:%"UVuf"/%"IVdf" W:%"UVuf" L:%"UVuf"/%"UVuf" C:%"UVuf"/%"UVuf">",
==== //depot/perl/regcomp.pl#18 (text) ====
Index: perl/regcomp.pl
--- perl/regcomp.pl#17~29260~ 2006-11-13 06:00:41.000000000 -0800
+++ perl/regcomp.pl 2007-03-03 04:22:19.000000000 -0800
@@ -157,10 +157,15 @@
print OUT <<EOP;
};
+#endif /* REG_COMP_C */
+
/* reg_name[] - Opcode/state names in string form, for debugging */
#ifdef DEBUGGING
-const char * reg_name[] = {
+# ifndef DOINIT
+EXTCONST char * PL_reg_name[];
+# else
+EXTCONST char * PL_reg_name[] = {
EOP
$ind = 0;
@@ -181,12 +186,8 @@
print OUT <<EOP;
};
+# endif /* DOINIT */
#endif /* DEBUGGING */
-#else
-#ifdef DEBUGGING
-extern const char * reg_name[];
-#endif
-#endif /* REG_COMP_C */
/* ex: set ro: */
EOP
==== //depot/perl/regexec.c#520 (text) ====
Index: perl/regexec.c
--- perl/regexec.c#519~30436~ 2007-03-01 02:54:09.000000000 -0800
+++ perl/regexec.c 2007-03-03 04:22:19.000000000 -0800
@@ -2485,7 +2485,7 @@
PerlIO_printf(Perl_debug_log, \
" %*s"pp" %s%s%s%s%s\n", \
depth*2, "", \
- reg_name[st->resume_state], \
+ PL_reg_name[st->resume_state], \
((st==yes_state||st==mark_state) ? "[" : ""), \
((st==yes_state) ? "Y" : ""), \
((st==mark_state) ? "M" : ""), \
@@ -5008,7 +5008,7 @@
}
PerlIO_printf(Perl_error_log, "%*s#%-3d %-10s %s\n",
REPORT_CODE_OFF + 2 + depth * 2,"",
- curd, reg_name[cur->resume_state],
+ curd, PL_reg_name[cur->resume_state],
(curyes == cur) ? "yes" : ""
);
if (curyes == cur)
==== //depot/perl/regnodes.h#39 (text+w) ====
Index: perl/regnodes.h
--- perl/regnodes.h#38~29756~ 2007-01-11 06:47:01.000000000 -0800
+++ perl/regnodes.h 2007-03-03 04:22:19.000000000 -0800
@@ -452,10 +452,15 @@
0, /* PSEUDO */
};
+#endif /* REG_COMP_C */
+
/* reg_name[] - Opcode/state names in string form, for debugging */
#ifdef DEBUGGING
-const char * reg_name[] = {
+# ifndef DOINIT
+EXTCONST char * PL_reg_name[];
+# else
+EXTCONST char * PL_reg_name[] = {
"END", /* 0000 */
"SUCCEED", /* 0x01 */
"BOL", /* 0x02 */
@@ -583,11 +588,7 @@
"KEEPS_next", /* REGNODE_MAX +0x27 */
"KEEPS_next_fail", /* REGNODE_MAX +0x28 */
};
+# endif /* DOINIT */
#endif /* DEBUGGING */
-#else
-#ifdef DEBUGGING
-extern const char * reg_name[];
-#endif
-#endif /* REG_COMP_C */
/* ex: set ro: */
End of Patch.
Define and initialise reg_name only once.
This allows re to be a static extension.
As it's now no-longer a static variable in regcomp.c, it needs a PL_
prefix.
Affected files ...
... //depot/perl/regcomp.c#563 edit
... //depot/perl/regcomp.pl#18 edit
... //depot/perl/regexec.c#520 edit
... //depot/perl/regnodes.h#39 edit
Differences ...
==== //depot/perl/regcomp.c#563 (text) ====
Index: perl/regcomp.c
--- perl/regcomp.c#562~30424~ 2007-02-28 00:54:05.000000000 -0800
+++ perl/regcomp.c 2007-03-03 04:22:19.000000000 -0800
@@ -7900,7 +7900,7 @@
if (RExC_offsets) { /* MJD */
MJD_OFFSET_DEBUG(("%s:%d: (op %s) %s %"UVuf" (len %"UVuf") (max %"UVuf").\n",
"reg_node", __LINE__,
- reg_name[op],
+ PL_reg_name[op],
(UV)(RExC_emit - RExC_emit_start) > RExC_offsets[0]
? "Overwriting end of array!\n" : "OK",
(UV)(RExC_emit - RExC_emit_start),
@@ -7954,7 +7954,7 @@
MJD_OFFSET_DEBUG(("%s(%d): (op %s) %s %"UVuf" <- %"UVuf" (max %"UVuf").\n",
"reganode",
__LINE__,
- reg_name[op],
+ PL_reg_name[op],
(UV)(RExC_emit - RExC_emit_start) > RExC_offsets[0] ?
"Overwriting end of array!\n" : "OK",
(UV)(RExC_emit - RExC_emit_start),
@@ -7994,7 +7994,7 @@
GET_RE_DEBUG_FLAGS_DECL;
PERL_UNUSED_ARG(depth);
/* (PL_regkind[(U8)op] == CURLY ? EXTRA_STEP_2ARGS : 0); */
- DEBUG_PARSE_FMT("inst"," - %s",reg_name[op]);
+ DEBUG_PARSE_FMT("inst"," - %s",PL_reg_name[op]);
if (SIZE_ONLY) {
RExC_size += size;
return;
@@ -8029,7 +8029,7 @@
MJD_OFFSET_DEBUG(("%s(%d): (op %s) %s copy %"UVuf" -> %"UVuf" (max %"UVuf").\n",
"reg_insert",
__LINE__,
- reg_name[op],
+ PL_reg_name[op],
(UV)(dst - RExC_emit_start) > RExC_offsets[0]
? "Overwriting end of array!\n" : "OK",
(UV)(src - RExC_emit_start),
@@ -8048,7 +8048,7 @@
MJD_OFFSET_DEBUG(("%s(%d): (op %s) %s %"UVuf" <- %"UVuf" (max %"UVuf").\n",
"reginsert",
__LINE__,
- reg_name[op],
+ PL_reg_name[op],
(UV)(place - RExC_emit_start) > RExC_offsets[0]
? "Overwriting end of array!\n" : "OK",
(UV)(place - RExC_emit_start),
@@ -8092,7 +8092,7 @@
PerlIO_printf(Perl_debug_log, "~ %s (%d) %s %s\n",
SvPV_nolen_const(mysv), REG_NODE_NUM(scan),
(temp == NULL ? "->" : ""),
- (temp == NULL ? reg_name[OP(val)] : "")
+ (temp == NULL ? PL_reg_name[OP(val)] : "")
);
});
if (temp == NULL)
@@ -8173,7 +8173,7 @@
PerlIO_printf(Perl_debug_log, "~ %s (%d) -> %s\n",
SvPV_nolen_const(mysv),
REG_NODE_NUM(scan),
- reg_name[exact]);
+ PL_reg_name[exact]);
});
if (temp == NULL)
break;
@@ -8331,7 +8331,7 @@
/* It would be nice to FAIL() here, but this may be called from
regexec.c, and it would be hard to supply pRExC_state. */
Perl_croak(aTHX_ "Corrupted regexp opcode %d > %d", (int)OP(o), (int)REGNODE_MAX);
- sv_catpv(sv, reg_name[OP(o)]); /* Take off const! */
+ sv_catpv(sv, PL_reg_name[OP(o)]); /* Take off const! */
k = PL_regkind[OP(o)];
@@ -8360,7 +8360,7 @@
const reg_trie_data * const trie
= (reg_trie_data*)progi->data->data[!IS_TRIE_AC(op) ? n : ac->trie];
- Perl_sv_catpvf(aTHX_ sv, "-%s",reg_name[o->flags]);
+ Perl_sv_catpvf(aTHX_ sv, "-%s",PL_reg_name[o->flags]);
DEBUG_TRIE_COMPILE_r(
Perl_sv_catpvf(aTHX_ sv,
"<S:%"UVuf"/%"IVdf" W:%"UVuf" L:%"UVuf"/%"UVuf" C:%"UVuf"/%"UVuf">",
==== //depot/perl/regcomp.pl#18 (text) ====
Index: perl/regcomp.pl
--- perl/regcomp.pl#17~29260~ 2006-11-13 06:00:41.000000000 -0800
+++ perl/regcomp.pl 2007-03-03 04:22:19.000000000 -0800
@@ -157,10 +157,15 @@
print OUT <<EOP;
};
+#endif /* REG_COMP_C */
+
/* reg_name[] - Opcode/state names in string form, for debugging */
#ifdef DEBUGGING
-const char * reg_name[] = {
+# ifndef DOINIT
+EXTCONST char * PL_reg_name[];
+# else
+EXTCONST char * PL_reg_name[] = {
EOP
$ind = 0;
@@ -181,12 +186,8 @@
print OUT <<EOP;
};
+# endif /* DOINIT */
#endif /* DEBUGGING */
-#else
-#ifdef DEBUGGING
-extern const char * reg_name[];
-#endif
-#endif /* REG_COMP_C */
/* ex: set ro: */
EOP
==== //depot/perl/regexec.c#520 (text) ====
Index: perl/regexec.c
--- perl/regexec.c#519~30436~ 2007-03-01 02:54:09.000000000 -0800
+++ perl/regexec.c 2007-03-03 04:22:19.000000000 -0800
@@ -2485,7 +2485,7 @@
PerlIO_printf(Perl_debug_log, \
" %*s"pp" %s%s%s%s%s\n", \
depth*2, "", \
- reg_name[st->resume_state], \
+ PL_reg_name[st->resume_state], \
((st==yes_state||st==mark_state) ? "[" : ""), \
((st==yes_state) ? "Y" : ""), \
((st==mark_state) ? "M" : ""), \
@@ -5008,7 +5008,7 @@
}
PerlIO_printf(Perl_error_log, "%*s#%-3d %-10s %s\n",
REPORT_CODE_OFF + 2 + depth * 2,"",
- curd, reg_name[cur->resume_state],
+ curd, PL_reg_name[cur->resume_state],
(curyes == cur) ? "yes" : ""
);
if (curyes == cur)
==== //depot/perl/regnodes.h#39 (text+w) ====
Index: perl/regnodes.h
--- perl/regnodes.h#38~29756~ 2007-01-11 06:47:01.000000000 -0800
+++ perl/regnodes.h 2007-03-03 04:22:19.000000000 -0800
@@ -452,10 +452,15 @@
0, /* PSEUDO */
};
+#endif /* REG_COMP_C */
+
/* reg_name[] - Opcode/state names in string form, for debugging */
#ifdef DEBUGGING
-const char * reg_name[] = {
+# ifndef DOINIT
+EXTCONST char * PL_reg_name[];
+# else
+EXTCONST char * PL_reg_name[] = {
"END", /* 0000 */
"SUCCEED", /* 0x01 */
"BOL", /* 0x02 */
@@ -583,11 +588,7 @@
"KEEPS_next", /* REGNODE_MAX +0x27 */
"KEEPS_next_fail", /* REGNODE_MAX +0x28 */
};
+# endif /* DOINIT */
#endif /* DEBUGGING */
-#else
-#ifdef DEBUGGING
-extern const char * reg_name[];
-#endif
-#endif /* REG_COMP_C */
/* ex: set ro: */
End of Patch.