Introduce STR_WITH_LEN macro in the form suggested by Chip.
Gisle Aas [Wed, 4 Jan 2006 10:44:48 +0000 (10:44 +0000)]
p4raw-id: //depot/perl@26635

handy.h
toke.c

diff --git a/handy.h b/handy.h
index 6c87f91..b587ea5 100644 (file)
--- a/handy.h
+++ b/handy.h
@@ -236,6 +236,9 @@ typedef U64TYPE U64;
 
 #define Ctl(ch) ((ch) & 037)
 
+/* concatenating with "" ensures that only literal strings are accepted as agument */
+#define STR_WITH_LEN(s)  (s ""), (sizeof(s)-1)
+
 /*
 =head1 Miscellaneous Functions
 
diff --git a/toke.c b/toke.c
index 6a454ca..35d2639 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -460,7 +460,7 @@ S_missingterm(pTHX_ char *s)
 
 #define FEATURE_IS_ENABLED(name)                                       \
        ((0 != (PL_hints & HINT_LOCALIZE_HH))                           \
-           && feature_is_enabled((name ""), sizeof(name)-1))
+           && feature_is_enabled(STR_WITH_LEN(name)))
 /*
  * S_feature_is_enabled
  * Check whether the named feature is enabled.