[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: CVS update: subversion/subversion/client add-cmd.c checkout-cmd.c cl.h commit-cmd.c delete-cmd.c main.c propget-cmd.c proplist-cmd.c props.c propset-cmd.c status-cmd.c update-cmd.c

From: Greg Stein <gstein_at_lyra.org>
Date: 2000-11-18 20:59:20 CET

On Sat, Nov 18, 2000 at 02:48:57PM -0500, Jim Blandy wrote:
>
> > [ I've been on a mission re: const for a while. there are two reasons for
> > adding const: 1) "static const" data can then be passed in functions that
> > are declared with 'const' (if a function does /not/ have const, then you
> > cannot pass const data to it); 2) the 'const' is a semantic signal that
> > the function will not be changing your data. ]
>
> Const is one of those things which seems like a nice idea, but the way
> it actually works out is so disappointing. For example, consider:
>
> #include <string.h>
>
> char *pc;
> const char *pcc; /* assume non-empty */
>
> pc = strchr (pcc, pcc[0]);
>
> Hmm. It all type-checks, but somehow I've turned a const char * into
> a char *. So we've gone to all the trouble to implement this static
> typechecking, which then doesn't let us express everyday arrangements.
> You can't even implement something straightforward like strchr without
> "turning off" your type checker on the returned value.
>
> Not an objection to Greg's changes, just a language gripe.

Note: the above mis-logic is caused by erroneous definitiosn of strchr(). It
is declared: char *strchr(const char *s). Totally wrong :-(

We fixed this in the Apache code, but it wasn't moved down to APR.

Specifically, Apache #defines strchr() to be ap_strchr(), which is defined
as: char *ap_strchr(char *s). If you pass it a const, then it barfs on you.
In that case, the code explicitly uses ap_strchr_c() which is defined as:
const char *ap_strchr_c(const char *s).

The above gimmickry is controlled by AP_DEBUG, so production code actually
just uses strchr() all the time (and thus, any potential compiler
optimizations).

I've set up SVN_DEBUG (and AP_DEBUG) for us in the configure file, so we can
use the same mechanism (and mod_dav_svn uses Apache's when it includes
Apache files, because of the AP_DEBUG). I might look into shifting the stuff
down into APR, although that would be a big symbol rename across Apache (no
real big deal, but possible).

Thoughts?

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/
Received on Sat Oct 21 14:36:15 2006

This is an archived mail posted to the Subversion Dev mailing list.