@@ -199,6 +199,7 @@ struct RExC_state_t {
199
199
scan_frame *frame_head;
200
200
scan_frame *frame_last;
201
201
U32 frame_count;
202
+ AV *warn_text;
202
203
#ifdef ADD_TO_REGEXEC
203
204
char *starttry; /* -Dr: where regtry was called. */
204
205
#define RExC_starttry (pRExC_state->starttry)
@@ -290,6 +291,7 @@ struct RExC_state_t {
290
291
#define RExC_frame_count (pRExC_state->frame_count)
291
292
#define RExC_strict (pRExC_state->strict)
292
293
#define RExC_study_started (pRExC_state->study_started)
294
+ #define RExC_warn_text (pRExC_state->warn_text)
293
295
294
296
/* Heuristic check on the complexity of the pattern: if TOO_NAUGHTY, we set
295
297
* a flag to disable back-off on the fixed/floating substrings - if it's
@@ -6764,6 +6766,7 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
6764
6766
#endif
6765
6767
}
6766
6768
6769
+ pRExC_state->warn_text = NULL;
6767
6770
pRExC_state->code_blocks = NULL;
6768
6771
pRExC_state->num_code_blocks = 0;
6769
6772
@@ -13764,8 +13767,8 @@ S_populate_ANYOF_from_invlist(pTHX_ regnode *node, SV** invlist_ptr)
13764
13767
* routine. q.v. */
13765
13768
#define ADD_POSIX_WARNING(p, text) STMT_START { \
13766
13769
if (posix_warnings) { \
13767
- if (! warn_text) warn_text = (AV *) sv_2mortal((SV *) newAV()); \
13768
- av_push(warn_text , Perl_newSVpvf(aTHX_ \
13770
+ if (! RExC_warn_text ) RExC_warn_text = (AV *) sv_2mortal((SV *) newAV()); \
13771
+ av_push(RExC_warn_text , Perl_newSVpvf(aTHX_ \
13769
13772
WARNING_PREFIX \
13770
13773
text \
13771
13774
REPORT_LOCATION, \
@@ -13896,7 +13899,6 @@ S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,
13896
13899
bool has_opening_colon = FALSE;
13897
13900
int class_number = OOB_NAMEDCLASS; /* Out-of-bounds until find
13898
13901
valid class */
13899
- AV* warn_text = NULL; /* any warning messages */
13900
13902
const char * possible_end = NULL; /* used for a 2nd parse pass */
13901
13903
const char* name_start; /* ptr to class name first char */
13902
13904
@@ -13912,6 +13914,9 @@ S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,
13912
13914
13913
13915
PERL_ARGS_ASSERT_HANDLE_POSSIBLE_POSIX;
13914
13916
13917
+ if (posix_warnings && RExC_warn_text)
13918
+ av_clear(RExC_warn_text);
13919
+
13915
13920
if (p >= e) {
13916
13921
return NOT_MEANT_TO_BE_A_POSIX_CLASS;
13917
13922
}
@@ -14529,10 +14534,9 @@ S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,
14529
14534
ADD_POSIX_WARNING(p, "there is no terminating ']'");
14530
14535
}
14531
14536
14532
- if (warn_text ) {
14537
+ if (posix_warnings && av_top_index(RExC_warn_text) > -1 ) {
14533
14538
/* warn_text should only be true if posix_warnings is true */
14534
- assert(posix_warnings);
14535
- *posix_warnings = warn_text;
14539
+ *posix_warnings = RExC_warn_text;
14536
14540
}
14537
14541
}
14538
14542
else if (class_number != OOB_NAMEDCLASS) {
0 commit comments