autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AS_VAR_ARITH


From: Eric Blake
Subject: AS_VAR_ARITH
Date: Mon, 27 Oct 2008 21:36:31 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Any objections to these two patches, which switch autoconf over to using $(()) 
rather than `expr` when possible?

Note that this patch series adds a fork to config.status, even though (at 
present), there are no arithmetic evaluations in that file.  I'm thinking of a 
bigger patch to help improve this, but it won't happen today:

AS_REQUIRE would be changed to do two things: ensure that the required text is 
emitted in M4SH-INIT{,-FN} as it currently does, but also append appropriate 
text to a set of child initializations.

Modify AS_INIT_GENERATED to increase the value of _m4_divert(BODY) by two, as 
well as add a hook to AS_CLEANUP that expands the set of child initializations 
into the original _m4_divert(BODY)+1.  This creates a clean division in the 
output between all text prior to AS_INIT_GENERATED and all text after, while 
giving us a diversion where we defer the decision of what to dump until after 
we have read the rest of the input file, instead of the current approach where 
we have to dump everything up front because we are not sure what later macros 
might need.

Alter AS_VAR_APPEND, AS_VAR_ARITH, and any other initialization text such that 
when it is emitted as part of the AS_INIT_GENERATED hook, it outputs only the 
version of the function that the parent script learned, rather than repeating 
the same test as the parent.  For example:

in M4SH-INIT-FN:
AS_IF([_AS_VAR_ARITH_WORKS],
[as_func_arith_defn='as_func_arith ()
{
  as_val=$(( $[]* ))
}],
[as_func_arith_defn='as_func_arith ()
{
  as_val=`expr "$[]@"`
}])
eval $as_func_arith

Later, at the point where AS_INIT_GENERATED was expanded, we use an unquoted 
heredoc:

cat >>child <<_ASEOF
$as_func_arith
ASEOF

We probably ought to change the API of AS_INIT_GENERATED to actually take the 
filename of the child script, so that we can swap between quoted and unquoted 
here-docs at will, rather than the current interface where AS_INIT_GENERATED is 
only a snippet that must occur in a quoted heredoc.  That way, we can also 
subsume the recommendation about starting the child script with #!$SHELL rather 
than #!/bin/sh.  We haven't released an autoconf version with AS_INIT_GENERATED 
yet, so we are still free to improve this API.

Another advantage of this proposal is that modern m4sh scripts (ie. those that 
don't use either of the deprecated _?AS_PREPARE macros) can once again have 
lazy m4sh initialization - rather than having to test for all possible m4sh 
features, the initialization of both the parent and child scripts is reduced to 
the set of features actually used by the script.  configure scripts would no 
longer have to worry about AS_PREPARE.

>From b0a035dc8e48289a4e4ea51061c63b2dc2e07cb8 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 27 Oct 2008 14:26:57 -0600
Subject: [PATCH] Add AS_VAR_ARITH.

* lib/m4sugar/m4sh.m4 (_AS_VAR_ARITH_PREPARE, _AS_VAR_ARITH_WORKS)
(AS_VAR_ARITH): New macros.
(_AS_PREPARE, AS_PREPARE): Emit preparation.
* tests/m4sh.at (AS@&address@hidden): New test.
* doc/autoconf.texi (Polymorphic Variables) <AS_VAR_ARITH>:
Document new macro.
(Limitations of Usual Tools) <expr>: Mention portability problem
if first argument starts with -.
(Shell Substitutions) <$((expression))>: Mention it.
* NEWS: Likewise.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog           |   16 +++++++++++++++-
 NEWS                |    3 ++-
 doc/autoconf.texi   |   37 +++++++++++++++++++++++++++++++++----
 lib/m4sugar/m4sh.m4 |   47 +++++++++++++++++++++++++++++++++++++++++++++--
 tests/m4sh.at       |   31 +++++++++++++++++++++++++++++++
 5 files changed, 126 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 313124b..d5b68ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,26 @@
 2008-10-27  Eric Blake  <address@hidden>
 
+       Add AS_VAR_ARITH.
+       * lib/m4sugar/m4sh.m4 (_AS_VAR_ARITH_PREPARE, _AS_VAR_ARITH_WORKS)
+       (AS_VAR_ARITH): New macros.
+       (_AS_PREPARE, AS_PREPARE): Emit preparation.
+       * tests/m4sh.at (AS@&address@hidden): New test.
+       * doc/autoconf.texi (Polymorphic Variables) <AS_VAR_ARITH>:
+       Document new macro.
+       (Limitations of Usual Tools) <expr>: Mention portability problem
+       if first argument starts with -.
+       (Shell Substitutions) <$((expression))>: Mention it.
+       * NEWS: Likewise.
+
+2008-10-27  Eric Blake  <address@hidden>
+
        Use read, rather than `cat`, for safe one-line files.
        * lib/autotest/general.m4 (AT_CLEANUP): Avoid a fork, since it is
        known that the file has only one line and no \.
        * lib/autoconf/general.m4 (_AC_COMPUTE_INT_RUN): Likewise.
 
 2008-10-27  Paolo Bonzini  <address@hidden>
-    
+
        * lib/autoconf/general.m4 (_AC_COMPUTE_INT_COMPILE,
        _AC_COMPUTE_INT_RUN): Add IF-SUCCESS argument.
        (_AC_COMPUTE_INT_BODY): New.
diff --git a/NEWS b/NEWS
index 5bdff48..1f969b1 100644
--- a/NEWS
+++ b/NEWS
@@ -20,7 +20,8 @@ GNU Autoconf NEWS - User visible changes.
    m4_copy  m4_rename
 
 ** The following documented m4sh macros are new:
-   AS_LINENO_PREPARE  AS_ME_PREPARE  AS_VAR_APPEND  AS_VAR_COPY
+   AS_LINENO_PREPARE  AS_ME_PREPARE  AS_VAR_APPEND  AS_VAR_ARITH
+   AS_VAR_COPY
 
 ** The following m4sh macros are documented now:
    AS_ECHO  AS_ECHO_N  AS_EXIT  AS_LITERAL_IF  AS_UNSET  AS_VAR_IF
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index b89ce5b..c1427a6 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -12121,6 +12121,27 @@ Polymorphic Variables
 expansion.
 @end defmac
 
address@hidden AS_VAR_ARITH (@var{var}, @var{expression})
address@hidden
+Emit shell code to compute the arithmetic expansion of @var{expression},
+assigning the result as the contents of the polymorphic shell variable
address@hidden  The code takes advantage of shells that provide @samp{$(())}
+for fewer forks, but uses @command{expr} as a fallback.  Therefore, the
+syntax for a valid @var{expression} is rather limited: all operators
+must occur as separate shell arguments and with proper quoting, there is
+no portable equality operator, all variables containing numeric values
+must be expanded prior to the computation, all numeric values must be
+provided in decimal without leading zeroes, and the first shell argument
+should not be a negative number.  In the following example, this snippet
+will print @samp{(2+3)*4 == 20}.
+
address@hidden
+bar=3
+AS_VAR_ARITH([foo], [\( 2 + $bar \) \* 4])
+echo "(2+$bar)*4 == $foo"
address@hidden example
address@hidden defmac
+
 @defmac AS_VAR_COPY (@var{dest}, @var{source})
 @asindex{VAR_COPY}
 Emit shell code to assign the contents of the polymorphic shell variable
@@ -14034,10 +14055,10 @@ Shell Substitutions
 
 When it is available, using arithmetic expansion provides a noticeable
 speedup in script execution; but testing for support requires
address@hidden to avoid syntax errors.  If shell function support can
-be assumed, then this construct can be used to assign @samp{foo}
-to an arithmetic result, provided all numeric arguments are provided in
-decimal and without a leading zero:
address@hidden to avoid syntax errors.  The following construct is used
+by @code{AS_VAR_ARITH} to provide arithmetic computation when all
+arguments are provided in decimal and without a leading zero, and all
+operators are properly quoted and appear as distinct arguments:
 
 @example
 if ( eval 'test $(( 1 + 1 )) = 2' ) 2>/dev/null; then
@@ -15880,6 +15901,14 @@ Limitations of Usual Tools
 @item @command{expr}
 @c -----------------
 @prindex @command{expr}
+Not all implementations obey the Posix rule that @samp{--} separates
+options from arguments; likewise, not all implementations provide the
+extension to Posix that the first argument can be treated as part of a
+valid expression rather than an invalid option if it begins with
address@hidden  When performing arithmetic, use @samp{expr 0 + $var} if
address@hidden might be a negative number, to keep @command{expr} from
+interpreting it as an option.
+
 No @command{expr} keyword starts with @samp{X}, so use @samp{expr
 X"@var{word}" : 'address@hidden'} to keep @command{expr} from
 misinterpreting @var{word}.
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 6124065..300923a 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -266,6 +266,7 @@ m4_defun([_AS_PREPARE],
 )]dnl
 [_AS_UNSET_PREPARE
 _AS_VAR_APPEND_PREPARE
+_AS_VAR_ARITH_PREPARE
 
 _AS_EXPR_PREPARE
 _AS_BASENAME_PREPARE
@@ -301,6 +302,7 @@ AS_REQUIRE([_AS_TR_CPP_PREPARE])
 AS_REQUIRE([_AS_TR_SH_PREPARE])
 AS_REQUIRE([_AS_UNSET_PREPARE])
 AS_REQUIRE([_AS_VAR_APPEND_PREPARE], [], [M4SH-INIT-FN])
+AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])
 m4_divert_pop[]])
 
 
@@ -1642,14 +1644,12 @@ AS_IF([_AS_RUN(["AS_ESCAPE([_AS_VAR_APPEND_WORKS])"])],
   }]) # as_func_append
 ])
 
-
 # _AS_VAR_APPEND_WORKS
 # --------------------
 # Output a shell test to discover whether += works.
 m4_define([_AS_VAR_APPEND_WORKS],
 [as_var=1; as_var+=2; test x$as_var = x12])
 
-
 # AS_VAR_APPEND(VAR, VALUE)
 # -------------------------
 # Append the shell expansion of VALUE to the end of the existing
@@ -1666,6 +1666,49 @@ m4_defun_init([AS_VAR_APPEND],
 [as_func_append $1 $2])
 
 
+# _AS_VAR_ARITH_PREPARE
+# ---------------------
+# Define as_func_arith to the optimum definition for the current
+# shell (using POSIX $(()) where supported).
+m4_defun([_AS_VAR_ARITH_PREPARE],
+[AS_FUNCTION_DESCRIBE([as_func_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([_AS_VAR_ARITH_WORKS])"])],
+[eval 'as_func_arith ()
+  {
+    as_val=$(( $[]* ))
+  }'],
+[as_func_arith ()
+  {
+    as_val=`expr "$[]@"`
+  }]) # as_func_arith
+])
+
+# _AS_VAR_ARITH_WORKS
+# -------------------
+# Output a shell test to discover whether $(()) works.
+m4_define([_AS_VAR_ARITH_WORKS],
+[test $(( 1 + 1 )) = 2])
+
+# AS_VAR_ARITH(VAR, EXPR)
+# -----------------------
+# Perform the arithmetic evaluation of the arguments in EXPR, and set
+# contents of the polymorphic shell variable VAR to the result, taking
+# advantage of any shell optimizations that perform arithmetic without
+# forks.  Note that numbers occuring within EXPR must be written in
+# decimal, and without leading zeroes; variables containing numbers
+# must be expanded prior to arithmetic evaluation; the first argument
+# must not be a negative number; there is no portable equality
+# 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_func_arith $2 && AS_VAR_SET([$1], [$as_val])])
+
+
 # AS_VAR_COPY(DEST, SOURCE)
 # -------------------------
 # Set the polymorphic shell variable DEST to the contents of the polymorphic
diff --git a/tests/m4sh.at b/tests/m4sh.at
index badc668..e90e231 100644
--- a/tests/m4sh.at
+++ b/tests/m4sh.at
@@ -1070,6 +1070,37 @@ hello,  world
 AT_CLEANUP
 
 
+## -------------- ##
+## AS_VAR_ARITH.  ##
+## -------------- ##
+
+AT_SETUP([AS@&address@hidden)
+AT_KEYWORDS([m4sh AS@&address@hidden)
+
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+# Literals.
+AS_VAR_ARITH([foo], [1 + 1])
+echo "$foo"
+# Indirects via shell vars.
+num=1
+AS_VAR_ARITH([foo$num], [\( 2 + 3 \) \* 4])
+echo "$foo1"
+# Indirects via command substitution.
+AS_VAR_ARITH([`echo foo2`], [0 + -2 + $foo1 / 2])
+echo "$foo2"
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([./script], [],
+[[2
+20
+8
+]])
+
+AT_CLEANUP
+
+
 ## ----------------- ##
 ## AS_INIT cleanup.  ##
 ## ----------------- ##
-- 
1.6.0.2


>From 17d356b018822941aa06ced426c2800d07bc2c71 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 27 Oct 2008 15:07:57 -0600
Subject: [PATCH] Use AS_VAR_ARITH.

* lib/autotest/general.m4 (at_func_arith): Delete; replace all
clients with AS_VAR_ARITH instead.
* lib/autoconf/general.m4 (_AC_COMPUTE_INT_COMPILE): Use new
macro.
* lib/autoconf/programs.m4 (_AC_FEATURE_CHECK_LENGTH): Likewise.
* tests/torture.at (Torturing config.status): Likewise.
* tests/tools.at (autom4te --force): Likewise.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog                |    9 +++++++++
 lib/autoconf/general.m4  |   13 +++++++------
 lib/autoconf/programs.m4 |    2 +-
 lib/autotest/general.m4  |   44 +++++++++-----------------------------------
 lib/m4sugar/m4sh.m4      |    3 ++-
 tests/tools.at           |    3 ++-
 tests/torture.at         |    2 +-
 7 files changed, 31 insertions(+), 45 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d5b68ad..06d08de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-10-27  Eric Blake  <address@hidden>
 
+       Use AS_VAR_ARITH.
+       * lib/autotest/general.m4 (at_func_arith): Delete; replace all
+       clients with AS_VAR_ARITH instead.
+       * lib/autoconf/general.m4 (_AC_COMPUTE_INT_COMPILE): Use new
+       macro.
+       * lib/autoconf/programs.m4 (_AC_FEATURE_CHECK_LENGTH): Likewise.
+       * tests/torture.at (Torturing config.status): Likewise.
+       * tests/tools.at (autom4te --force): Likewise.
+
        Add AS_VAR_ARITH.
        * lib/m4sugar/m4sh.m4 (_AS_VAR_ARITH_PREPARE, _AS_VAR_ARITH_WORKS)
        (AS_VAR_ARITH): New macros.
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index ec59c8d..3a991b7 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2871,31 +2871,32 @@ _AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], 
[($1) >= 0])],
   while :; do
     _AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) <= $ac_mid])],
                       [ac_hi=$ac_mid; break],
-                      [ac_lo=`expr $ac_mid + 1`
+                      [AS_VAR_ARITH([ac_lo], [$ac_mid + 1])
                        if test $ac_lo -le $ac_mid; then
                          ac_lo= ac_hi=
                          break
                        fi
-                       ac_mid=`expr 2 '*' $ac_mid + 1`])
+                       AS_VAR_ARITH([ac_mid], [2 '*' $ac_mid + 1])])
   done],
 [AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) < 0])],
  [ac_hi=-1 ac_mid=-1
   while :; do
     _AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) >= $ac_mid])],
                       [ac_lo=$ac_mid; break],
-                      [ac_hi=`expr '(' $ac_mid ')' - 1`
+                      [AS_VAR_ARITH([ac_hi], ['(' $ac_mid ')' - 1])
                        if test $ac_mid -le $ac_hi; then
                          ac_lo= ac_hi=
                          break
                        fi
-                       ac_mid=`expr 2 '*' $ac_mid`])
+                       AS_VAR_ARITH([ac_mid], [2 '*' $ac_mid])])
   done],
  [ac_lo= ac_hi=])])
 # Binary search between lo and hi bounds.
 while test "x$ac_lo" != "x$ac_hi"; do
-  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+  AS_VAR_ARITH([ac_mid], ['(' $ac_hi - $ac_lo ')' / 2 + $ac_lo])
   _AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) <= $ac_mid])],
-                    [ac_hi=$ac_mid], [ac_lo=`expr '(' $ac_mid ')' + 1`])
+                    [ac_hi=$ac_mid],
+                    [AS_VAR_ARITH([ac_lo], ['(' $ac_mid ')' + 1])])
 done
 case $ac_lo in @%:@((
 ?*) AS_VAR_SET([$2], [$ac_lo]); $4 ;;
diff --git a/lib/autoconf/programs.m4 b/lib/autoconf/programs.m4
index 6e79cdc..3f66ae3 100644
--- a/lib/autoconf/programs.m4
+++ b/lib/autoconf/programs.m4
@@ -510,7 +510,7 @@ m4_define([_AC_FEATURE_CHECK_LENGTH],
     AS_ECHO(['$4']) >> "conftest.nl"
     $3 < "conftest.nl" >"conftest.out" 2>/dev/null || break
     diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    ac_count=`expr $ac_count + 1`
+    AS_VAR_ARITH([ac_count], [$ac_count + 1])
     if test $ac_count -gt ${$1_max-0}; then
       # Best one so far, save it but keep looking for a better one
       $2="$$1"
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 00817b1..4d7c0f5 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -355,24 +355,6 @@ at_func_create_debugging_script ()
   chmod +x "$at_group_dir/run"
 }
 
-AS_FUNCTION_DESCRIBE([at_func_arith], [ARG...],
-[Arithmetic evaluation, avoids expr if the shell is sane.  The
-interpretation of leading zeroes is unspecified.])
-#
-# subshell and eval are needed to keep Solaris sh from bailing out:
-if ( eval 'test $(( 1 + 1 )) = 2' ) 2>/dev/null; then
-  [#] With "address@hidden", bash does not split positional parameters:
-  eval 'at_func_arith ()
-  {
-    at_func_arith_result=$(( $[*] ))
-  }'
-else
-  at_func_arith ()
-  {
-    at_func_arith_result=`expr "address@hidden"`
-  }
-fi
-
 m4_text_box([End of autotest shell functions.])
 m4_divert_pop([PREPARE_TESTS])dnl back to DEFAULTS
 
@@ -448,7 +430,7 @@ at_func_validate_ranges ()
     fi
     case $at_value in
       0*) # We want to treat leading 0 as decimal, like expr and test, but
-         # at_func_arith treats it as octal if it uses $(( )).
+         # AS_VAR_ARITH treats it as octal if it uses $(( )).
          # With XSI shells, ${at_value#${at_value%%[1-9]*}} avoids the
          # expr fork, but it is not worth the effort to determine if the
          # shell supports XSI when the user can just avoid leading 0.
@@ -1265,12 +1247,9 @@ set X $at_xfail_list; shift; address@hidden:@]
 set X $at_fail_list; shift; address@hidden:@]; at_fail_list=$[*]
 set X $at_skip_list; shift; address@hidden:@]
 
-at_func_arith $at_group_count - $at_skip_count
-at_run_count=$at_func_arith_result
-at_func_arith $at_xpass_count + $at_fail_count
-at_unexpected_count=$at_func_arith_result
-at_func_arith $at_xfail_count + $at_fail_count
-at_total_fail_count=$at_func_arith_result
+AS_VAR_ARITH([at_run_count], [$at_group_count - $at_skip_count])
+AS_VAR_ARITH([at_unexpected_count], [$at_xpass_count + $at_fail_count])
+AS_VAR_ARITH([at_total_fail_count], [$at_xfail_count + $at_fail_count])
 
 # Back to the top directory.
 cd "$at_dir"
@@ -1282,16 +1261,11 @@ at_stop_time=`date +%s 2>/dev/null`
 AS_ECHO(["$as_me: ending at: $at_stop_date"]) >&AS_MESSAGE_LOG_FD
 case $at_start_time,$at_stop_time in
   [[0-9]*,[0-9]*])
-    at_func_arith $at_stop_time - $at_start_time
-    at_duration_s=$at_func_arith_result
-    at_func_arith $at_duration_s / 60
-    at_duration_m=$at_func_arith_result
-    at_func_arith $at_duration_m / 60
-    at_duration_h=$at_func_arith_result
-    at_func_arith $at_duration_s % 60
-    at_duration_s=$at_func_arith_result
-    at_func_arith $at_duration_m % 60
-    at_duration_m=$at_func_arith_result
+    AS_VAR_ARITH([at_duration_s], [$at_stop_time - $at_start_time])
+    AS_VAR_ARITH([at_duration_m], [$at_duration_s / 60])
+    AS_VAR_ARITH([at_duration_h], [$at_duration_m / 60])
+    AS_VAR_ARITH([at_duration_s], [$at_duration_s % 60])
+    AS_VAR_ARITH([at_duration_m], [$at_duration_m % 60])
     at_duration="${at_duration_h}h ${at_duration_m}m ${at_duration_s}s"
     AS_ECHO(["$as_me: test suite duration: $at_duration"]) >&AS_MESSAGE_LOG_FD
     ;;
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 300923a..7ba1adf 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -944,7 +944,8 @@ m4_defun([_AS_ME_PREPARE],
 # This macro does not expand to a single shell command, so be careful
 # when using it.  Surrounding the body of this macro with {} would
 # cause "bash -c '_ASLINENO_WORKS'" to fail (with Bash 2.05, anyway),
-# but that bug is irrelevant to our use of LINENO.
+# but that bug is irrelevant to our use of LINENO.  We can't use
+# AS_VAR_ARITH, as this is expanded prior to shell functions.
 m4_define([_AS_LINENO_WORKS],
 [
   as_lineno_1=$LINENO
diff --git a/tests/tools.at b/tests/tools.at
index 0123f82..06fcf6a 100644
--- a/tests/tools.at
+++ b/tests/tools.at
@@ -130,7 +130,8 @@ AT_CHECK_AUTOM4TE([-o file file.m4])
 # even on slow machines.
 echo BAD >file
 this_year=`TZ=UTC0 date +%Y`
-TZ=UTC0 touch -t `expr $this_year + 1`01010001 file
+AS_VAR_ARITH([next_year], [$this_year + 1])
+TZ=UTC0 touch -t ${next_year}01010001 file
 
 AT_CHECK_AUTOM4TE([--force -o file file.m4])
 AT_CHECK([cat file], 0,
diff --git a/tests/torture.at b/tests/torture.at
index b79ff89..74aab9e 100644
--- a/tests/torture.at
+++ b/tests/torture.at
@@ -614,7 +614,7 @@ AT_DATA([dummy.in],
 i=1
 while test $i != 101; do
   echo "content of file $i" > file_$i
-  i=`expr $i + 1`
+  AS_VAR_ARITH([i], [$i + 1])
 done
 
 
-- 
1.6.0.2







reply via email to

[Prev in Thread] Current Thread [Next in Thread]