From: Jim Meyering Date: Sun, 3 Dec 2000 08:35:48 +0000 (+0000) Subject: (parse_options): Use xstrtoumax to parse the byte and line X-Git-Tag: TEXTUTILS-2_0_9~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ce861b2cb39ffb66c42212f018c379354ce4027a;p=thirdparty%2Fcoreutils.git (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. --- diff --git a/src/tail.c b/src/tail.c index 37dd5061a2..7e2ff3b58f 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;