Patch from Frank Korz.
authorJim Meyering <jim@meyering.net>
Fri, 5 Apr 1996 13:14:59 +0000 (13:14 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 5 Apr 1996 13:14:59 +0000 (13:14 +0000)
src/nice.c

index 606e364b36e340c23e17fade04d01aa804fea809..7a935210651f663e6306375799aa60edaef6dddb 100644 (file)
@@ -59,8 +59,6 @@ main (int argc, char **argv)
   int adjustment = 0;
   int minusflag = 0;
   int adjustment_given = 0;
-  int long_option_priority = 0;
-  int last_optind = 0;
 
   program_name = argv[0];
   setlocale (LC_ALL, "");
@@ -81,47 +79,46 @@ main (int argc, char **argv)
            error (1, 0, _("invalid option `%s'"), s);
 
          minusflag = 1;
+         /* FIXME: use strtol */
          adjustment = atoi (&s[2]);
          adjustment_given = 1;
-         long_option_priority = 1;
          ++optind;
        }
       else
        {
-         int optc;
-         while ((optc = getopt_long (argc, argv, "+0123456789n:", longopts,
-                                     (int *) 0)) != EOF)
+         if (s[0] == '-' && ISDIGIT (s[1]))
            {
-             switch (optc)
+             if (!isinteger (&s[1]))
+               error (1, 0, _("invalid option `%s'"), s);
+             /* FIXME: use strtol */
+             adjustment = atoi (&s[1]);
+             adjustment_given = 1;
+             ++optind;
+           }
+         else
+           {
+             int optc;
+             while ((optc = getopt_long (argc, argv, "+n:",
+                                         longopts, (int *) 0)) != EOF)
                {
-               case '?':
-                 usage (1);
-
-               case 'n':
-                 if (!isinteger (optarg))
-                   error (1, 0, _("invalid priority `%s'"), optarg);
-                 adjustment = atoi (optarg);
-                 adjustment_given = 1;
-                 break;
-
-               default:
-                 assert (ISDIGIT (optc));
-                 /* Reset ADJUSTMENT if the last priority-specifying option
-                    was not of the same type or if it was, but a separate
-                    option.  */
-                 if (long_option_priority ||
-                     (adjustment_given && optind != last_optind))
+                 switch (optc)
                    {
-                     long_option_priority = 0;
-                     adjustment = 0;
+                   case '?':
+                     usage (1);
+
+                   case 'n':
+                     if (!isinteger (optarg))
+                       error (1, 0, _("invalid priority `%s'"), optarg);
+                     /* FIXME: use strtol */
+                     adjustment = atoi (optarg);
+                     adjustment_given = 1;
+                     break;
                    }
-                 adjustment = adjustment * 10 + optc - '0';
-                 adjustment_given = 1;
-                 last_optind = optind;
                }
+
+             if (optc == EOF)
+               break;
            }
-         if (optc == EOF)
-           break;
        }
     }