From f46f40b54e6993356a87a258abca4cb570cbed59 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Tue, 12 Feb 2008 17:20:09 +0000 Subject: 2008-02-12 Peter Rosin * libc/stdlib/getopt.c (getopt_internal): Handle optional arguments better for long options and short options not appearing as the first option in a sequence. --- newlib/ChangeLog | 6 ++++++ newlib/libc/stdlib/getopt.c | 9 ++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index b20a7ad1c..bf077bf62 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,9 @@ +2008-02-12 Peter Rosin + + * libc/stdlib/getopt.c (getopt_internal): Handle optional + arguments better for long options and short options not + appearing as the first option in a sequence. + 2008-02-11 Patrick Mansfield * libc/machine/spu/straddr.h: New file, supplies _straddr. diff --git a/newlib/libc/stdlib/getopt.c b/newlib/libc/stdlib/getopt.c index 06e378170..09952db19 100644 --- a/newlib/libc/stdlib/getopt.c +++ b/newlib/libc/stdlib/getopt.c @@ -308,13 +308,8 @@ getopt_internal (int argc, char *const argv[], const char *shortopts, case OPTIONAL_ARG: if (*possible_arg == '=') possible_arg++; - if (*possible_arg != '\0') - { - optarg = possible_arg; - optwhere = 1; - } - else - optarg = NULL; + optarg = (*possible_arg != '\0') ? possible_arg : NULL; + optwhere = 1; break; case REQUIRED_ARG: if (*possible_arg == '=') -- cgit v1.2.3