[PATCH] getopt,argp - reentrant getopt interface, argp fixes

Marcus Brinkmann marcus.brinkmann@ruhr-uni-bochum.de
Mon Mar 8 13:42:00 GMT 2004


At Sun, 07 Mar 2004 23:07:22 -0800,
Ulrich Drepper wrote:
> Don't move the declarations into include/getopt.h.  Instead create a new
> internal header, getopt_int.h or whatever named.  Move all the internal
> stuff in there.  This means users outside glibc will have to copy along
> another file but that cannot be a problem.

This is certainly the best way to do it.  I put it in
posix/getopt_int.h.  I had to add include/getopt_int.h, too, though,
so that argp/argp-parse.h can include it.  (Including
posix/getopt_int.h from include/getopt.h or including <posix/getopt_int.h>
from argp/argp-parse.c looked wrong to me.)
 
> The patch itself is botch.

Urgh, sorry.

> There should be no need for the global __getopt_initialized variable.

Removed.

> Just always use the value in the struct.  This variable has always been
> internal.  Also, in _getopt_internal() there should be no need to copy
> the variables going into the function.  Check the code all paths whether
> any of the values is being read.  I might miss something but I think
> there are none.

opterr and optind are user input variables that need to be copied.
optind, optarg and optopt are output variables.  I removed all the
other copies.

> I do not worry about the case where the value in the
> global opt* variables gets overwritten with a value from __getopt_data
> even though the latter hasn't been written to in the _getopt_internal_r
> call.
> 
> Aslo, you're using some C99 syntax which probably won't make the gnulib
> people happy.  Look for uses of _GETOPT_DATA_INITIALIZER.

Fixed.

New patch attached.  Hopefully it is converging :)

Thanks!
Marcus

-------------- next part --------------
A non-text attachment was scrubbed...
Name: libc-argp4.diff
Type: application/octet-stream
Size: 47107 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20040308/00348cfe/attachment.obj>


More information about the Libc-alpha mailing list