]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Remove posixver.h and its uses.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 Apr 2005 16:41:17 +0000 (16:41 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 Apr 2005 16:41:17 +0000 (16:41 +0000)
(shortopts): New constant.  -DIGIT now always takes an optional arg.
(main): Don't preprocess arg list; that was buggy.  Use method
similar to expand.

src/fold.c

index 3ca3d0ff72ae13f2ea5ac6d8fd0a67b30d47295f..0717973b075b4b8969b622b9311ad23010779ab9 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "system.h"
 #include "error.h"
-#include "posixver.h"
 #include "xstrtol.h"
 
 #define TAB_WIDTH 8
@@ -47,6 +46,8 @@ static bool count_bytes;
 /* If nonzero, at least one of the files we read was standard input. */
 static bool have_read_stdin;
 
+static char const shortopts[] = "bsw:0::1::2::3::4::5::6::7::8::9::";
+
 static struct option const longopts[] =
 {
   {"bytes", no_argument, NULL, 'b'},
@@ -255,33 +256,10 @@ main (int argc, char **argv)
 
   break_spaces = count_bytes = have_read_stdin = false;
 
-  /* Turn any numeric options into -w options.  */
-  for (i = 1; i < argc; i++)
+  while ((optc = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1)
     {
-      char const *a = argv[i];
-      if (a[0] == '-')
-       {
-         if (a[1] == '-' && ! a[2])
-           break;
-         if (ISDIGIT (a[1]))
-           {
-             size_t len_a = strlen (a);
-             char *s = xmalloc (len_a + 2);
-             s[0] = '-';
-             s[1] = 'w';
-             memcpy (s + 2, a + 1, len_a);
-             argv[i] = s;
-             if (200112 <= posix2_version ())
-               {
-                 error (0, 0, _("`%s' option is obsolete; use `%s'"), a, s);
-                 usage (EXIT_FAILURE);
-               }
-           }
-       }
-    }
+      char optargbuf[2];
 
-  while ((optc = getopt_long (argc, argv, "bsw:", longopts, NULL)) != -1)
-    {
       switch (optc)
        {
        case 'b':               /* Count bytes rather than columns. */
@@ -292,6 +270,17 @@ main (int argc, char **argv)
          break_spaces = true;
          break;
 
+       case '0': case '1': case '2': case '3': case '4':
+       case '5': case '6': case '7': case '8': case '9':
+         if (optarg)
+           optarg--;
+         else
+           {
+             optargbuf[0] = optc;
+             optargbuf[1] = '\0';
+             optarg = optargbuf;
+           }
+         /* Fall through.  */
        case 'w':               /* Line width. */
          {
            unsigned long int tmp_ulong;