2017-04-06 16:11:58 UTC
they have not been kept consistent in quite some time and there has
been quite a bit of divergence. They also haven't really been
*maintained* in either project.
I set out simply to eliminate __need_getopt in both projects (see
previous discussion in threads at
https://sourceware.org/ml/libc-alpha/2017-03/msg00512.html) but it
immediately became clear that a full bidirectional merge and quite a
few cleanups would be necessary to keep from going nuts.
Attached are a tarball of patches for glibc and a tarball of patches
for gnulib. I apologize for making reviewers unpack them, but this
seemed the best way of preventing the patch-sets from getting mixed
up. What they accomplish is:
* getopt.c, getopt1.c, and getopt_int.h are now identical in both projects.
* getopt.h has been exploded into many files. The most important
two, getopt_core.h and getopt_ext.h, are also identical in both
projects. The other two (in glibc) or four (in gnulib) are not shared
* __need_getopt is eliminated. In glibc, the replacement is #include
<bits/getopt_core.h>. In gnulib it's slightly more complicated, see
* The code to handle _GNU_nonoption_argv_flags_ has been removed.
This was an experimental feature in bash 2.0.0, withdrawn in 2.0.1 and
never reconsidered. All of the removed code has been ifdef-ed out
* Error reporting in getopt.c no longer involves an #ifdef _LIBC
block for every single call to fprintf.
* There is now only one copy of the code to process long options; an
off-by-one error in that code has been corrected, and memory-handling
while reporting ambiguous abbreviated options simplified.
Most of these changes should be completely invisible to applications.