regcomp.c: Omit warning if error about to be raised
authorKarl Williamson <khw@cpan.org>
Sun, 14 Oct 2018 18:52:07 +0000 (12:52 -0600)
committerKarl Williamson <khw@cpan.org>
Sat, 20 Oct 2018 06:09:55 +0000 (00:09 -0600)
This commit changes the code to skip a warning when it knows an error is
about to happen.  Currently this doesn't matter, as the warning would be
emitted only in a later pass, and the error would actually happen first,
so the warning doesn't get output at all.  But future commits will
change that, so this commit is in preparation for that.

regcomp.c

index 668f264..e79c455 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -13886,11 +13886,13 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
                        /* FALLTHROUGH */
                    default:
                        if (isALPHANUMERIC(*p)) {
-                           /* Include any left brace following the alpha to emphasize
-                            * that it could be part of an escape at some point
-                            * in the future */
-                           int len = (isALPHA(*p) && *(p + 1) == '{') ? 2 : 1;
-                           ckWARN3reg(p + len, "Unrecognized escape \\%.*s passed through", len, p);
+                            /* An alpha followed by '{' is going to fail next
+                             * iteration, so don't output this warning in that
+                             * case */
+                            if (! isALPHA(*p) || *(p + 1) != '{') {
+                                ckWARN2reg(p + 1, "Unrecognized escape \\%.1s"
+                                                  " passed through", p);
+                            }
                        }
                        goto normal_default;
                    } /* End of switch on '\' */