3
#define EPR fprintf(stderr,
4
#define ERR(str, chr) if(opterr){EPR "%s%c\n", str, chr);}
11
getopt (int argc, char *const argv[], const char *opts)
19
argv[optind][0] != '-' || argv[optind][1] == '\0')
21
else if (strcmp(argv[optind], "--") == 0) {
26
optopt = c = argv[optind][sp];
27
if (c == ':' || (cp=strchr(opts, c)) == 0) {
28
ERR (": illegal option -- ", c);
29
if (argv[optind][++sp] == '\0') {
36
if (argv[optind][sp+1] != '\0')
37
optarg = &argv[optind++][sp+1];
38
else if (++optind >= argc) {
39
ERR (": option requires an argument -- ", c);
43
optarg = argv[optind++];
46
if (argv[optind][++sp] == '\0') {