add getopt reset support

based on proposed patches by Daniel Cegiełka, with minor changes:
- use a weak symbol for optreset so it doesn't clash with namespace
- also reset optpos (position in multi-option arg like -lR)
- also make getopt_long support reset
This commit is contained in:
Rich Felker 2012-09-30 20:00:38 -04:00
commit 030e526392
3 changed files with 19 additions and 3 deletions

View file

@ -7,7 +7,7 @@ extern "C" {
int getopt(int, char * const [], const char *);
extern char *optarg;
extern int optind, opterr, optopt;
extern int optind, opterr, optopt, optreset;
struct option
{