diff options
author | Jim Meyering <jim@meyering.net> | 2002-02-02 07:58:50 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2002-02-02 07:58:50 +0000 |
commit | f87b5cab0c8f56f9a055cfaf212a51ca56668b18 (patch) | |
tree | 2a3e84548e5f4715f2d01ac8d2198e51bc722a39 | |
parent | 33f9d106bc584bd5135b40efd42bed24604c30b4 (diff) | |
download | coreutils-f87b5cab0c8f56f9a055cfaf212a51ca56668b18.tar.xz |
Add more support for POSIX 1003.1-2001, which requires removal for
support of obsolete "-N" option syntax in expand, head, fold,
split, tail, unexpand, uniq, and which prohibits options with
optional arguments in od and pr.
(main): Check for obsolete options.
(main): Fix bug: -- -N was treated as -N --.
-rw-r--r-- | src/fold.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/fold.c b/src/fold.c index 8854171df..ea6f98729 100644 --- a/src/fold.c +++ b/src/fold.c @@ -1,5 +1,5 @@ /* fold -- wrap each input line to fit in specified width. - Copyright (C) 91, 1995-2001 Free Software Foundation, Inc. + Copyright (C) 91, 1995-2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -80,6 +80,10 @@ 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>.")); @@ -246,20 +250,29 @@ main (int argc, char **argv) break_spaces = count_bytes = have_read_stdin = 0; - /* Turn any numeric options into -w options. */ - for (i = 1; i < argc; i++) - { - if (argv[i][0] == '-' && ISDIGIT (argv[i][1])) - { - char *s; - - s = xmalloc (strlen (argv[i]) + 2); - s[0] = '-'; - s[1] = 'w'; - strcpy (s + 2, argv[i] + 1); - argv[i] = s; - } - } + /* 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); + } + } + } while ((optc = getopt_long (argc, argv, "bsw:", longopts, NULL)) != -1) { |