@defmac m4_count (@var{arg}, @dots{})
@msindex{count}
-This macro returns the decimal count of the number of arguments it was
-passed.
+This macro returns the number of arguments it was passed.
@end defmac
@defmac m4_curry (@var{macro}, @var{arg}@dots{})
@subsection Arithmetic computation in M4
The following macros facilitate integer arithmetic operations.
+
Where a parameter is documented as taking an arithmetic expression, you
can use anything that can be parsed by @code{m4_eval}.
+Any other numeric parameter should consist of an optional sign followed
+by one or more decimal digits; it is treated as a decimal integer.
+
+Macros that expand to a number do so as either @samp{0}, or an optional
+@samp{-} followed by a nonzero decimal digit followed by zero or more
+decimal digits.
+
+Due to @command{m4} limitations, arithmetic expressions and numeric
+parameters should use only numbers that fit into a 32-bit signed
+integer.
@defmac m4_cmp (@var{expr-1}, @var{expr-2})
@msindex{cmp}
@defmac m4_max (@var{arg}, @dots{})
@msindex{max}
-This macro was introduced in Autoconf 2.62. Expand to the decimal value
+This macro was introduced in Autoconf 2.62. Expand to the value
of the maximum arithmetic expression among all the arguments.
@end defmac
@defmac m4_min (@var{arg}, @dots{})
@msindex{min}
-This macro was introduced in Autoconf 2.62. Expand to the decimal value
+This macro was introduced in Autoconf 2.62. Expand to the value
of the minimum arithmetic expression among all the arguments.
@end defmac
@var{var}. 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
+must occur as separate shell arguments and with proper quoting;
+the only operators supported are @samp{*}, @samp{/}, @samp{%}, binary
+@samp{+}, binary @samp{-}, @samp{>}, @samp{>=}, @samp{<}, @samp{<=},
+@samp{!=}, @samp{&}, and @samp{|};
+all variables containing numbers must be expanded prior to the computation;
+the first shell argument must not start with @samp{-};
+and each number must be an optional @samp{-} followed by one or more
+decimal digits, where the first digit is nonzero if there is more than
+one digit. In the following example, this snippet
will print @samp{(2+3)*4 == 20}.
@example
speedup in script execution; but testing for support requires
@command{eval} 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
+arguments are decimal integers without leading zeros, and all
operators are properly quoted and appear as distinct arguments:
@example
@command{hexdump} program can be used instead.
In some versions of some operating systems derived from Solaris 11,
-@command{od} prints decimal byte values padded with zeroes rather than
+@command{od} prints decimal byte values padded with zeros rather than
with spaces:
@smallexample
# AS_FUNCTION_DESCRIBE(NAME, [ARGS], DESCRIPTION, [WRAP-COLUMN = 79])
# -------------------------------------------------------------------
# Output a shell comment describing NAME and its arguments ARGS, then
-# a separator line, then the DESCRIPTION wrapped at a decimal
-# WRAP-COLUMN. The output resembles:
+# a separator line, then the DESCRIPTION wrapped at WRAP-COLUMN.
+# The output resembles:
# # NAME ARGS
# # ---------
# # Wrapped DESCRIPTION text
#
# Format a help string so that it looks pretty when the user executes
# "script --help". This macro takes up to four arguments, a
-# "left hand side" (LHS), a "right hand side" (RHS), a decimal
+# "left hand side" (LHS), a "right hand side" (RHS),
# INDENT-COLUMN which is the column where wrapped lines should begin
-# (the default of 26 is recommended), and a decimal WRAP-COLUMN which is
+# (the default of 26 is recommended), and WRAP-COLUMN which is
# the column where lines should wrap (the default of 79 is recommended).
# LHS is expanded, RHS is not.
#
# 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 occurring 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.
+# forks. Because EXPR might be evaluated via either $((...)) or the
+# 'expr' command, EXPR's syntax is limited; see the Autoconf manual.
m4_defun_init([AS_VAR_ARITH],
[_AS_DETECT_SUGGESTED([_AS_VAR_ARITH_WORKS])]dnl
[AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])],