1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-08-12 20:09:14 +02:00

(main): Use `if' stmt, not while loop, around getopt invocation.

Otherwise, `./nice --a=1 -1 ./nice' (in which old-style option
follows a long option) gets an error.
This commit is contained in:
Jim Meyering
1996-04-05 13:32:39 +00:00
parent 9d22ab92f9
commit 0e199278c1
+27 -29
View File
@@ -79,46 +79,43 @@ main (int argc, char **argv)
error (1, 0, _("invalid option `%s'"), s);
minusflag = 1;
/* FIXME: use strtol */
/* FIXME: use xstrtol */
adjustment = atoi (&s[2]);
adjustment_given = 1;
++optind;
}
else if (s[0] == '-' && ISDIGIT (s[1]))
{
if (!isinteger (&s[1]))
error (1, 0, _("invalid option `%s'"), s);
/* FIXME: use xstrtol */
adjustment = atoi (&s[1]);
adjustment_given = 1;
++optind;
}
else
{
if (s[0] == '-' && ISDIGIT (s[1]))
int optc;
if ((optc = getopt_long (argc, argv, "+n:",
longopts, (int *) 0)) != EOF)
{
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)
switch (optc)
{
switch (optc)
{
case '?':
usage (1);
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;
}
case 'n':
if (!isinteger (optarg))
error (1, 0, _("invalid priority `%s'"), optarg);
/* FIXME: use xstrtol */
adjustment = atoi (optarg);
adjustment_given = 1;
break;
}
if (optc == EOF)
break;
}
if (optc == EOF)
break;
}
}
@@ -143,6 +140,7 @@ main (int argc, char **argv)
exit (0);
}
printf ("adjustment = %d\n", adjustment);
#ifndef NICE_PRIORITY
errno = 0;
current_priority = GET_PRIORITY ();