expr: clarify error message

* src/expr.c (eval4, eval3): Clarify that expr expects integers,
and not the broader category of numbers.
* tests/misc/expr: Update test accordingly.
Suggested by Dan Jacobson.
This commit is contained in:
Eric Blake 2010-02-25 08:36:39 -07:00
parent 0b5bd805bd
commit 9a6c97eb29
2 changed files with 3 additions and 3 deletions

View File

@ -787,7 +787,7 @@ eval4 (bool evaluate)
if (evaluate)
{
if (!toarith (l) || !toarith (r))
error (EXPR_INVALID, 0, _("non-numeric argument"));
error (EXPR_INVALID, 0, _("non-integer argument"));
if (fxn != multiply && mpz_sgn (r->u.i) == 0)
error (EXPR_INVALID, 0, _("division by zero"));
((fxn == multiply ? mpz_mul
@ -824,7 +824,7 @@ eval3 (bool evaluate)
if (evaluate)
{
if (!toarith (l) || !toarith (r))
error (EXPR_INVALID, 0, _("non-numeric argument"));
error (EXPR_INVALID, 0, _("non-integer argument"));
(fxn == plus ? mpz_add : mpz_sub) (l->u.i, l->u.i, r->u.i);
}
freev (r);

View File

@ -70,7 +70,7 @@ my @Tests =
# This erroneously succeeded and output `3' before 2.0.12.
['fail-a', '3 + -', {ERR => "$prog: non-numeric argument\n"},
['fail-a', '3 + -', {ERR => "$prog: non-integer argument\n"},
{EXIT => 2}],
# This erroneously succeeded before 5.3.1.