From ce861b2cb39ffb66c42212f018c379354ce4027a Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 3 Dec 2000 08:35:48 +0000 Subject: (parse_options): Use xstrtoumax to parse the byte and line offset. Give a better diagnostic when the requested offset is still representable but larger than OFF_T_MAX. --- src/tail.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/tail.c b/src/tail.c index 37dd5061a..7e2ff3b58 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1382,8 +1382,8 @@ parse_options (int argc, char **argv, { strtol_error s_err; - unsigned long int tmp_ulong; - s_err = xstrtoul (optarg, NULL, 10, &tmp_ulong, "bkm"); + uintmax_t n; + s_err = xstrtoumax (optarg, NULL, 10, &n, "bkm"); if (s_err == LONGINT_INVALID) { error (EXIT_FAILURE, 0, "%s: %s", optarg, @@ -1391,14 +1391,16 @@ parse_options (int argc, char **argv, ? _("invalid number of lines") : _("invalid number of bytes"))); } - if (s_err != LONGINT_OK || tmp_ulong > OFF_T_MAX) - { - error (EXIT_FAILURE, 0, - _("%s: %s is so large that it is not representable"), - optarg, - c == 'n' ? _("number of lines") : _("number of bytes")); - } - *n_units = (off_t) tmp_ulong; + + if (s_err != LONGINT_OK) + error (EXIT_FAILURE, 0, + _("%s: is so large that it is not representable"), optarg); + + if (OFF_T_MAX < n) + error (EXIT_FAILURE, 0, + _("%s is larger than the maximum file size on this system"), + optarg); + *n_units = (off_t) n; } break; -- cgit v1.2.3-54-g00ecf