This is the mail archive of the libc-alpha@sources.redhat.com 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]

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


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

Attachment: libc-argp4.diff
Description: Binary data


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