summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2021-05-31 17:12:21 -0600
committerKarl Williamson <khw@cpan.org>2021-08-07 14:50:35 -0600
commite040f2ad444d8427fef376d99c0fb47a06a78e05 (patch)
treed5520a18e87cbe21764c7442fa478a11bff7162d /regcomp.c
parent138daa9de5910dbd89190c9345fb07a0efbb5860 (diff)
downloadperl-e040f2ad444d8427fef376d99c0fb47a06a78e05.tar.gz
regcomp.c: S_optimize_regclass() return 0 if fail
Based on a comment from @hvds, I think it better if this function return an impossible node value if it didn't find a node to use.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/regcomp.c b/regcomp.c
index edcb9e44d0..9b895cbba2 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -19222,6 +19222,12 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
SvREFCNT_dec(upper_latin1_only_utf8_matches);
return ret;
}
+
+ /* If no optimization was found, an END was returned and we will now
+ * emit an ANYOF */
+ if (op == END) {
+ op = ANYOF;
+ }
}
/* Here are going to emit an ANYOF; set the particular type */
@@ -19305,14 +19311,14 @@ S_optimize_regclass(pTHX_
* ANYOF node. The parameter names are the same as the corresponding
* variables in S_regclass.
*
- * It returns the new op (ANYOF if no optimization found) and sets *ret to
- * any created regnode. If the new op is sufficiently like plain ANYOF, it
- * leaves *ret unchanged for allocation in S_regclass.
+ * It returns the new op (the impossible END one if no optimization found)
+ * and sets *ret to any created regnode. If the new op is sufficiently
+ * like plain ANYOF, it leaves *ret unchanged for allocation in S_regclass.
*
* Certain of the parameters may be updated as a result of the changes
* herein */
- U8 op = ANYOF; /* The returned node-type, initialized to the unoptimized
+ U8 op = END; /* The returned node-type, initialized to an impossible
one. */
UV value;
PERL_UINT_FAST8_T i;
@@ -19435,7 +19441,7 @@ S_optimize_regclass(pTHX_
/* khw can't think of any other possible transformation involving these. */
if (has_runtime_dependency & HAS_USER_DEFINED_PROPERTY) {
- return op;
+ return END;
}
if (! has_runtime_dependency) {
@@ -19753,7 +19759,7 @@ S_optimize_regclass(pTHX_
}
}
- if (op != ANYOF) {
+ if (op != END) {
U8 len;
/* Here, we have calculated what EXACTish node to use. Have to
@@ -19905,7 +19911,7 @@ S_optimize_regclass(pTHX_
_invlist_invert(cp_list);
}
- if (op != ANYOF) {
+ if (op != END) {
return op;
}