gawk

[old] Sed-like interface to the Gopher protocol
Log | Files | Refs | LICENSE

commit b254a79af61ceddda4610a523bfa5c616548d6e9
parent 837d0d6fb94d9922a2d22b59e290f4df3f3e5ff0
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Tue,  5 Jan 2021 03:13:39 -0800

Revise warg()

Return an error on too many arguments are given and reformat warnings.

Diffstat:
Mutil.c | 16+++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/util.c b/util.c @@ -53,15 +53,13 @@ strtorange(unsigned int *r, unsigned int min, unsigned int max, char const *s) int warg(int min, int max, int argc, char const **ap) { - if (max > 0 && argc > max) { - warn(0, "%s: '%s' and %d more arguments unused.", - *ap, ap[max], argc - (max + 1)); - } else if (argc < min) { - warn(0, "%s: Not enough arguments.", *ap); - return 1; - } - - return 0; + if (max > 0 && argc > max) + warn(0, "'%s': '%s'... unused.", *ap, ap[max]); + else if (min > 0 && argc < min) + warn(0, "'%s': Not enough arguments.", *ap); + else + return 0; + return 1; } int