[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] m4sh: require POSIX arithmetic $((...)) unconditionally
From: |
Stefano Lattarini |
Subject: |
[PATCH 1/2] m4sh: require POSIX arithmetic $((...)) unconditionally |
Date: |
Wed, 7 Nov 2012 13:37:19 +0100 |
This is a first step towards our aim of making autoconf require,
and if necessary find, a POSIX shell. For more details, see:
<http://lists.gnu.org/archive/html/bug-autoconf/2012-06/msg00009.html>
* lib/m4sugar/m4sh.m4 (AS_INIT): Call '_AS_DETECT_REQUIRED' with
'_AS_VAR_ARITH_WORKS' as argument, thus ensuring that the shell which
will end up running configure will support POSIX-mandated $((...))
arithmetic expansion.
(AS_VAR_ARITH): Accordingly, no need to call '_AS_DETECT_SUGGESTED'
with '_AS_VAR_ARITH_WORKS' as argument.
(_AS_VAR_ARITH_PREPARE): Unconditionally assume that POSIX-mandated
$((...)) arithmetic expansion works.
Signed-off-by: Stefano Lattarini <address@hidden>
---
lib/m4sugar/m4sh.m4 | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 19ee12f..dc4207c 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -1948,21 +1948,15 @@ m4_defun_init([AS_VAR_APPEND],
# _AS_VAR_ARITH_PREPARE
# ---------------------
# Define as_fn_arith to the optimum definition for the current
-# shell (using POSIX $(()) where supported).
+# shell -- that is, using POSIX $((...)).
m4_defun([_AS_VAR_ARITH_PREPARE],
[AS_FUNCTION_DESCRIBE([as_fn_arith], [ARG...],
[Perform arithmetic evaluation on the ARGs, and store the result in
-the global $as_val. Take advantage of shells that can avoid forks.
-The arguments must be portable across $(()) and expr.])
-AS_IF([_AS_RUN(["AS_ESCAPE(m4_quote(_AS_VAR_ARITH_WORKS))"])],
-[eval 'as_fn_arith ()
+the global $as_val.])
+as_fn_arith ()
{
as_val=$(( $[]* ))
- }'],
-[as_fn_arith ()
- {
- as_val=`expr "$[]@" || test $? -eq 1`
- }]) # as_fn_arith
+ }
])
# _AS_VAR_ARITH_WORKS
@@ -1983,7 +1977,6 @@ m4_define([_AS_VAR_ARITH_WORKS],
# operator; and operators must be given as separate arguments and
# properly quoted.
m4_defun_init([AS_VAR_ARITH],
-[_AS_DETECT_SUGGESTED([_AS_VAR_ARITH_WORKS])]dnl
[AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])],
[as_fn_arith $2 && AS_VAR_SET([$1], [$as_val])])
@@ -2168,5 +2161,6 @@ m4_divert([BODY])dnl
m4_text_box([Main body of script.])
_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
_AS_DETECT_REQUIRED([_AS_TEST_X_WORKS])dnl
+_AS_DETECT_REQUIRED([_AS_VAR_ARITH_WORKS])dnl
AS_REQUIRE([_AS_UNSET_PREPARE], [], [M4SH-INIT-FN])dnl
])
--
1.8.0
- [PATCH 0/2] First steps in making autoconf ensure a POSIX shell, Stefano Lattarini, 2012/11/07
- [PATCH 1/2] m4sh: require POSIX arithmetic $((...)) unconditionally,
Stefano Lattarini <=
- [PATCH 2/2] m4sh: require a POSIX shell, Stefano Lattarini, 2012/11/07
- Re: [PATCH 0/2] First steps in making autoconf ensure a POSIX shell, Paul Eggert, 2012/11/07
- Re: [PATCH 0/2] First steps in making autoconf ensure a POSIX shell, Stefano Lattarini, 2012/11/07
- Re: [PATCH 0/2] First steps in making autoconf ensure a POSIX shell, Adrian Bunk, 2012/11/07
- Re: [PATCH 0/2] First steps in making autoconf ensure a POSIX shell, Eric Blake, 2012/11/07
- Re: [PATCH 0/2] First steps in making autoconf ensure a POSIX shell, Stefano Lattarini, 2012/11/07
- Re: [PATCH 0/2] First steps in making autoconf ensure a POSIX shell, Eric Blake, 2012/11/09
- Re: [PATCH 0/2] First steps in making autoconf ensure a POSIX shell, Stefano Lattarini, 2012/11/10
- Re: [PATCH 0/2] First steps in making autoconf ensure a POSIX shell, Adrian Bunk, 2012/11/10
- Re: [PATCH 0/2] First steps in making autoconf ensure a POSIX shell, Stefano Lattarini, 2012/11/10