diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2009-12-14 10:47:25 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2009-12-14 10:47:25 +0000 |
commit | 5d5594597eaccccd24e3ee3d07dfdae01c3f89b3 (patch) | |
tree | ed150f43fc2e060b3ced853645e73650efcfac9f /winsup | |
parent | cfc4fc9debfdd6823358bc63c550b96f3d48d5b1 (diff) | |
download | newlib-5d5594597eaccccd24e3ee3d07dfdae01c3f89b3.zip newlib-5d5594597eaccccd24e3ee3d07dfdae01c3f89b3.tar.gz newlib-5d5594597eaccccd24e3ee3d07dfdae01c3f89b3.tar.bz2 |
* libc/getopt.c (getopt_internal): Set optreset according to optind
setting earlier. Reevaluate POSIXLY_CORRECT if optreset is set to !0.
Handle a leading '-' in options independently of posixly_correct.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/cygwin/libc/getopt.c | 25 |
2 files changed, 20 insertions, 11 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 8c39cea..d6f47bd 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2009-12-14 Corinna Vinschen <corinna@vinschen.de> + + * libc/getopt.c (getopt_internal): Set optreset according to optind + setting earlier. Reevaluate POSIXLY_CORRECT if optreset is set to !0. + Handle a leading '-' in options independently of posixly_correct. + 2009-12-09 Christopher Faylor <me+cygwin@cgf.cx> * fhandler_fifo.cc (fhandler_fifo::open): Avoid resetting errno after diff --git a/winsup/cygwin/libc/getopt.c b/winsup/cygwin/libc/getopt.c index ccec9b5..bc35f96 100644 --- a/winsup/cygwin/libc/getopt.c +++ b/winsup/cygwin/libc/getopt.c @@ -304,25 +304,28 @@ getopt_internal(int nargc, char * const *nargv, const char *options, return (-1); /* + * XXX Some GNU programs (like cvs) set optind to 0 instead of + * XXX using optreset. Work around this braindamage. + */ + if (optind == 0) + optind = optreset = 1; + + /* * Disable GNU extensions if POSIXLY_CORRECT is set or options * string begins with a '+'. + * + * CV, 2009-12-14: Check POSIXLY_CORRECT anew if optind == 0 or + * optreset != 0 for GNU compatibility. */ - if (posixly_correct == -1) + if (posixly_correct == -1 || optreset != 0) posixly_correct = (getenv("POSIXLY_CORRECT") != NULL); - if (posixly_correct || *options == '+') - flags &= ~FLAG_PERMUTE; - else if (*options == '-') + if (*options == '-') flags |= FLAG_ALLARGS; + else if (posixly_correct || *options == '+') + flags &= ~FLAG_PERMUTE; if (*options == '+' || *options == '-') options++; - /* - * XXX Some GNU programs (like cvs) set optind to 0 instead of - * XXX using optreset. Work around this braindamage. - */ - if (optind == 0) - optind = optreset = 1; - optarg = NULL; if (optreset) nonopt_start = nonopt_end = -1; |