new IF_HAVE_PERL_5_16 convenience macro
Lukas Mai [Fri, 22 Jun 2012 07:12:35 +0000 (09:12 +0200)]
Parameters.xs
toke_on_crack.c.inc

index 261a5bc..b822303 100644 (file)
@@ -61,6 +61,12 @@ WARNINGS_ENABLE
 #define HAVE_PERL_VERSION(R, V, S) \
        (PERL_REVISION > (R) || (PERL_REVISION == (R) && (PERL_VERSION > (V) || (PERL_VERSION == (V) && (PERL_SUBVERSION >= (S))))))
 
+#if HAVE_PERL_VERSION(5, 16, 0)
+ #define IF_HAVE_PERL_5_16(YES, NO) YES
+#else
+ #define IF_HAVE_PERL_5_16(YES, NO) NO
+#endif
+
 typedef struct {
        enum {
                FLAG_NAME_OPTIONAL = 1,
index 325ed72..bd609eb 100644 (file)
@@ -68,11 +68,10 @@ static char *S_scan_str(pTHX_ SV *sv, int keep_quoted, int keep_delims) {
                termlen = 1;
        }
        else {
-#if HAVE_PERL_VERSION(5, 16, 0)
-               termcode = utf8_to_uvchr_buf((U8*)s, (U8*)PL_bufend, &termlen);
-#else
-               termcode = utf8_to_uvchr((U8*)s, &termlen);
-#endif
+               termcode = IF_HAVE_PERL_5_16(
+                       utf8_to_uvchr_buf((U8*)s, (U8*)PL_bufend, &termlen),
+                       utf8_to_uvchr((U8*)s, &termlen)
+               );
                Copy(s, termstr, termlen, U8);
                if (!UTF8_IS_INVARIANT(term))
                        has_utf8 = TRUE;
@@ -111,10 +110,11 @@ static char *S_scan_str(pTHX_ SV *sv, int keep_quoted, int keep_delims) {
                                char * const svlast = SvEND(sv) - 1;
 
                                for (; s < ns; s++) {
-                                       if (*s == '\n' && !PL_rsfp
-#if HAVE_PERL_VERSION(5, 16, 0)
-                                               && !PL_parser->filtered
-#endif
+                                       if (*s == '\n' && !PL_rsfp &&
+                                               IF_HAVE_PERL_5_16(
+                                                       !PL_parser->filtered,
+                                                       TRUE
+                                               )
                                        )
                                                CopLINE_inc(PL_curcop);
                                }
@@ -182,10 +182,11 @@ static char *S_scan_str(pTHX_ SV *sv, int keep_quoted, int keep_delims) {
                if (PL_multi_open == PL_multi_close) {
                        for (; s < PL_bufend; s++,to++) {
                                /* embedded newlines increment the current line number */
-                               if (*s == '\n' && !PL_rsfp
-#if HAVE_PERL_VERSION(5, 16, 0)
-                                       && !PL_parser->filtered
-#endif
+                               if (*s == '\n' && !PL_rsfp &&
+                                       IF_HAVE_PERL_5_16(
+                                               !PL_parser->filtered,
+                                               1
+                                       )
                                )
                                        CopLINE_inc(PL_curcop);
                                /* handle quoted delimiters */
@@ -218,10 +219,11 @@ static char *S_scan_str(pTHX_ SV *sv, int keep_quoted, int keep_delims) {
                        /* read until we run out of string, or we find the terminator */
                        for (; s < PL_bufend; s++,to++) {
                                /* embedded newlines increment the line count */
-                               if (*s == '\n' && !PL_rsfp
-#if HAVE_PERL_VERSION(5, 16, 0)
-                                       && !PL_parser->filtered
-#endif
+                               if (*s == '\n' && !PL_rsfp &&
+                                       IF_HAVE_PERL_5_16(
+                                               !PL_parser->filtered,
+                                               1
+                                       )
                                )
                                        CopLINE_inc(PL_curcop);
                                /* backslashes can escape the open or closing characters */