From 8232744d27936bf57bbbcd790e0b8013ce08eae7 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 16 Feb 2002 07:39:17 +0000 Subject: [PATCH] Include posixver.h. (usage): Document only the intersection of the old and new behaviors, to encourage portability. (main): Revert to previous behavior, except report an error and exit if the obsolete syntax is used and if conforming to the new standard. --- src/head.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/head.c b/src/head.c index dd39cbd..23c29f5 100644 --- a/src/head.c +++ b/src/head.c @@ -32,6 +32,7 @@ #include "system.h" #include "closeout.h" #include "error.h" +#include "posixver.h" #include "xstrtol.h" #include "safe-read.h" @@ -111,12 +112,6 @@ Mandatory arguments to long options are mandatory for short options too.\n\ \n\ SIZE may have a multiplier suffix: b for 512, k for 1K, m for 1 Meg.\n\ "), stdout); - if (POSIX2_VERSION < 200112) - fputs (_("\ -\n\ -(obsolete) If -VALUE is used as first OPTION, same as -c VALUE when one of\n\ -multipliers bkm follows concatenated, else same as -n VALUE.\n\ -"), stdout); puts (_("\nReport bugs to .")); } exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE); @@ -297,8 +292,7 @@ main (int argc, char **argv) print_headers = 0; - if (POSIX2_VERSION < 200112 - && 1 < argc && argv[1][0] == '-' && ISDIGIT (argv[1][1])) + if (1 < argc && argv[1][0] == '-' && ISDIGIT (argv[1][1])) { char *a = argv[1]; char *n_string = ++a; @@ -348,13 +342,15 @@ main (int argc, char **argv) } } - if (OBSOLETE_OPTION_WARNINGS && ! getenv ("POSIXLY_CORRECT")) - error (0, 0, - _("warning: `head -%s' is obsolete; use `head -%c %.*s%.*s%s'"), - n_string, count_lines ? 'n' : 'c', - (int) (end_n_string - n_string), n_string, - multiplier_char != 0, &multiplier_char, - header_mode_option[header_mode]); + if (200112 <= posix2_version ()) + { + error (0, 0, _("`-%s' option is obsolete; use `-%c %.*s%.*s%s'"), + n_string, count_lines ? 'n' : 'c', + (int) (end_n_string - n_string), n_string, + multiplier_char != 0, &multiplier_char, + header_mode_option[header_mode]); + usage (EXIT_FAILURE); + } /* Append the multiplier character (if any) onto the end of the digit string. Then add NUL byte if necessary. */ -- 2.7.4