From 366e06bf71b500939fa3a70e3cce91d9a7776e14 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 20 Mar 2012 20:37:26 +0200 Subject: Make getopt always compile, fix C89 issues. --- getopt.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'getopt.c') diff --git a/getopt.c b/getopt.c index c539e3d7..c5c72a23 100644 --- a/getopt.c +++ b/getopt.c @@ -48,6 +48,11 @@ # endif #endif +/* !@#$%^&*() !!!!!!!! */ +#ifdef GAWK +#undef ELIDE_CODE +#endif + #ifndef ELIDE_CODE @@ -582,6 +587,7 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, struct option_list first; first.p = pfound; first.next = ambig_list; + first.needs_free = 0; ambig_list = &first; #if defined _LIBC @@ -877,9 +883,6 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, /* Convenience. Treat POSIX -W foo same as long option --foo */ if (temp[0] == 'W' && temp[1] == ';') { - if (longopts == NULL) - goto no_longs; - char *nameend; const struct option *p; const struct option *pfound = NULL; @@ -888,6 +891,9 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, int indfound = 0; int option_index; + if (longopts == NULL) + goto no_longs; + /* This is an option that requires an argument. */ if (*d->__nextchar != '\0') { -- cgit v1.2.3