From a7f5d3d6d671bb4e9117b1f72971a19eed135fed Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 23 Feb 2016 01:03:55 -0800 Subject: 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. --- src/tail.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/tail.c') diff --git a/src/tail.c b/src/tail.c index 2a72a93f0..caa54076a 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1981,7 +1981,6 @@ parse_obsolete_option (int argc, char * const *argv, uintmax_t *n_units) const char *p; const char *n_string; const char *n_string_end; - bool obsolete_usage; int default_count = DEFAULT_N_LINES; bool t_from_start; bool t_count_lines = true; @@ -1994,7 +1993,9 @@ parse_obsolete_option (int argc, char * const *argv, uintmax_t *n_units) || (3 <= argc && argc <= 4 && STREQ (argv[2], "--")))) return false; - obsolete_usage = (posix2_version () < 200112); + int posix_ver = posix2_version (); + bool obsolete_usage = posix_ver < 200112; + bool traditional_usage = obsolete_usage || 200809 <= posix_ver; p = argv[1]; switch (*p++) @@ -2003,8 +2004,8 @@ parse_obsolete_option (int argc, char * const *argv, uintmax_t *n_units) return false; case '+': - /* Leading "+" is a file name in the non-obsolete form. */ - if (!obsolete_usage) + /* Leading "+" is a file name in the standard form. */ + if (!traditional_usage) return false; t_from_start = true; @@ -2014,7 +2015,7 @@ parse_obsolete_option (int argc, char * const *argv, uintmax_t *n_units) /* In the non-obsolete form, "-" is standard input and "-c" requires an option-argument. The obsolete multidigit options are supported as a GNU extension even when conforming to - POSIX 1003.1-2001, so don't complain about them. */ + POSIX 1003.1-2001 or later, so don't complain about them. */ if (!obsolete_usage && !p[p[0] == 'c']) return false; -- cgit v1.2.3-54-g00ecf