Age | Commit message (Collapse) | Author |
|
(looks_like_integer): New function.
(toarith): Use it. Also, use xstrtoimax rather than rolling our
own diagnostics.
(eval2): Don't look for trouble if !evaluate; this simplifies things.
Compare numbers using string comparison, so that overflow is
not possible.
|
|
|
|
|
|
|
|
|
|
|
|
rather than suffering silently.
Before, expr would silently overflow and wrap around:
$ expr 9223372036854775808 = 0 # $(echo 2^63|bc)
1
Now it detects the problem and exits nonzero:
$ ./expr $(echo 2^63|bc) = 0
./expr: 9223372036854775808: integer is too large
|
|
by Debian 5.2.1-2.
|
|
reference to obsolescent macro XMALLOC.
All uses replaced by xmalloc and free.
|
|
|
|
too few operands ("missing operand after `xxx'") or
too many operands ("extra operand `xxx'").
Include "quote.h" and/or "error.h" if it wasn't already being included.
|
|
|
|
Accept a bool argument specifying whether to evaluate the
expression. This is to allow short-circuit evaluation. All
callers changed.
(null): Report that a string is zero even if it has
a form like "-0" or "00".
(eval1, eval): Use short-circuit evaluation for | and &.
(eval): Return 0 if both arguments are null or zero, instead
of returning the first argument.
|
|
(main): Use initialize_exit_failure rather than
setting exit_failure directly; this optimizes away redundant assignments.
(EXPR_FAILURE): Renamed from EXPR_ERROR, for
consistency with the other programs' naming conventions.
All uses changed.
|
|
parse_long_options, so that it works even on systems for which
sizeof char* != sizeof int.
|
|
of 2003-09-19. Now, AUTHORS is a comma-separated list of strings.
Update the call to parse_long_options so that `AUTHORS, NULL' are the
last parameters.
* src/true.c (main): Append NULL to version_etc argument list.
* src/sys2.h (case_GETOPT_VERSION_CHAR): Likewise.
|
|
Begin each WRITTEN_BY string with `Written by ' and end it with `.'.
Mark each WRITTEN_BY string as translatable.
|
|
|
|
the call to parse_long_options so that `AUTHORS, NULL' are the last parameters.
|
|
Don't include closeout.h.
|
|
(EXPR_INVALID, EXPR_ERROR): New constants.
(nomoreargs, null, toarith, nextarg): Return bool, not int.
(syntax_error): New function, exiting with status 2. Use it
insteading of printing "syntax error" ourselves.
(main): Initialize exit_failure to EXPR_ERROR.
Exit with EXPR_INVALID on syntax error (too few arguments).
(nextarg): Use strcmp, not strcoll; strcoll might return
an undesirable 0, or might fail.
(docolon, eval4, eval3): Exit with status 3 on invalid argument type
or other such error.
(eval2): Report an error if strcoll fails in a string comparison.
|
|
|
|
|
|
|
|
xrealloc, and xcalloc return values and of xrealloc's first argument.
|
|
|
|
|
|
|
|
`exit (1)' to `exit (EXIT_FAILURE)', and
`usage (1)' to `usage (EXIT_FAILURE)'.
|
|
|
|
|
|
instead of hard-coding --help and --version descriptions.
Split --help output into smaller pieces.
Use fputs, not printf.
|
|
|
|
|
|
(main): Do not worry about POSIXLY_CORRECT, as it's OK for
expr to have options (so long as they do not begin with digits).
|
|
All callers changed.
|
|
(eval2): Do comparisons as strings first, before trying to convert to
integer. This avoids loss of information and wrong result, e.g. for
"expr '00' '<' '0!'", where you don't want to convert '00' to '0'.
|
|
(cmpf, less_than, less_equal, equal, not_equal, greater_equal,
greater_than, arithf, arithdivf, plus, minus, multiply, divide, mod):
Remove.
(eval4, eval3, eval2): Rewrite to avoid the need for the above macros
and functions.
|
|
|
|
|
|
the value of integer expressions.
(struct valinfo.i): Now intmax_t, not int.
(docolon, int_value, str_value, isstring, nextarg, toarith,
freev, tostring, trace): Remove unnecessary forward decls.
(int_value, printv, tostring, toarith, arithf, arithdivf, docolon,
eval6, eval4, eval3): Do integer arithmetic using intmax_t, not int.
(docolon): Don't assume size_t fits in int.
|
|
(main): Call atexit with close_stdout.
|
|
(NEW): Redefine in terms of XMALLOC.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|