Previously, "test 1 2 3 -a -b -c" was permuted to "test -a -b -c 1 2 3",
but "test 1 2 3 -abc" was left as "test 1 2 3 -abc".
Signed-off-by: Thomas Kindler <mail+newlib@t-kindler.de>
"const char *".
* newlib/libc/stdlib/getopt.c (getopt_internal): Use fputs()/fputc()
instead of fprintf() to save code space. Fix signed/unsigned
comparison.
* libc/include/getopt.h: Hide newlib extensions under
the __need_getopt_newlib flag.
* libc/stdlib/getopt.c: #define __need_getopt_newlib before including
getopt.h. Put entire code under !HAVE_GETOPT to support platforms
with their own getopt implementation.
* configure.host: Specify HAVE_GETOPT for x86-linux.
* libc/stdlib/getopt.c (getopt_internal): Rewrite to accept
data area so as to support reentrant calls. Change all callers
to fill in data area with global values and restore any changes
to the global values after call.
(__getopt_r, __getopt_long_r, __getopt_long_only_r): New routines
to support reentrancy that add a data area argument.
* libc/include/getopt.h: Add new _r routines and provide macros
so they can be called with using double-underscores.