]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Use AS_VAR_ARITH.
authorEric Blake <ebb9@byu.net>
Mon, 27 Oct 2008 21:07:57 +0000 (15:07 -0600)
committerEric Blake <ebb9@byu.net>
Mon, 27 Oct 2008 22:11:59 +0000 (16:11 -0600)
* 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 <ebb9@byu.net>
ChangeLog
lib/autoconf/general.m4
lib/autoconf/programs.m4
lib/autotest/general.m4
lib/m4sugar/m4sh.m4
tests/tools.at
tests/torture.at

index d5b68adbbb52580e7b411bfe02dd7453571bffb9..06d08ded2452e60b889f38f2222fdc7da77c6696 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-10-27  Eric Blake  <ebb9@byu.net>
 
+       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.
index 000f705b76f59104f7558e7d00fd42a8b582b724..c8ab4afbce07c4dc49c7d54aff0f16eaffe181f3 100644 (file)
@@ -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 ;;
index 6e79cdc9b916455c5a8097d2934425a1c9980eb2..3f66ae32d6e6e7ea89c2600b41c2596dad990824 100644 (file)
@@ -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"
index 00817b1a75bf7a73bfe1894ae4780ff60b7f9fd5..4d7c0f5aa02939ad0a6222cca36266b6a653048d 100644 (file)
@@ -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 "$[@]", bash does not split positional parameters:
-  eval 'at_func_arith ()
-  {
-    at_func_arith_result=$(( $[*] ))
-  }'
-else
-  at_func_arith ()
-  {
-    at_func_arith_result=`expr "$[@]"`
-  }
-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; at_xfail_count=$[@%:@]
 set X $at_fail_list; shift; at_fail_count=$[@%:@]; at_fail_list=$[*]
 set X $at_skip_list; shift; at_skip_count=$[@%:@]
 
-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
     ;;
index 300923a23b4ce6263c546ad3d5886f8b075bb426..7ba1adf0253498bfd3167d5b2319ef6724779d00 100644 (file)
@@ -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
index 0123f825e0356cae6400a4a76a675638490a092b..06fcf6a9e4d3cc9a76ff95364e7fa1345bfcb994 100644 (file)
@@ -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,
index b79ff895f84fb845e1a61570dd29bbdc89e97911..74aab9e9dc149694ac64d0dfeec3bb730774901e 100644 (file)
@@ -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