httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <>
Subject RE: cvs commit: apache-2.0/src/lib/apr/misc/unix getopt.c
Date Wed, 09 Aug 2000 20:40:33 GMT
> From: Jeff Trawick []
> Sent: Wednesday, August 09, 2000 3:20 PM
> "William A. Rowe, Jr." <> writes:
> > My problem, I can't get MSVC to complain (even at max error level 
> > rejection), so I don't know when/if I've licked the problem.  Jeff, 
> > if you have a fix, please apply and make the doc consistant.
> I suspect that the "fix" is to avoid the const on the last parm to both
> apr_getopt() and apr_initopt().

That feels "wrong" to me.  While in general, K&R declares that *argv[]
isn't const, I think it's simply bad form to maul the source parameters,
especially when we have a proper memory pool handler to create/discard
these sorts of working spaces.

> I realize that this is ugly in the const-ness sense, but IMHO if the
> normal declaration of argv ("char **argv" or "char *argv[]") can't be passed
> to apr_initopt() then it is apr_initopt() that is broken.

Wait... you can always pass non-const to const functions, simply not the
other way around.  We can pass the stock argv to apr_initopt, the question
is will we mutilate it in place.  If so, the original patch needs to be
changed to entirely non-const, and if not, it's a tweak.

> > This might be the fix, again I can't be certain:
> > 
> >  * @deffunc apr_status_t apr_getopt(apr_getopt_t *os, const 
> char *opts, char *optch, const char **optarg)
> >  */
> > APR_EXPORT(apr_status_t) apr_getopt(apr_getopt_t *os, const 
> char *opts, 
> >                                     char *optch, const char
> >  **optarg);
> No...  Then I have to specify "const char *optarg" in ab.c and then I
> have to cast optarg later when passing it to other routines.

That's actually the desired declaration of optarg.  Yes, you can maul
it with a cast, and yes, you can copy it out to something useful, but
I recall this conversation about another generic c lib function, and
there is no good resolution.
> (Don't forget the "problem" with apr_initopt().)

Ok... If we otherwise can accept this patch, the q. on the floor is this:

Do we want to treat argv as const?  Or do we choose to maul argv?

Responses?  (I'm in the former camp, but I won't even push a vote either way.)


View raw message