mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2025-08-17 12:41:05 +03:00
getopt-gnu: flush out another BSD bug
POSIX requires 'echo foo > bar; m4 -Dfoo=1 bar -Dfoo=2 bar' to output '1' then '2'. To achieve this, m4 relies on the GNU getopt{,_long} extension of a leading '-'. However, BSD getopt fails to honor this extension when POSIXLY_CORRECT. Also, BSD getopt fails to reparse POSIXLY_CORRECT from the environment even when a reset is requested (whether by optreset=1 or by optind=0). * m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS): Test for the bug. * tests/test-getopt.c (main): Check POSIXLY_CORRECT first, to flush out BSD bug. * tests/test-getopt.h (test_getopt): End lists with NULL. * tests/test-getopt_long.h (test_getopt_long): Likewise. (test_getopt_long_posix): Enhance test. * modules/getopt-posix-tests (Depends-on): Add stdbool. * doc/glibc-functions/getopt_long.texi (getopt_long): Mention getopt-gnu. * doc/glibc-functions/getopt_long_only.texi (getopt_long_only): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
This commit is contained in:
@@ -2,15 +2,33 @@
|
||||
@subsection @code{getopt_long}
|
||||
@findex getopt_long
|
||||
|
||||
Gnulib module: ---
|
||||
Gnulib module: getopt-gnu
|
||||
|
||||
Portability problems fixed by Gnulib:
|
||||
@itemize
|
||||
@item
|
||||
The function @code{getopt_long} does not support the @samp{+} flag in
|
||||
the options string on some platforms:
|
||||
MacOS X 10.5, AIX 5.2, OSF/1 5.1, Solaris 10.
|
||||
@item
|
||||
The function @code{getopt_long} does not obey the @samp{-} flag in the
|
||||
options string when @env{POSIXLY_CORRECT} is set on some platforms:
|
||||
Cygwin 1.7.0.
|
||||
@item
|
||||
The function @code{getopt_long} does not support options with optional
|
||||
arguments on some platforms:
|
||||
MacOS X 10.5, OpenBSD 4.0, AIX 5.2, IRIX 6.5, Solaris 10, Cygwin 1.5.x.
|
||||
@item
|
||||
This function is missing on some platforms:
|
||||
AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Interix 3.5.
|
||||
@end itemize
|
||||
|
||||
Portability problems not fixed by Gnulib:
|
||||
@itemize
|
||||
@item
|
||||
This function is missing on some platforms:
|
||||
AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Interix 3.5.
|
||||
The glibc implementation allows a complete reset of the environment,
|
||||
including re-checking for @env{POSIXLY_CORRECT}, by setting
|
||||
@code{optind} to 0. Other implementations provide @code{optreset},
|
||||
causing a reset by setting it non-zero, although it does not
|
||||
necessarily re-read @env{POSIXLY_CORRECT}.
|
||||
@end itemize
|
||||
|
@@ -2,15 +2,34 @@
|
||||
@subsection @code{getopt_long_only}
|
||||
@findex getopt_long_only
|
||||
|
||||
Gnulib module: ---
|
||||
Gnulib module: getopt-gnu
|
||||
|
||||
Portability problems fixed by Gnulib:
|
||||
@itemize
|
||||
@item
|
||||
The function @code{getopt_long_only} does not support the @samp{+}
|
||||
flag in the options string on some platforms:
|
||||
MacOS X 10.5, AIX 5.2, OSF/1 5.1, Solaris 10.
|
||||
@item
|
||||
The function @code{getopt_long_only} does not obey the @samp{-} flag
|
||||
in the options string when @env{POSIXLY_CORRECT} is set on some platforms:
|
||||
Cygwin 1.7.0.
|
||||
@item
|
||||
The function @code{getopt_long_only} does not support options with
|
||||
optional arguments on some platforms:
|
||||
MacOS X 10.5, OpenBSD 4.0, AIX 5.2, Solaris 10, Cygwin 1.5.x.
|
||||
@item
|
||||
This function is missing on some platforms:
|
||||
MacOS X 10.3, FreeBSD 5.2.1, NetBSD 3.0, AIX 5.1, HP-UX 11, IRIX 6.5,
|
||||
OSF/1 5.1, mingw, Interix 3.5.
|
||||
@end itemize
|
||||
|
||||
Portability problems not fixed by Gnulib:
|
||||
@itemize
|
||||
@item
|
||||
This function is missing on some platforms:
|
||||
MacOS X 10.3, FreeBSD 5.2.1, NetBSD 3.0, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, mingw, Interix 3.5.
|
||||
The glibc implementation allows a complete reset of the environment,
|
||||
including re-checking for @env{POSIXLY_CORRECT}, by setting
|
||||
@code{optind} to 0. Other implementations provide @code{optreset},
|
||||
causing a reset by setting it non-zero, although it does not
|
||||
necessarily re-read @env{POSIXLY_CORRECT}.
|
||||
@end itemize
|
||||
|
Reference in New Issue
Block a user