Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cflags.SH
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,20 @@ Intel*) ;; # # Is that you, Intel C++?
# NOTE 3: the relative order of these options matters:
# -Wextra before -Wno-long-long -Wno-declaration-after-statement
#
# NOTE 4: If a function has __attribute__nonnull__(n), gcc generates many
# warnings for macros that have the generality to check for NULLness on
# parameter n. We could write versions of those macros that eliminate
# that check, but why?. It complicates our code and gains no
# perceptible performance except in very hot code that the compiler
# has chosen to not optimize away. So turn these off with
# -Wno-nonnull-compare

*) warns="$pedantic \
-Werror=pointer-arith \
-Werror=vla \
-Wextra \
-Wno-long-long -Wno-declaration-after-statement \
-Wno-nonnull-compare \
-Wc++-compat -Wwrite-strings"
case " $ccflags " in
*" -std="*) ;; # Already have -std=...
Expand Down
9 changes: 5 additions & 4 deletions dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,18 +990,19 @@ S_do_pmop_dump_bar(pTHX_ I32 level, UV bar, PerlIO *file, const PMOP *pm,
S_opdump_indent(aTHX_ (OP*)pm, level, bar, file,
"PMOFFSET = %" IVdf "\n", (IV)pm->op_pmoffset);
#endif
REGEXP * re = PM_GETRE(pm);
S_opdump_indent(aTHX_ (OP*)pm, level, bar, file,
"REGEX = 0x%" UVxf "\n", PTR2UV(PM_GETRE(pm)));
"REGEX = 0x%" UVxf "\n", PTR2UV(re));

if (PM_GETRE(pm)) {
if (re) {
char ch = (pm->op_pmflags & PMf_ONCE) ? '?' : '/';
S_opdump_indent(aTHX_ (OP*)pm, level, bar, file, "PMf_PRE %c%.*s%c\n",
ch,(int)RX_PRELEN(PM_GETRE(pm)), RX_PRECOMP(PM_GETRE(pm)), ch);
ch,(int)RX_PRELEN(re), RX_PRECOMP(re), ch);
}
else
S_opdump_indent(aTHX_ (OP*)pm, level, bar, file, "PMf_PRE (RUNTIME)\n");

if (pm->op_pmflags || PM_GETRE(pm)) {
if (pm->op_pmflags || re) {
SV * const tmpsv = pm_description(pm);
S_opdump_indent(aTHX_ (OP*)pm, level, bar, file, "PMFLAGS = (%s)\n",
SvCUR(tmpsv) ? SvPVX_const(tmpsv) + 1 : "");
Expand Down
12 changes: 7 additions & 5 deletions op.c
Original file line number Diff line number Diff line change
Expand Up @@ -8035,11 +8035,13 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, OP *repl, UV flags, I32 floor)
konst = TRUE;
}
else konst = FALSE;
if (konst
&& !(repl_has_vars
&& (!PM_GETRE(pm)
|| !RX_PRELEN(PM_GETRE(pm))
|| RX_EXTFLAGS(PM_GETRE(pm)) & RXf_EVAL_SEEN)))

REGEXP * re;
if ( konst
&& ! ( repl_has_vars
&& ( ! (re = PM_GETRE(pm))
|| ! RX_PRELEN(re)
|| (RX_EXTFLAGS(re) & RXf_EVAL_SEEN))))
{
pm->op_pmflags |= PMf_CONST; /* const for long enough */
op_prepend_elem(o->op_type, scalar(repl), o);
Expand Down
21 changes: 11 additions & 10 deletions op.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,12 @@ struct pmop {
* processing or asserts */
#ifdef USE_ITHREADS
#define PM_GETRE_raw(o) (REGEXP*)(PL_regex_pad[(o)->op_pmoffset])
#define PM_GETRE(o) (SvTYPE(PL_regex_pad[(o)->op_pmoffset]) == SVt_REGEXP \
? (REGEXP*)(PL_regex_pad[(o)->op_pmoffset]) : NULL)
#define PM_GETRE(o) (SvTYPE(PM_GETRE_raw(o)) == SVt_REGEXP \
? PM_GETRE_raw(o) : NULL)

#define PM_SETRE_raw(o,r) STMT_START { \
PL_regex_pad[(o)->op_pmoffset] = MUTABLE_SV(r); \
} STMT_END
#define PM_SETRE_raw(o,r) STMT_START { \
PL_regex_pad[(o)->op_pmoffset] = MUTABLE_SV(r);\
} STMT_END
/* The assignment is just to enforce type safety (or at least get a warning).
*/
/* With first class regexps not via a reference one needs to assign
Expand All @@ -318,16 +318,17 @@ struct pmop {
more complex, and we'd have an AV with (SV*)NULL in it, which feels bad */
/* BEWARE - something that calls this macro passes (r) which has a side
effect. */
#define r1_ PERL_UNIQUE_NAME(r)
#define PM_SETRE(o,r) STMT_START { \
Comment on lines 320 to 322
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replaces any instance of r1_ globally, which seems heavily name polluting.

REGEXP *const pm_setre_ = (r); \
assert(pm_setre_); \
PL_regex_pad[(o)->op_pmoffset] = MUTABLE_SV(pm_setre_); \
REGEXP *const r1_ = (r); \
assert(r1_); \
PM_SETRE_raw(o, r1_); \
} STMT_END
#else
#define PM_GETRE_raw(o) ((o)->op_pmregexp)
#define PM_GETRE(o) ((o)->op_pmregexp)
#define PM_GETRE(o) PM_GETRE_raw(o)
#define PM_SETRE_raw(o,r) ((o)->op_pmregexp = (r))
#define PM_SETRE(o,r) ((o)->op_pmregexp = (r))
#define PM_SETRE(o,r) PM_SETRE_raw(o,r)
#endif

/* Currently these PMf flags occupy a single 32-bit word. Not all bits are
Expand Down
4 changes: 4 additions & 0 deletions perl.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ Now a synonym for C<L</dTHXa>>.
# define pTHX_7 8
# define pTHX_8 9
# define pTHX_9 10
# define pTHX_10 11
# define pTHX_11 12
# define pTHX_12 13
# if defined(DEBUGGING) && !defined(PERL_TRACK_MEMPOOL)
# define PERL_TRACK_MEMPOOL
Expand Down Expand Up @@ -732,6 +734,8 @@ code.
# define pTHX_7 7
# define pTHX_8 8
# define pTHX_9 9
# define pTHX_10 10
# define pTHX_11 11
# define pTHX_12 12
#endif

Expand Down
2 changes: 1 addition & 1 deletion pp_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ PP(pp_regcomp)
}

/* handle the empty pattern */
if (!RX_PRELEN(PM_GETRE(pm)) && PL_curpm) {
if (!RX_PRELEN(PM_GETRE_raw(pm)) && PL_curpm) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this just be

   if (!RX_PRELEN(new_re) && PL_curpm) {

which saves someone checking the code from having to trace that?

if (PL_curpm == PL_reg_curpm) {
if (PL_curpm_under && PL_curpm_under == PL_reg_curpm) {
croak("Infinite recursion via empty pattern");
Expand Down
Loading
Loading