diff options
author | Jim Meyering <jim@meyering.net> | 2000-12-03 08:35:48 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-12-03 08:35:48 +0000 |
commit | ce861b2cb39ffb66c42212f018c379354ce4027a (patch) | |
tree | d7a27c066b76b6a31d532784b9201a596b36b9be /src | |
parent | 67ec78d1880e8b3c070bd1a3529c10e7894b4b62 (diff) | |
download | coreutils-ce861b2cb39ffb66c42212f018c379354ce4027a.tar.xz |
(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.
Diffstat (limited to 'src')
-rw-r--r-- | src/tail.c | 22 |
1 files changed, 12 insertions, 10 deletions
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; |