** Changes in behavior
+ Several programs now check that numbers end properly. For example,
+ 'du -d 1x' now reports an error instead of silently ignoring the 'x'.
+ Affected programs and options include du -d, expr's numeric operands
+ on non-GMP builds, install -g and -o, ls's TABSIZE environment
+ variable, mknod b and c, ptx -g and -w, shuf -n, and sort --batch-size
+ and --parallel.
+
date now parses military time zones in accordance with common usage:
"A" to "M" are equivalent to UTC+1 to UTC+12
"N" to "Y" are equivalent to UTC-1 to UTC-12
gid = grp->gr_gid;
else
{
- unsigned long int tmp;
- if (! (xstrtoul (name, NULL, 10, &tmp, "") == LONGINT_OK
+ uintmax_t tmp;
+ if (! (xstrtoumax (name, NULL, 10, &tmp, "") == LONGINT_OK
&& tmp <= GID_T_MAX))
die (EXIT_FAILURE, 0, _("invalid group: %s"),
quote (name));
for (tmp = strtok (buffer, ","); tmp; tmp = strtok (NULL, ","))
{
struct group *g;
- unsigned long int value;
+ uintmax_t value;
- if (xstrtoul (tmp, NULL, 10, &value, "") == LONGINT_OK && value <= MAXGID)
+ if (xstrtoumax (tmp, NULL, 10, &value, "") == LONGINT_OK
+ && value <= MAXGID)
{
while (isspace (to_uchar (*tmp)))
tmp++;
case 'd': /* --max-depth=N */
{
- unsigned long int tmp_ulong;
- if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) == LONGINT_OK
- && tmp_ulong <= SIZE_MAX)
+ uintmax_t tmp;
+ if (xstrtoumax (optarg, NULL, 0, &tmp, "") == LONGINT_OK
+ && tmp <= SIZE_MAX)
{
max_depth_specified = true;
- max_depth = tmp_ulong;
+ max_depth = tmp;
}
else
{
static int
mpz_init_set_str (mpz_t z, char *s, int base)
{
- return xstrtoimax (s, NULL, base, z, NULL) == LONGINT_OK ? 0 : -1;
+ return xstrtoimax (s, NULL, base, z, "") == LONGINT_OK ? 0 : -1;
}
static void
mpz_add (mpz_t r, mpz_t a0, mpz_t b0)
pw = getpwnam (owner_name);
if (pw == NULL)
{
- unsigned long int tmp;
- if (xstrtoul (owner_name, NULL, 0, &tmp, NULL) != LONGINT_OK
+ uintmax_t tmp;
+ if (xstrtoumax (owner_name, NULL, 0, &tmp, "") != LONGINT_OK
|| UID_T_MAX < tmp)
die (EXIT_FAILURE, 0, _("invalid user %s"),
quote (owner_name));
gr = getgrnam (group_name);
if (gr == NULL)
{
- unsigned long int tmp;
- if (xstrtoul (group_name, NULL, 0, &tmp, NULL) != LONGINT_OK
+ uintmax_t tmp;
+ if (xstrtoumax (group_name, NULL, 0, &tmp, "") != LONGINT_OK
|| GID_T_MAX < tmp)
die (EXIT_FAILURE, 0, _("invalid group %s"),
quote (group_name));
string_to_join_field (char const *str)
{
size_t result;
- unsigned long int val;
- verify (SIZE_MAX <= ULONG_MAX);
+ uintmax_t val;
- strtol_error s_err = xstrtoul (str, NULL, 10, &val, "");
+ strtol_error s_err = xstrtoumax (str, NULL, 10, &val, "");
if (s_err == LONGINT_OVERFLOW || (s_err == LONGINT_OK && SIZE_MAX < val))
val = SIZE_MAX;
else if (s_err != LONGINT_OK || val == 0)
tabsize = 8;
if (p)
{
- unsigned long int tmp_ulong;
- if (xstrtoul (p, NULL, 0, &tmp_ulong, NULL) == LONGINT_OK
- && tmp_ulong <= SIZE_MAX)
- {
- tabsize = tmp_ulong;
- }
+ uintmax_t tmp;
+ if (xstrtoumax (p, NULL, 0, &tmp, "") == LONGINT_OK
+ && tmp <= SIZE_MAX)
+ tabsize = tmp;
else
- {
- error (0, 0,
- _("ignoring invalid tab size in environment variable TABSIZE: %s"),
- quote (p));
- }
+ error (0, 0,
+ _("ignoring invalid tab size in environment variable TABSIZE:"
+ " %s"),
+ quote (p));
}
}
ptrdiff_t algo = argmatch (algo_name, algorithm_out_string, NULL, 0);
if (algo < 0)
return false;
- else
- b2_algorithm = algo;
+ b2_algorithm = algo;
if (openssl_format)
s[--i] = '(';
+ b2_length = blake2_max_len[b2_algorithm] * 8;
if (length_specified)
{
- unsigned long int tmp_ulong;
- if (xstrtoul (s + i, NULL, 0, &tmp_ulong, NULL) == LONGINT_OK
- && 0 < tmp_ulong && tmp_ulong <= blake2_max_len[b2_algorithm] * 8
- && tmp_ulong % 8 == 0)
- b2_length = tmp_ulong;
- else
+ uintmax_t length;
+ char *siend;
+ if (! (xstrtoumax (s + i, &siend, 0, &length, NULL) == LONGINT_OK
+ && 0 < length && length <= b2_length
+ && length % 8 == 0))
return false;
- while (ISDIGIT (s[i]))
- ++i;
+ i = siend - s;
+ b2_length = length;
}
- else
- b2_length = blake2_max_len[b2_algorithm] * 8;
digest_hex_bytes = b2_length / 4;
#endif
uintmax_t i_major, i_minor;
dev_t device;
- if (xstrtoumax (s_major, NULL, 0, &i_major, NULL) != LONGINT_OK
+ if (xstrtoumax (s_major, NULL, 0, &i_major, "") != LONGINT_OK
|| i_major != (major_t) i_major)
die (EXIT_FAILURE, 0,
_("invalid major device number %s"), quote (s_major));
- if (xstrtoumax (s_minor, NULL, 0, &i_minor, NULL) != LONGINT_OK
+ if (xstrtoumax (s_minor, NULL, 0, &i_minor, "") != LONGINT_OK
|| i_minor != (minor_t) i_minor)
die (EXIT_FAILURE, 0,
_("invalid minor device number %s"), quote (s_minor));
case 'g':
{
intmax_t tmp;
- if (! (xstrtoimax (optarg, NULL, 0, &tmp, NULL) == LONGINT_OK
+ if (! (xstrtoimax (optarg, NULL, 0, &tmp, "") == LONGINT_OK
&& 0 < tmp && tmp <= PTRDIFF_MAX))
die (EXIT_FAILURE, 0, _("invalid gap width: %s"),
quote (optarg));
case 'w':
{
intmax_t tmp;
- if (! (xstrtoimax (optarg, NULL, 0, &tmp, NULL) == LONGINT_OK
+ if (! (xstrtoimax (optarg, NULL, 0, &tmp, "") == LONGINT_OK
&& 0 < tmp && tmp <= PTRDIFF_MAX))
die (EXIT_FAILURE, 0, _("invalid line width: %s"),
quote (optarg));
case 'n':
{
- unsigned long int argval;
- strtol_error e = xstrtoul (optarg, NULL, 10, &argval, NULL);
+ uintmax_t argval;
+ strtol_error e = xstrtoumax (optarg, NULL, 10, &argval, "");
if (e == LONGINT_OK)
head_lines = MIN (head_lines, argval);
{
uintmax_t n;
struct rlimit rlimit;
- enum strtol_error e = xstrtoumax (s, NULL, 10, &n, NULL);
+ enum strtol_error e = xstrtoumax (s, NULL, 10, &n, "");
/* Try to find out how many file descriptors we'll be able
to open. We need at least nmerge + 3 (STDIN_FILENO,
static size_t
specify_nthreads (int oi, char c, char const *s)
{
- unsigned long int nthreads;
- enum strtol_error e = xstrtoul (s, NULL, 10, &nthreads, "");
+ uintmax_t nthreads;
+ enum strtol_error e = xstrtoumax (s, NULL, 10, &nthreads, "");
if (e == LONGINT_OVERFLOW)
return SIZE_MAX;
if (e != LONGINT_OK)
static size_t
size_opt (char const *opt, char const *msgid)
{
- unsigned long int size;
- verify (SIZE_MAX <= ULONG_MAX);
+ uintmax_t size;
- switch (xstrtoul (opt, NULL, 10, &size, ""))
+ switch (xstrtoumax (opt, NULL, 10, &size, ""))
{
case LONGINT_OK:
case LONGINT_OVERFLOW:
{
case 1:
{
- unsigned long int size;
+ uintmax_t size;
if (optarg[0] == '+'
&& ! strict_posix2 ()
- && xstrtoul (optarg, NULL, 10, &size, "") == LONGINT_OK
+ && xstrtoumax (optarg, NULL, 10, &size, "") == LONGINT_OK
&& size <= SIZE_MAX)
skip_chars = size;
else if (nfiles == 2)