]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Include posixver.h.
authorJim Meyering <jim@meyering.net>
Sat, 16 Feb 2002 08:04:12 +0000 (08:04 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 16 Feb 2002 08:04:12 +0000 (08:04 +0000)
(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.

src/split.c

index 5634019defa98777b5c657be44c44ea51dab0da9..2cc3055895b0bb42f352c965f0fb7284231692a1 100644 (file)
@@ -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)