mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-06 20:58:33 +01:00
Update.
2000-09-06 Ulrich Drepper <drepper@redhat.com> * posix/getopt.c (_getopt_internal): Don't recognize an option name as ambiguous if it's a prefix for more than one name but the other struct option values are identical. * posix/tstgetopt.c: Add test for improved ambiguity recognition. Don't depend on visual inspection of the output file to recognize errors. * posix/Makefile (tstgetopt-ARGS): Add a few more parameters.
This commit is contained in:
parent
b8b17701ae
commit
b64cd08aab
3 changed files with 34 additions and 5 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2000-09-06 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* posix/getopt.c (_getopt_internal): Don't recognize an option
|
||||||
|
name as ambiguous if it's a prefix for more than one name but the
|
||||||
|
other struct option values are identical.
|
||||||
|
|
||||||
|
* posix/tstgetopt.c: Add test for improved ambiguity recognition.
|
||||||
|
Don't depend on visual inspection of the output file to recognize
|
||||||
|
errors.
|
||||||
|
* posix/Makefile (tstgetopt-ARGS): Add a few more parameters.
|
||||||
|
|
||||||
2000-09-06 Andreas Jaeger <aj@suse.de>
|
2000-09-06 Andreas Jaeger <aj@suse.de>
|
||||||
|
|
||||||
* sysdeps/alpha/soft-fp/Dist: New file.
|
* sysdeps/alpha/soft-fp/Dist: New file.
|
||||||
|
|
|
@ -109,7 +109,7 @@ endif
|
||||||
CFLAGS-regex.c = -Wno-strict-prototypes
|
CFLAGS-regex.c = -Wno-strict-prototypes
|
||||||
CFLAGS-getaddrinfo.c = -DRESOLVER
|
CFLAGS-getaddrinfo.c = -DRESOLVER
|
||||||
tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \
|
tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \
|
||||||
--none random
|
--none random --col --color --colour
|
||||||
|
|
||||||
tst-exec-ARGS = -- $(built-program-cmd)
|
tst-exec-ARGS = -- $(built-program-cmd)
|
||||||
tst-spawn-ARGS = -- $(built-program-cmd)
|
tst-spawn-ARGS = -- $(built-program-cmd)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
|
@ -10,14 +11,19 @@ main (int argc, char **argv)
|
||||||
{"required", required_argument, NULL, 'r'},
|
{"required", required_argument, NULL, 'r'},
|
||||||
{"optional", optional_argument, NULL, 'o'},
|
{"optional", optional_argument, NULL, 'o'},
|
||||||
{"none", no_argument, NULL, 'n'},
|
{"none", no_argument, NULL, 'n'},
|
||||||
|
{"color", no_argument, NULL, 'C'},
|
||||||
|
{"colour", no_argument, NULL, 'C'},
|
||||||
{NULL, 0, NULL, 0 }
|
{NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
int aflag = 0;
|
int aflag = 0;
|
||||||
int bflag = 0;
|
int bflag = 0;
|
||||||
char *cvalue = NULL;
|
char *cvalue = NULL;
|
||||||
|
int Cflag = 0;
|
||||||
|
int nflag = 0;
|
||||||
int index;
|
int index;
|
||||||
int c;
|
int c;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
while ((c = getopt_long (argc, argv, "abc:", options, NULL)) >= 0)
|
while ((c = getopt_long (argc, argv, "abc:", options, NULL)) >= 0)
|
||||||
switch (c)
|
switch (c)
|
||||||
|
@ -31,6 +37,9 @@ main (int argc, char **argv)
|
||||||
case 'c':
|
case 'c':
|
||||||
cvalue = optarg;
|
cvalue = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'C':
|
||||||
|
++Cflag;
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
fputs ("Unknown option.\n", stderr);
|
fputs ("Unknown option.\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -40,19 +49,28 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
printf ("--required %s\n", optarg);
|
printf ("--required %s\n", optarg);
|
||||||
|
result |= strcmp (optarg, "foobar") != 0;
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
printf ("--optional %s\n", optarg);
|
printf ("--optional %s\n", optarg);
|
||||||
|
result |= optarg == NULL || strcmp (optarg, "bazbug") != 0;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
puts ("--none");
|
puts ("--none");
|
||||||
|
nflag = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("aflag = %d, bflag = %d, cvalue = %s\n", aflag, bflag, cvalue);
|
printf ("aflag = %d, bflag = %d, cvalue = %s, Cflags = %d, nflag = %d\n",
|
||||||
|
aflag, bflag, cvalue, Cflag, nflag);
|
||||||
|
|
||||||
|
result |= (aflag != 1 || bflag != 1 || cvalue == NULL
|
||||||
|
|| strcmp (cvalue, "foobar") != 0 || Cflag != 3 || nflag != 1);
|
||||||
|
|
||||||
for (index = optind; index < argc; index++)
|
for (index = optind; index < argc; index++)
|
||||||
printf ("Non-option argument %s\n", argv[index]);
|
printf ("Non-option argument %s\n", argv[index]);
|
||||||
|
|
||||||
return 0;
|
result |= optind + 1 != argc || strcmp (argv[optind], "random") != 0;
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue