diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-02-23 01:03:55 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-02-23 01:05:10 -0800 |
commit | a7f5d3d6d671bb4e9117b1f72971a19eed135fed (patch) | |
tree | 2f993165a5edfc026e631e17ad3506475ae54de6 /src/uniq.c | |
parent | 4c1995f1b673b0e1eae73a9db4e28016b86dee9e (diff) | |
download | coreutils-a7f5d3d6d671bb4e9117b1f72971a19eed135fed.tar.xz |
all: be less strict about usage if POSIX 2008
sort, tail, and uniq now support traditional usage like 'sort +2'
and 'tail +10' on systems conforming to POSIX 1003.1-2008 and later.
* NEWS: Document this.
* doc/coreutils.texi (Standards conformance, tail invocation)
(sort invocation, uniq invocation, touch invocation):
Document new behavior, or behavior's dependence on POSIX 1003.1-2001.
* src/sort.c (struct keyfield.traditional_used):
Rename from obsolete_used, since implementations are now allowed
to support it. All uses changed.
(main): Allow traditional usage if _POSIX2_VERSION is 200809.
* src/tail.c (parse_obsolete_option): Distinguish between
traditional usage (which POSIX 2008 and later allows) and obsolete
(which it still does not).
* src/uniq.c (strict_posix2): New function.
(main): Allow traditional usage if _POSIX2_VERSION is 200809.
* tests/misc/tail.pl: Test for new behavior.
Diffstat (limited to 'src/uniq.c')
-rw-r--r-- | src/uniq.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/uniq.c b/src/uniq.c index 0e118da9d..896ce938f 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -226,6 +226,13 @@ Also, comparisons honor the rules specified by 'LC_COLLATE'.\n\ exit (status); } +static bool +strict_posix2 (void) +{ + int posix_ver = posix2_version (); + return 200112 <= posix_ver && posix_ver < 200809; +} + /* Convert OPT to size_t, reporting an error using MSGID if OPT is invalid. Silently convert too-large values to SIZE_MAX. */ @@ -533,7 +540,7 @@ main (int argc, char **argv) { unsigned long int size; if (optarg[0] == '+' - && posix2_version () < 200112 + && ! strict_posix2 () && xstrtoul (optarg, NULL, 10, &size, "") == LONGINT_OK && size <= SIZE_MAX) skip_chars = size; |