]> git.ipfire.org Git - thirdparty/coreutils.git/commit
all: improve parsing of numeric arguments
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 22 Oct 2019 21:55:24 +0000 (14:55 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 22 Oct 2019 22:04:43 +0000 (15:04 -0700)
commit04b136e29853a53a7885371526c4616303c39bcc
tree41a421cefc35d11b72537a37bfa2eeeb42a18c3b
parented2db6886bc4dfa5be7c0a3a72a45024fdafe29f
all: improve parsing of numeric arguments

This addresses a longstanding "update all callers" FIXME in
lib/xstrtol.c, by having programs check that numbers do not
have unknown suffixes.  The problem was also reported for
'shuf' by my student Maggie Huang while reimplementing a shuf
subset in Python as an exercise in UCLA Computer Science 35L:
https://web.cs.ucla.edu/classes/fall19/cs35L/assign/assign3.html
This patch also improves the portability of the code to unusual
platforms where ULONG_MAX < SIZE_MAX.
* NEWS: Mention user-visible changes.
* src/chgrp.c (parse_group):
* src/chroot.c (parse_additional_groups):
* src/du.c (main):
* src/install.c (get_ids):
* src/join.c (string_to_join_field):
* src/ls.c (decode_switches):
* src/md5sum.c (split_3):
* src/shuf.c (main):
* src/sort.c (specify_nthreads):
* src/uniq.c (size_opt, main):
Use uintmax_t instead of unsigned long, for portability
to oddball platforms where unsigned long is not wide enough.
* src/du.c (main):
* src/expr.c (mpz_init_set_str) [!HAVE_GMP]:
* src/install.c (get_ids):
* src/ls.c (decode_switches):
* src/mknod.c (main):
* src/ptx.c (main):
* src/shuf.c (main):
* src/sort.c (specify_nmerge, specify_nthreads):
Reject numbers with suffixes.
* src/md5sum.c (split_3): Simplify.
14 files changed:
NEWS
src/chgrp.c
src/chroot.c
src/du.c
src/expr.c
src/install.c
src/join.c
src/ls.c
src/md5sum.c
src/mknod.c
src/ptx.c
src/shuf.c
src/sort.c
src/uniq.c