*: move getopt reset code to better place(s)

This commit is contained in:
Denis Vlasenko
2008-01-28 22:57:10 +00:00
parent 73032ca04b
commit 9772816570
4 changed files with 31 additions and 26 deletions

View File

@@ -155,7 +155,14 @@ static int generate_output(char **argv, int argc, const char *optstr, const stru
if (quiet_errors) /* No error reporting from getopt(3) */
opterr = 0;
optind = 0; /* Reset getopt(3) */
/* Reset getopt(3) (see libbb/getopt32.c for long rant) */
#ifdef __GLIBC__
optind = 0;
#else /* BSD style */
optind = 1;
/* optreset = 1; */
#endif
while (1) {
opt =