]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Use warnings from m4 when available.
authorEric Blake <ebb9@byu.net>
Fri, 18 Jul 2008 18:05:43 +0000 (12:05 -0600)
committerEric Blake <ebb9@byu.net>
Sat, 19 Jul 2008 15:28:18 +0000 (09:28 -0600)
* lib/m4sugar/m4sugar.m4 (m4_defn, m4_popdef, m4_undefine): Don't
define slower wrapper if m4 will warn on our behalf; key off of
__m4_version__, added alongside the new warnings in m4 1.6.
* tests/m4sugar.at (m4@&t@_defn): New test.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/m4sugar/m4sugar.m4
tests/m4sugar.at

index af9b4d9b61512512c9da1574039f08c0655edc78..d90117c9a9ba2588290297038df839dc3f6474e9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-07-19  Eric Blake  <ebb9@byu.net>
+
+       Use warnings from m4 when available.
+       * lib/m4sugar/m4sugar.m4 (m4_defn, m4_popdef, m4_undefine): Don't
+       define slower wrapper if m4 will warn on our behalf; key off of
+       __m4_version__, added alongside the new warnings in m4 1.6.
+       * tests/m4sugar.at (m4@&t@_defn): New test.
+
 2008-07-18  Eric Blake  <ebb9@byu.net>
 
        Add m4_joinall.
index eb4374e2d53891784c6ffc90293c1d95d1cb5797..b1e545e6cadde26b75439e7349824d684e2ac821 100644 (file)
@@ -151,7 +151,7 @@ m4_undefine([maketemp])],
 [m4_rename_m4([maketemp])
 m4_copy([m4_maketemp], [m4_mkstemp])])
 m4_rename([patsubst], [m4_bpatsubst])
-m4_undefine([popdef])
+m4_rename_m4([popdef])
 m4_rename_m4([pushdef])
 m4_rename([regexp], [m4_bregexp])
 m4_rename_m4([shift])
@@ -505,15 +505,17 @@ m4_define([m4_default],
 
 # m4_defn(NAME)
 # -------------
-# Like the original, except don't tolerate popping something which is
-# undefined, and only support one argument.
+# Like the original, except guarantee a warning when using something which is
+# undefined (unlike M4 1.4.x), and only support one argument.
 #
 # This macro is called frequently, so minimize the amount of additional
-# expansions by skipping m4_ifndef.
-m4_define([m4_defn],
+# expansions by skipping m4_ifndef.  Better yet, if __m4_version__ exists,
+# (added in M4 1.6), then let m4 do the job for us.
+m4_ifdef([__m4_version__], [],
+[m4_define([m4_defn],
 [m4_ifdef([$1], [],
          [m4_fatal([$0: undefined macro: $1])])]dnl
-[m4_builtin([defn], [$1])])
+[m4_builtin([defn], [$1])])])
 
 
 # _m4_dumpdefs_up(NAME)
@@ -546,15 +548,17 @@ _m4_dumpdefs_down([$1])])
 
 # m4_popdef(NAME)
 # ---------------
-# Like the original, except don't tolerate popping something which is
-# undefined, and only support one argument.
+# Like the original, except guarantee a warning when using something which is
+# undefined (unlike M4 1.4.x), and only support one argument.
 #
 # This macro is called frequently, so minimize the amount of additional
-# expansions by skipping m4_ifndef.
-m4_define([m4_popdef],
+# expansions by skipping m4_ifndef.  Better yet, if __m4_version__ exists,
+# (added in M4 1.6), then let m4 do the job for us.
+m4_ifdef([__m4_version__], [],
+[m4_define([m4_popdef],
 [m4_ifdef([$1], [],
          [m4_fatal([$0: undefined macro: $1])])]dnl
-[m4_builtin([popdef], [$1])])
+[m4_builtin([popdef], [$1])])])
 
 
 # m4_shiftn(N, ...)
@@ -603,15 +607,17 @@ m4_define([_m4_shift3],
 
 # m4_undefine(NAME)
 # -----------------
-# Like the original, except don't tolerate undefining something which is
-# undefined, and only support one argument.
+# Like the original, except guarantee a warning when using something which is
+# undefined (unlike M4 1.4.x), and only support one argument.
 #
 # This macro is called frequently, so minimize the amount of additional
-# expansions by skipping m4_ifndef.
-m4_define([m4_undefine],
+# expansions by skipping m4_ifndef.  Better yet, if __m4_version__ exists,
+# (added in M4 1.6), then let m4 do the job for us.
+m4_ifdef([__m4_version__], [],
+[m4_define([m4_undefine],
 [m4_ifdef([$1], [],
          [m4_fatal([$0: undefined macro: $1])])]dnl
-[m4_builtin([undefine], [$1])])
+[m4_builtin([undefine], [$1])])])
 
 # _m4_wrap(PRE, POST)
 # -------------------
index b6a4cac5ebf253af636410f7edf10ac3636d4906..650f5dcf01f2fd8f0fddab7f69c550b5b177a6a7 100644 (file)
@@ -52,6 +52,41 @@ AT_CHECK_M4SUGAR([-o-],, [$2], [$3])
 # - m4_text_wrap
 # uses m4_split code.
 
+## --------- ##
+## m4_defn.  ##
+## --------- ##
+
+AT_SETUP([m4@&t@_defn])
+
+AT_KEYWORDS([m4@&t@_popdef m4@&t@_undefine])
+
+# Ensure that m4sugar dies when dereferencing undefined macros, whether
+# this is provided by m4 natively or faked by wrappers in m4sugar.
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_defn([oops])
+]])
+
+AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep 'm4@&t@_defn: undefined.*oops' stderr], [0], [ignore])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_popdef([oops])
+]])
+
+AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep 'm4@&t@_popdef: undefined.*oops' stderr], [0], [ignore])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_undefine([oops])
+]])
+
+AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep 'm4@&t@_undefine: undefined.*oops' stderr], [0], [ignore])
+
+AT_CLEANUP
+
+
 ## --------- ##
 ## m4_warn.  ##
 ## --------- ##