1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
5 #define EPR fprintf(stderr,
6 #define ERR(str, chr) if(opterr) { EPR "%s%c\n", str, chr); }
14 stgetopt(int argc
, char *const argv
[], const char *opts
)
23 argv
[optind
][0] != '-' || argv
[optind
][1] == '\0')
25 else if (strcmp(argv
[optind
], "--") == 0)
30 else if (strcmp(argv
[optind
], "-isysroot") == 0)
32 // skip Mac OS X SDK selection flags
36 optopt
= c
= argv
[optind
][sp
];
37 if (c
== ':' || (cp
= strchr(opts
, c
)) == 0)
39 ERR(": illegal option -- ", c
);
40 if (argv
[optind
][++sp
] == '\0')
49 if (argv
[optind
][sp
+ 1] != '\0')
50 optarg
= &argv
[optind
++][sp
+ 1];
54 ERR(": option requires an argument -- ", c
);
59 optarg
= argv
[optind
++];
64 if (argv
[optind
][++sp
] == '\0')
74 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */