From 9cb0d2f4481062ede2b1ff56907c7f20304ac4a8 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 16 Feb 2002 07:42:52 +0000 Subject: Include posixver.h. (usage): Document only the intersection of the old and new behaviors, to encourage portability. (short_options): Remove; no longer needed. (COMMON_SHORT_OPTIONS): New macro. (SEP_STRING_OPTION): Remove; no longer needed. All uses changed to back to the corresponding short options. (main): Parse options using POSIX 1003.1-2001 rules if conforming to that standard. Do not warn of obsolete options. --- src/pr.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'src/pr.c') diff --git a/src/pr.c b/src/pr.c index 7127d2e5d..f9a7601b1 100644 --- a/src/pr.c +++ b/src/pr.c @@ -319,6 +319,7 @@ #include "closeout.h" #include "error.h" #include "mbswidth.h" +#include "posixver.h" #include "xstrtol.h" /* The official name of this program (e.g., no `g' prefix). */ @@ -735,12 +736,11 @@ static int last_line = FALSE; enum { COLUMNS_OPTION = CHAR_MAX + 1, - PAGES_OPTION, - SEP_STRING_OPTION + PAGES_OPTION }; -static char const short_options[] = -"-0123456789abcdD:e::fFh:i::Jl:mn::N:o:rs::S" OPTARG_POSIX "tTvw:W:"; +#define COMMON_SHORT_OPTIONS \ + "-0123456789D:FJN:TW:abcde::fh:i::l:mn::o:rs::tvw:" static struct option const long_options[] = { @@ -762,7 +762,7 @@ static struct option const long_options[] = {"indent", required_argument, NULL, 'o'}, {"no-file-warnings", no_argument, NULL, 'r'}, {"separator", optional_argument, NULL, 's'}, - {"sep-string", optional_argument, NULL, SEP_STRING_OPTION}, + {"sep-string", optional_argument, NULL, 'S'}, {"omit-header", no_argument, NULL, 't'}, {"omit-pagination", no_argument, NULL, 'T'}, {"show-nonprinting", no_argument, NULL, 'v'}, @@ -856,7 +856,9 @@ main (int argc, char **argv) int old_w = FALSE; int old_s = FALSE; char **file_names; - bool posix_pedantic = (getenv ("POSIXLY_CORRECT") != NULL); + char const *short_options = (posix2_version () < 200112 + ? COMMON_SHORT_OPTIONS "S::" + : COMMON_SHORT_OPTIONS "S:"); program_name = argv[0]; setlocale (LC_ALL, ""); @@ -1023,12 +1025,6 @@ main (int argc, char **argv) separator_string (optarg); break; case 'S': - if (POSIX2_VERSION < 200112 && OBSOLETE_OPTION_WARNINGS - && ! optarg && ! posix_pedantic) - error (0, 0, - _("warning: `pr -S' is obsolete; use `pr --sep-string'")); - /* Fall through. */ - case SEP_STRING_OPTION: old_s = FALSE; /* Reset an additional input of -s, -S dominates -s */ col_sep_string = ""; @@ -1081,7 +1077,7 @@ main (int argc, char **argv) } if (! date_format) - date_format = (posix_pedantic + date_format = (getenv ("POSIXLY_CORRECT") ? dcgettext (NULL, "%b %e %H:%M %Y", LC_TIME) : "%Y-%m-%d %H:%M"); @@ -2833,14 +2829,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\ -s[CHAR] turns off line truncation of all 3 column\n\ options (-COLUMN|-a -COLUMN|-m) except -w is set\n\ "), stdout); - if (POSIX2_VERSION < 200112) - fputs (_("\ - -S[STRING], --sep-string[=STRING]\n\ - (`-S' with empty STRING is obsolete; use `--sep-string'.)\n\ -"), stdout); - else - fputs (_("\ - -S STRING, --sep-string[=STRING]\n\ + fputs (_("\ + -SSTRING, --sep-string[=STRING]\n\ "), stdout); fputs (_("\ separate columns by STRING,\n\ -- cgit v1.2.3-54-g00ecf