diff options
author | Jim Meyering <jim@meyering.net> | 2002-02-16 07:31:27 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2002-02-16 07:31:27 +0000 |
commit | 1183723f2565d3aa1918de2e1ce41322db3076d4 (patch) | |
tree | 66c83189b1dae5f83c60ef9659bef7ce347f08e4 | |
parent | 014c8f4a029421bada37d5950188d51f31263388 (diff) | |
download | coreutils-1183723f2565d3aa1918de2e1ce41322db3076d4.tar.xz |
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.
-rw-r--r-- | src/fold.c | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/src/fold.c b/src/fold.c index ea6f98729..084258bd5 100644 --- a/src/fold.c +++ b/src/fold.c @@ -26,6 +26,7 @@ #include "system.h" #include "closeout.h" #include "error.h" +#include "posixver.h" #include "xstrtol.h" /* The official name of this program (e.g., no `g' prefix). */ @@ -80,10 +81,6 @@ Mandatory arguments to long options are mandatory for short options too.\n\ -s, --spaces break at spaces\n\ -w, --width=WIDTH use WIDTH columns instead of 80\n\ "), stdout); - if (POSIX2_VERSION < 200112) - fputs (_("\ - -WIDTH (obsolete) same as -w WIDTH\n\ -"), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); puts (_("\nReport bugs to <bug-textutils@gnu.org>.")); @@ -250,29 +247,29 @@ main (int argc, char **argv) break_spaces = count_bytes = have_read_stdin = 0; - /* If obsolete, turn any numeric options into -w options. */ - if (POSIX2_VERSION < 200112) - for (i = 1; i < argc; i++) - { - char const *a = argv[i]; - if (a[0] == '-') - { - if (a[1] == '-' && ! a[2]) - break; - if (ISDIGIT (a[1])) - { - char *s = xmalloc (strlen (a) + 2); - s[0] = '-'; - s[1] = 'w'; - strcpy (s + 2, a + 1); - argv[i] = s; - if (OBSOLETE_OPTION_WARNINGS && ! getenv ("POSIXLY_CORRECT")) - error (0, 0, - _("warning: `fold %s' is obsolete; use `fold -w %s'"), - a, a + 1); - } - } - } + /* Turn any numeric options into -w options. */ + for (i = 1; i < argc; i++) + { + char const *a = argv[i]; + if (a[0] == '-') + { + if (a[1] == '-' && ! a[2]) + break; + if (ISDIGIT (a[1])) + { + char *s = xmalloc (strlen (a) + 2); + s[0] = '-'; + s[1] = 'w'; + strcpy (s + 2, a + 1); + argv[i] = s; + if (200112 <= posix2_version ()) + { + error (0, 0, _("`%s' option is obsolete; use `%s'"), a, s); + usage (EXIT_FAILURE); + } + } + } + } while ((optc = getopt_long (argc, argv, "bsw:", longopts, NULL)) != -1) { |