diff options
author | Jim Meyering <jim@meyering.net> | 2002-02-16 08:04:12 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2002-02-16 08:04:12 +0000 |
commit | e1ce35d51f7a0136c187978559dd5d834b3192c9 (patch) | |
tree | b3297ba3814075de46917715c0fc5bc6aba09be5 /src | |
parent | 12549a6db82c68b33e02ad863b91cc83b1e67249 (diff) | |
download | coreutils-e1ce35d51f7a0136c187978559dd5d834b3192c9.tar.xz |
Include posixver.h.
(usage): Document only the intersection of the old and new behaviors,
to encourage portability.
(shortopts): Remove; no longer needed.
(main): Parse options using POSIX 1003.1-2001 rules if
conforming to that standard. Do not warn of obsolete options.
Diffstat (limited to 'src')
-rw-r--r-- | src/split.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/split.c b/src/split.c index 5634019de..2cc305589 100644 --- a/src/split.c +++ b/src/split.c @@ -32,6 +32,7 @@ #include "dirname.h" #include "error.h" #include "full-write.h" +#include "posixver.h" #include "safe-read.h" #include "xstrtol.h" @@ -71,12 +72,6 @@ static int output_desc; output file is opened. */ static int verbose; -static char const shortopts[] = "a:b:l:C:" -#if POSIX2_VERSION < 200112 -"0123456789" -#endif -; - static struct option const longopts[] = { {"bytes", required_argument, NULL, 'b'}, @@ -115,10 +110,6 @@ Mandatory arguments to long options are mandatory for short options too.\n\ -C, --line-bytes=SIZE put at most SIZE bytes of lines per output file\n\ -l, --lines=NUMBER put NUMBER lines per output file\n\ "), DEFAULT_SUFFIX_LENGTH); - if (POSIX2_VERSION < 200112) - fputs (_("\ - -NUMBER (obsolete) same as -l NUMBER\n\ -"), stdout); fputs (_("\ --verbose print a diagnostic to standard error just\n\ before each output file is opened\n\ @@ -400,7 +391,7 @@ main (int argc, char **argv) int this_optind = optind ? optind : 1; long int tmp_long; - c = getopt_long (argc, argv, shortopts, longopts, NULL); + c = getopt_long (argc, argv, "0123456789C:a:b:l:", longopts, NULL); if (c == -1) break; @@ -468,7 +459,6 @@ main (int argc, char **argv) accum = (int) tmp_long; break; -#if POSIX2_VERSION < 200112 case '0': case '1': case '2': @@ -490,7 +480,6 @@ main (int argc, char **argv) split_type = type_digits; accum = accum * 10 + c - '0'; break; -#endif case 2: verbose = 1; @@ -505,10 +494,11 @@ main (int argc, char **argv) } } - if (OBSOLETE_OPTION_WARNINGS - && digits_optind && ! getenv ("POSIXLY_CORRECT")) - error (0, 0, _("warning: `split -%d' is obsolete; use `split -l %d'"), - accum, accum); + if (digits_optind && 200112 <= posix2_version ()) + { + error (0, 0, _("`-%d' option is obsolete; use `-l %d'"), accum, accum); + usage (EXIT_FAILURE); + } /* Handle default case. */ if (split_type == type_undef) |