This took longer than I had planned. Uli accepted some of my bug reports about glibc getopt. In the process of syncing glibc back to gnulib, I noticed that Solaris 10 and FreeBSD 8.0 used the replacement getopt even for getopt-posix, even though I saw no compelling reason for that behavior. I also discovered that MacOS 10.5 (darwin 9.8.0) has a getopt bug that we weren't yet testing. I'm pushing this series now. Cygwin 1.7.3 and above passes without needing the replacement, and I assume that glibc 2.11.90 in rawhide will pass as well (athough I currently can't get my rawhide system up to the point to test it); I also verified that Fedora 12's glibc 2.11 fails the m4 test, but that the fixed lib/getopt.c replacement passes.
[PATCH 1/5] getopt-posix: avoid spurious failure on FreeBSD [PATCH 2/5] getopt-posix: avoid spurious failure on Solaris [PATCH 3/5] getopt-posix: detect MacOS bug [PATCH 4/5] getopt: merge bug fixes from glibc [PATCH 5/5] getopt-gnu: match recent glibc fixes and posix ruling ChangeLog | 31 ++++++++ doc/glibc-functions/getopt_long.texi | 19 +++-- doc/glibc-functions/getopt_long_only.texi | 22 ++++-- doc/posix-functions/getopt.texi | 17 +++- lib/getopt.c | 37 +++++---- m4/getopt.m4 | 41 +++++++++- tests/test-getopt.h | 119 ++++++++++++++++++++++++++-- tests/test-getopt_long.h | 17 +++-- 8 files changed, 250 insertions(+), 53 deletions(-)
