diff options
Diffstat (limited to 'missing/getopt.c')
-rw-r--r-- | missing/getopt.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/missing/getopt.c b/missing/getopt.c index f5e62daa..14cd6a32 100644 --- a/missing/getopt.c +++ b/missing/getopt.c @@ -59,14 +59,17 @@ getopt(nargc, nargv, ostr) char * const *nargv; const char *ostr; { -#ifdef _WIN32 - char *__progname="windump"; -#else - extern char *__progname; -#endif + char *cp; + static char *__progname; static char *place = EMSG; /* option letter processing */ char *oli; /* option letter list index */ + if (__progname == NULL) { + if ((cp = strrchr(nargv[0], '/')) != NULL) + __progname = cp + 1; + else + __progname = nargv[0]; + } if (optreset || !*place) { /* update scanning pointer */ optreset = 0; if (optind >= nargc || *(place = nargv[optind]) != '-') { |