This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Extract some code into a macro
authorKarl Williamson <khw@cpan.org>
Sun, 24 Aug 2014 00:01:28 +0000 (18:01 -0600)
committerKarl Williamson <khw@cpan.org>
Mon, 25 Aug 2014 17:13:40 +0000 (11:13 -0600)
This is in preparation for it to be used in more than one place

regcomp.c

index d0fe08b..cb15aed 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -16667,6 +16667,11 @@ Perl_save_re_context(pTHX)
 
 #ifdef DEBUGGING
 
+/* Certain characters are output as a sequence with the first being a
+ * backslash. */
+#define isBACKSLASHED_PUNCT(c)                                              \
+                    ((c) == '-' || (c) == ']' || (c) == '\\' || (c) == '^')
+
 STATIC void
 S_put_byte(pTHX_ SV *sv, int c)
 {
@@ -16686,7 +16691,7 @@ S_put_byte(pTHX_ SV *sv, int c)
     }
     else {
        const char string = c;
-       if (c == '-' || c == ']' || c == '\\' || c == '^')
+       if (isBACKSLASHED_PUNCT(c))
            sv_catpvs(sv, "\\");
        sv_catpvn(sv, &string, 1);
     }