diff options
author | Jim Meyering <jim@meyering.net> | 2002-02-02 09:40:50 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2002-02-02 09:40:50 +0000 |
commit | 3c25a62eb8c076596fcda45eb115ace186c41559 (patch) | |
tree | 498814c6e128863b55daf4106e708a55e831fb12 | |
parent | 5e2bb11618f177b2b114b6ad46025f1b0efd87c7 (diff) | |
download | coreutils-3c25a62eb8c076596fcda45eb115ace186c41559.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.
(usage): Document this.
(main): Check for obsolete options.
(shortopts): New constant.
(main): Use -1, not EOF, for getopt_long.
-rw-r--r-- | src/split.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/split.c b/src/split.c index a4f7e9822..1b803977e 100644 --- a/src/split.c +++ b/src/split.c @@ -1,5 +1,5 @@ /* split.c -- split a file into pieces. - Copyright (C) 88, 91, 1995-2001 Free Software Foundation, Inc. + Copyright (C) 88, 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 @@ -65,6 +65,12 @@ static int output_desc; output file is opened. */ static int verbose; +static char const shortopts[] = "vb:l:C:" +#if POSIX2_VERSION < 200112 +"0123456789" +#endif +; + static struct option const longopts[] = { {"bytes", required_argument, NULL, 'b'}, @@ -100,7 +106,12 @@ Mandatory arguments to long options are mandatory for short options too.\n\ -b, --bytes=SIZE put SIZE bytes per output file\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\ - -NUMBER same as -l NUMBER\n\ +"), stdout); + 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\ "), stdout); @@ -368,8 +379,8 @@ main (int argc, char **argv) int this_optind = optind ? optind : 1; long int tmp_long; - c = getopt_long (argc, argv, "0123456789vb:l:C:", longopts, (int *) 0); - if (c == EOF) + c = getopt_long (argc, argv, shortopts, longopts, NULL); + if (c == -1) break; switch (c) @@ -426,6 +437,7 @@ main (int argc, char **argv) accum = (int) tmp_long; break; +#if POSIX2_VERSION < 200112 case '0': case '1': case '2': @@ -447,6 +459,7 @@ main (int argc, char **argv) split_type = type_digits; accum = accum * 10 + c - '0'; break; +#endif case 2: verbose = 1; @@ -461,6 +474,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); + /* Handle default case. */ if (split_type == type_undef) { |