This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Merge getopt from gnulib to glibc and vice versa, eliminate __need_getopt


The implementation of 'getopt' is shared between gnulib and glibc, but
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/msg00059.html,
https://sourceware.org/ml/libc-alpha/2017-03/msg00511.html, and
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
at all.
 * __need_getopt is eliminated.  In glibc, the replacement is #include
<bits/getopt_core.h>.  In gnulib it's slightly more complicated, see
unistd.in.h.

 * 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
since 2001.
 * 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.

zw

Attachment: getopt-glibc.patchset.tar.gz
Description: GNU Zip compressed data

Attachment: getopt-gnulib.patchset.tar.gz
Description: GNU Zip compressed data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]