autoconf-commit
[Top][All Lists]
Advanced

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

[SCM] GNU Autoconf source repository branch, master, updated. v2.63-116-


From: Eric Blake
Subject: [SCM] GNU Autoconf source repository branch, master, updated. v2.63-116-gd783e51
Date: Tue, 28 Oct 2008 02:55:55 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Autoconf source repository".

http://git.sv.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=d783e517644aa68e36b34335340d8629114d1f97

The branch, master has been updated
       via  d783e517644aa68e36b34335340d8629114d1f97 (commit)
       via  cb34ecf15c8153b9a67fa168510d2c4594d3049e (commit)
       via  cfa144a9556cec71d3cc4e29bc6dfcdf042135a3 (commit)
       via  bc9d68de415c7ab4b23f3cab12d97457e3da7e27 (commit)
       via  cf99ea9775cc8f2b18710f117de9291f6a7e8166 (commit)
      from  281988f2e2d00de5c5a20f9ec16fe4b3fc929334 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d783e517644aa68e36b34335340d8629114d1f97
Author: Eric Blake <address@hidden>
Date:   Mon Oct 27 17:22:40 2008 -0600

    Prefer m4_fatal over AC_FATAL.
    
    * lib/autoconf/types.m4 (AC_CHECK_SIZEOF, AC_CHECK_ALIGNOF)
    (AC_CHECK_MEMBER): Use non-obsolete macro name.
    * lib/autoconf/fortran.m4 (_AC_LIST_MEMBER_IF): Likewise.
    * lib/autoconf/general.m4 (AC_REQUIRE_AUX_FILE, AC_SUBST):
    Likewise.
    * lib/autoconf/lang.m4 (_AC_LANG_DISPATCH): Likewise.
    * lib/autoconf/status.m4 (_AC_CONFIG_DEPENDENCY_DEFAULT)
    (_AC_CONFIG_UNIQUE, _AC_CONFIG_REGISTER_DEST): Likewise.
    
    Signed-off-by: Eric Blake <address@hidden>

commit cb34ecf15c8153b9a67fa168510d2c4594d3049e
Author: Eric Blake <address@hidden>
Date:   Mon Oct 27 16:34:58 2008 -0600

    Avoid raw carriage return in scripts.
    
    * lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE): Generate CR
    via tr, rather than with literal byte.
    * THANKS: Update.
    Reported by Steven R. Loomis; patch suggested by Thomas Dickey.
    
    Signed-off-by: Eric Blake <address@hidden>

commit cfa144a9556cec71d3cc4e29bc6dfcdf042135a3
Author: Eric Blake <address@hidden>
Date:   Mon Oct 27 15:07:57 2008 -0600

    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>

commit bc9d68de415c7ab4b23f3cab12d97457e3da7e27
Author: Eric Blake <address@hidden>
Date:   Mon Oct 27 14:26:57 2008 -0600

    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>

commit cf99ea9775cc8f2b18710f117de9291f6a7e8166
Author: Eric Blake <address@hidden>
Date:   Mon Oct 27 10:36:59 2008 -0600

    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.
    
    Signed-off-by: Eric Blake <address@hidden>

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                |   52 +++++++++++++++++++++++++++++++++++++++++++++-
 NEWS                     |    3 +-
 THANKS                   |    1 +
 doc/autoconf.texi        |   37 +++++++++++++++++++++++++++++---
 lib/autoconf/fortran.m4  |    8 +++---
 lib/autoconf/general.m4  |   33 ++++++++++++++++-------------
 lib/autoconf/lang.m4     |    4 +-
 lib/autoconf/programs.m4 |    2 +-
 lib/autoconf/status.m4   |   20 +++++++++--------
 lib/autoconf/types.m4    |   20 ++++++++--------
 lib/autotest/general.m4  |   46 ++++++++-------------------------------
 lib/m4sugar/m4sh.m4      |   50 +++++++++++++++++++++++++++++++++++++++++--
 tests/m4sh.at            |   31 +++++++++++++++++++++++++++
 tests/tools.at           |    3 +-
 tests/torture.at         |    2 +-
 15 files changed, 224 insertions(+), 88 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index eab5a93..9a6a5f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,55 @@
+2008-10-27  Eric Blake  <address@hidden>
+
+       Prefer m4_fatal over AC_FATAL.
+       * lib/autoconf/types.m4 (AC_CHECK_SIZEOF, AC_CHECK_ALIGNOF)
+       (AC_CHECK_MEMBER): Use non-obsolete macro name.
+       * lib/autoconf/fortran.m4 (_AC_LIST_MEMBER_IF): Likewise.
+       * lib/autoconf/general.m4 (AC_REQUIRE_AUX_FILE, AC_SUBST):
+       Likewise.
+       * lib/autoconf/lang.m4 (_AC_LANG_DISPATCH): Likewise.
+       * lib/autoconf/status.m4 (_AC_CONFIG_DEPENDENCY_DEFAULT)
+       (_AC_CONFIG_UNIQUE, _AC_CONFIG_REGISTER_DEST): Likewise.
+
+2008-10-27  Eric Blake  <address@hidden>
+
+       Avoid raw carriage return in scripts.
+       * lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE): Generate CR
+       via tr, rather than with literal byte.
+       * THANKS: Update.
+       Reported by Steven R. Loomis; patch suggested by Thomas Dickey.
+
+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.
+       (_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/THANKS b/THANKS
index 0488f29..f566006 100644
--- a/THANKS
+++ b/THANKS
@@ -325,6 +325,7 @@ Steve Chamberlain           address@hidden
 Steve Huston                address@hidden
 Steve Robbins               address@hidden
 Steven G. Johnson           address@hidden
+Steven R. Loomis            address@hidden
 Stu Grossman                address@hidden
 Sumit Pandya                address@hidden
 Syd Polk                    address@hidden
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 @@ appends.  Note that unlike @code{AS_VAR_SET}, this 
macro requires that
 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 @@ $ @kbd{pdksh -c 'echo $(( 010 ))'}
 
 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 @@ foo
 @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/autoconf/fortran.m4 b/lib/autoconf/fortran.m4
index 34d9301..519f3f0 100644
--- a/lib/autoconf/fortran.m4
+++ b/lib/autoconf/fortran.m4
@@ -100,10 +100,10 @@
 # if ELEMENT is a member of LIST, otherwise it executes
 # ACTION-IF-NOT-FOUND.
 AC_DEFUN([_AC_LIST_MEMBER_IF],
-[dnl Do some sanity checking of the arguments.
-m4_if([$1], , [AC_FATAL([$0: missing argument 1])])dnl
-m4_if([$2], , [AC_FATAL([$0: missing argument 2])])dnl
-  ac_exists=false
+dnl Do some sanity checking of the arguments.
+[m4_if([$1], , [m4_fatal([$0: missing argument 1])],
+      [$2], , [m4_fatal([$0: missing argument 2])])]dnl
+[  ac_exists=false
   for ac_i in $2; do
     if test x"$1" = x"$ac_i"; then
       ac_exists=true
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 8b84245..922dda3 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -1722,7 +1722,7 @@ AC_DEFUN([AC_CONFIG_MACRO_DIR], [])
 # It announces FILE is required in the auxdir.
 m4_define([AC_REQUIRE_AUX_FILE],
 [AS_LITERAL_IF([$1], [],
-              [AC_FATAL([$0: requires a literal argument])])])
+              [m4_fatal([$0: requires a literal argument])])])
 
 
 
@@ -2111,12 +2111,11 @@ m4_define([AC_SUBST_TRACE])
 #
 m4_define([AC_SUBST],
 [AS_IDENTIFIER_IF([$1], [],
-  [AC_FATAL([$0: `$1' is not a valid shell variable name])])dnl
-AC_SUBST_TRACE([$1])dnl
-m4_pattern_allow([^$1$])dnl
-m4_ifvaln([$2], [$1=$2])[]dnl
-m4_set_add([_AC_SUBST_VARS], [$1])dnl
-])# AC_SUBST
+  [m4_fatal([$0: `$1' is not a valid shell variable name])])]dnl
+[AC_SUBST_TRACE([$1])]dnl
+[m4_pattern_allow([^$1$])]dnl
+[m4_ifvaln([$2], [$1=$2])[]]dnl
+[m4_set_add([_AC_SUBST_VARS], [$1])])# AC_SUBST
 
 
 # AC_SUBST_FILE(VARIABLE)
@@ -2871,31 +2870,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 ;;
@@ -2908,9 +2908,12 @@ esac[]dnl
 #                     [IF-FAILURE])
 # -----------------------------------------------------------------
 # Store the evaluation of the integer EXPRESSION in VARIABLE.
+#
+# AC_LANG_INT_SAVE intentionally does not end the file in a newline, so
+# we must add one to make it a text file before passing it to read.
 m4_define([_AC_COMPUTE_INT_RUN],
 [_AC_RUN_IFELSE([AC_LANG_INT_SAVE([$3], [$1])],
-              [AS_VAR_SET([$2], [`cat conftest.val`]); $4], [$5])
+               [echo >>conftest.val; read $2 <conftest.val; $4], [$5])
 rm -f conftest.val
 ])# _AC_COMPUTE_INT_RUN
 
@@ -2925,7 +2928,7 @@ m4_define([_AC_COMPUTE_INT_BODY],
                            [ac_retval=0], [ac_retval=1])
   else
     _AC_COMPUTE_INT_RUN([$[]2], [$[]3], [$[]4],
-                       [ac_retval=0], [ac_retval=1])
+                       [ac_retval=0], [ac_retval=1])
   fi
   AS_LINENO_POP
   return $ac_retval
diff --git a/lib/autoconf/lang.m4 b/lib/autoconf/lang.m4
index c48f1de..9ebc7d6 100644
--- a/lib/autoconf/lang.m4
+++ b/lib/autoconf/lang.m4
@@ -86,7 +86,7 @@ m4_define([AC_LANG_CASE],
 m4_define([_AC_LANG_DISPATCH],
 [m4_ifdef([$1($2)],
        [m4_indir([$1($2)], m4_shift2($@))],
-       [AC_FATAL([$1: unknown language: $2])])])
+       [m4_fatal([$1: unknown language: $2])])])
 
 
 # _AC_LANG_SET(OLD, NEW)
@@ -495,7 +495,7 @@ do
        # certainly right.
        break;;
     *.* )
-        if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+       if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
        then :; else
           ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
        fi
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/autoconf/status.m4 b/lib/autoconf/status.m4
index 3cbf618..54758b1 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -207,7 +207,8 @@ m4_define([_AC_CONFIG_DEPENDENCY],
 m4_define([_AC_CONFIG_DEPENDENCY_DEFAULT],
 [m4_bmatch([$2], [:], [],
           [m4_if([$1], [LINKS],
-                 [AS_LITERAL_IF([$2], [AC_FATAL([Invalid AC_CONFIG_LINKS tag: 
`$2'])])],
+                 [AS_LITERAL_IF([$2],
+                   [m4_fatal([Invalid AC_CONFIG_LINKS tag: `$2'])])],
                  [:$2.in])])dnl
 ])
 
@@ -220,7 +221,8 @@ m4_define([_AC_CONFIG_DEPENDENCY_DEFAULT],
 #
 m4_define([_AC_CONFIG_UNIQUE],
 [m4_ifdef([_AC_SEEN_TAG($2)],
-   [AC_FATAL([`$2' is already registered with 
AC_CONFIG_]m4_defn([_AC_SEEN_TAG($2)]).)],
+   [m4_fatal([`$2' is already registered with AC_CONFIG_]m4_defn(
+     [_AC_SEEN_TAG($2)]).)],
    [m4_define([_AC_SEEN_TAG($2)], [$1])])dnl
 ])
 
@@ -270,15 +272,15 @@ _AC_CONFIG_REGISTER_DEST([$1], [$2], m4_bpatsubst([[$2]], 
[:.*\(.\)$], [\1]), [$
 # Save the name of the first config header to AH_HEADER.
 #
 m4_define([_AC_CONFIG_REGISTER_DEST],
-[_AC_CONFIG_UNIQUE([$1], [$3])dnl
-m4_if([$1 $3], [LINKS .],
-      [AC_FATAL([invalid destination of a config link: `.'])])dnl
-m4_if([$1], [HEADERS],
-      [m4_define_default([AH_HEADER], [$3])])dnl
+[_AC_CONFIG_UNIQUE([$1], [$3])]dnl
+[m4_if([$1 $3], [LINKS .],
+       [m4_fatal([invalid destination of a config link: `.'])],
+       [$1], [HEADERS],
+       [m4_define_default([AH_HEADER], [$3])])]dnl
 dnl
 dnl Recognize TAG as an argument to config.status:
 dnl
-m4_append([_AC_LIST_TAGS],
+[m4_append([_AC_LIST_TAGS],
 [    "$3") CONFIG_$1="$CONFIG_$1 $2" ;;
 ])dnl
 dnl
@@ -370,7 +372,7 @@ else
   # The final `:' finishes the AND list.
   ac_cs_awk_pipe_fini='END { print "|#_!!_#|"; print ":" }'
 fi]])
-ac_cr='
'
+ac_cr=`echo X | tr X '\015'`
 ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
 if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
   ac_cs_awk_cr='\\r'
diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index f310cd1..2b63331 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -150,7 +150,7 @@ m4_define([_AC_CHECK_TYPE_NEW_BODY],
   AC_COMPILE_IFELSE(
     [AC_LANG_PROGRAM([$[]4],
        [if (sizeof ($[]2))
-         return 0;])],
+        return 0;])],
     [AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM([$[]4],
          [if (sizeof (($[]2)))
@@ -741,8 +741,8 @@ Remove this warning and the `AC_CACHE_CHECK' when you 
adjust the code.])
 # ---------------------------------------------------------------
 AC_DEFUN([AC_CHECK_SIZEOF],
 [AS_LITERAL_IF([$1], [],
-              [AC_FATAL([$0: requires literal arguments])])dnl
-# The cast to long int works around a bug in the HP C Compiler
+              [m4_fatal([$0: requires literal arguments])])]dnl
+[# The cast to long int works around a bug in the HP C Compiler
 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
 # This bug is HP SR number 8606223364.
@@ -764,8 +764,8 @@ AC_DEFINE_UNQUOTED(AS_TR_CPP(sizeof_$1), 
$AS_TR_SH([ac_cv_sizeof_$1]),
 # -----------------------------------------------------
 AC_DEFUN([AC_CHECK_ALIGNOF],
 [AS_LITERAL_IF([$1], [],
-              [AC_FATAL([$0: requires literal arguments])])dnl
-# The cast to long int works around a bug in the HP C Compiler,
+              [m4_fatal([$0: requires literal arguments])])]dnl
+[# The cast to long int works around a bug in the HP C Compiler,
 # see AC_CHECK_SIZEOF for more information.
 _AC_CACHE_CHECK_INT([alignment of $1], [AS_TR_SH([ac_cv_alignof_$1])],
   [(long int) offsetof (ac__type_alignof_, y)],
@@ -829,12 +829,12 @@ you adjust the code.])
 # variables are not a valid argument.
 AC_DEFUN([AC_CHECK_MEMBER],
 [AS_LITERAL_IF([$1], [],
-              [AC_FATAL([$0: requires literal arguments])])dnl
-m4_bmatch([$1], [\.], ,
-        [m4_fatal([$0: Did not see any dot in `$1'])])dnl
-AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl
+              [AC_FATAL([$0: requires literal arguments])])]dnl
+[m4_if(m4_index([$1], [.]), [-1],
+       [m4_fatal([$0: Did not see any dot in `$1'])])]dnl
+[AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])]dnl
 dnl Extract the aggregate name, and the member name
-AC_CACHE_CHECK([for $1], [ac_Member],
+[AC_CACHE_CHECK([for $1], [ac_Member],
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
 [dnl AGGREGATE ac_aggr;
 static m4_bpatsubst([$1], [\..*]) ac_aggr;
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 149fff1..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
     ;;
@@ -1674,7 +1648,7 @@ m4_undivert([TEST_SCRIPT])dnl Insert the code here
   $at_traceoff
   $at_times_p && times >"$at_times_file"
 ) AS_MESSAGE_LOG_FD>&1 2>&1 | eval $at_tee_pipe
-at_status=`cat "$at_status_file"`
+read at_status <"$at_status_file"
 [#AT_STOP_]AT_ordinal
 m4_divert_pop([TEST_GROUPS])dnl Back to KILL.
 ])# AT_CLEANUP
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 6124065..7ba1adf 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[]])
 
 
@@ -942,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
@@ -1642,14 +1645,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 +1667,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.  ##
 ## ----------------- ##
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
 
 


hooks/post-receive
--
GNU Autoconf source repository




reply via email to

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