| #define ERR(str, chr) if(opterr){fprintf(stderr, "%s%s%c\n", argv[0], str, chr);} |
| getopt (int argc, char **argv, char *opts) |
| argv[optind][0] != '-' || argv[optind][1] == '\0') |
| else if (strcmp(argv[optind], "--") == 0) { |
| optopt = c = argv[optind][sp]; |
| if (c == ':' || (cp=strchr(opts, c)) == NULL) { |
| ERR (": illegal option -- ", c); |
| if (argv[optind][++sp] == '\0') { |
| if (argv[optind][sp+1] != '\0') |
| optarg = &argv[optind++][sp+1]; |
| else if (++optind >= argc) { |
| ERR (": option requires an argument -- ", c); |
| if (argv[optind][++sp] == '\0') { |