getopt-gnu: flush out another BSD bug
authorEric Blake <ebb9@byu.net>
Sat, 28 Nov 2009 00:47:21 +0000 (17:47 -0700)
committerEric Blake <ebb9@byu.net>
Sat, 28 Nov 2009 03:29:00 +0000 (20:29 -0700)
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>

No differences found