summaryrefslogtreecommitdiff
path: root/src/sort.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2006-12-13 22:03:54 +0100
committerJim Meyering <jim@meyering.net>2006-12-13 22:03:54 +0100
commitec95137cc376119f634610a7683a296fc7b78ea4 (patch)
tree52d315f085e18022db44722d7e58f3e4635d84d9 /src/sort.c
parentae3ee95eb8372ec5947e3c790c6ea77bc703c160 (diff)
downloadcoreutils-ec95137cc376119f634610a7683a296fc7b78ea4.tar.xz
Remove some arbitrary restrictions on size fields,
so that commands like "sort -k 18446744073709551616" no longer fail merely because 18446744073709551616 doesn't fit in uintmax_t. The trick is that these fields can all be treated as effectively infinity; their exact values don't matter, since no internal buffer can be that long. * src/join.c (string_to_join_field): Verify that SIZE_MAX <= ULONG_MAX if the code assumes this. Silently truncate too-large values to SIZE_MAX, as the remaining code will do the right thing in this case. * src/sort.c (parse_field_count): Likewise. * src/uniq.c (size_opt, main): Likewise. * tests/join/Test.pm (bigfield): New test. * tests/sort/Test.pm (bigfield): New test. * tests/uniq/Test.pm (121): New test. Signed-off-by: Jim Meyering <jim@meyering.net>
Diffstat (limited to 'src/sort.c')
-rw-r--r--src/sort.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/sort.c b/src/sort.c
index feaf5a5bc..f03237cb3 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -2170,7 +2170,8 @@ check_ordering_compatibility (void)
/* Parse the leading integer in STRING and store the resulting value
(which must fit into size_t) into *VAL. Return the address of the
- suffix after the integer. If MSGID is NULL, return NULL after
+ suffix after the integer. If the value is too large, silently
+ substitute SIZE_MAX. If MSGID is NULL, return NULL after
failure; otherwise, report MSGID and exit on failure. */
static char const *
@@ -2189,10 +2190,8 @@ parse_field_count (char const *string, size_t *val, char const *msgid)
/* Fall through. */
case LONGINT_OVERFLOW:
case LONGINT_OVERFLOW | LONGINT_INVALID_SUFFIX_CHAR:
- if (msgid)
- error (SORT_FAILURE, 0, _("%s: count `%.*s' too large"),
- _(msgid), (int) (suffix - string), string);
- return NULL;
+ *val = SIZE_MAX;
+ break;
case LONGINT_INVALID:
if (msgid)