[PATCH] ax_var_{push,pop}.m4 missing auxiliary macros

Kip Warner <[email protected]> Mon, 12 Feb 2018 18:44:56 -0800
Newsgroups gmane.comp.sysutils.autoconf.archive-maintainers
Message-ID <[email protected]>
Hey list,

I've attached a patch to fix ax_var_{push,pop}.m4. Both macros were
missing auxiliary macros found in the other. This is why the following
would fail...

    AX_VAR_PUSHVALUE([CXXFLAGS],[])
    AX_TLS([], [AC_MSG_ERROR([thread local storage not available])])
    AX_VAR_POPVALUE([CXXFLAGS])

...with something like...

    ../configure: line 22174: syntax error near unexpected token `CXXFLAGS_counter'
    ../configure: line 22174: `  decrement(CXXFLAGS_counter)'

Yours truly,

-- 
Kip Warner | Senior Software Engineer
OpenPGP signed/encrypted mail preferred
https://www.cartesiantheatre.com
0001-ax_var_-push-pop-.m4-were-both-missing-auxiliary-mac.patch (text/x-patch, 1.9 KB)
From eebbd99e1513dc05a5bce6de7195e2ed6dc83c76 Mon Sep 17 00:00:00 2001
From: Kip Warner <[email protected]>
Date: Mon, 12 Feb 2018 18:38:29 -0800
Subject: [PATCH] ax_var_{push,pop}.m4 were both missing auxiliary macros found
 in the other...

---
 m4/ax_var_pop.m4  | 16 ++++++++++++++++
 m4/ax_var_push.m4 | 19 +++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/m4/ax_var_pop.m4 b/m4/ax_var_pop.m4
index 7c139f9..2d22d4b 100644
--- a/m4/ax_var_pop.m4
+++ b/m4/ax_var_pop.m4
@@ -80,6 +80,21 @@ AC_DEFUN([AX_VAR_POPVALUE],[
   AS_VAR_POPDEF([backup]) dnl
 ])dnl AX_POP_VAR
 
+# -------------------------
+# Auxiliary macro
+# -------------------------
+# increment(counter_name)
+#
+# Increment the value of a named counter.
+# Initialize to 1 if not defined
+# -------------------------
+m4_define([increment],[dnl
+  m4_ifdef([$1],dnl
+    [m4_define([$1],m4_incr($1))],dnl
+    [m4_define([$1],[1])]dnl
+  )dnl
+])dnl
+
 # -------------------------
 # Auxiliary macro
 # -------------------------
@@ -97,3 +112,4 @@ m4_define([decrement],[dnl
    )],dnl
    [m4_fatal([Missing call to AX_VAR_PUSHVALUE with var $1])])dnl
 ])dnl
+
diff --git a/m4/ax_var_push.m4 b/m4/ax_var_push.m4
index d67d8c3..f21400d 100644
--- a/m4/ax_var_push.m4
+++ b/m4/ax_var_push.m4
@@ -94,3 +94,22 @@ m4_define([increment],[dnl
     [m4_define([$1],[1])]dnl
   )dnl
 ])dnl
+
+# -------------------------
+# Auxiliary macro
+# -------------------------
+# decrement(counter_name)
+#
+# Decrement the value of a named counter.
+# Throws an error if counter not defined
+# or value reaches zero.
+# -------------------------
+m4_define([decrement],[dnl
+ m4_ifdef([$1],dnl
+   [m4_if(m4_eval($1 > 0),
+     [1],m4_define([$1],m4_decr($1)),dnl
+     [m4_fatal([Missing call to AX_VAR_PUSHVALUE with var $1])]dnl
+   )],dnl
+   [m4_fatal([Missing call to AX_VAR_PUSHVALUE with var $1])])dnl
+])dnl
+
-- 
2.14.1
signature.asc (application/pgp-signature, 163 B)
-----BEGIN PGP SIGNATURE-----

iEYEABECAAYFAlqCUSgACgkQLXnfK7bii21GCACeK63ZDPHg0+ciiE9YnKstxWb6
frsAnRHnvsawpzI84LURjJK2+tMCaStX
=/mer
-----END PGP SIGNATURE-----