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

Re: [patch] c99-isms

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: Thu, 26 Mar 2009 13:13:27 -0400

Branko Čibej wrote:
> C. Michael Pilato wrote:
>> Matthew Woehlke wrote:
>>
>>> I'm trying to build svn 1.6.0 (and previously 1.5.6, which had the same
>>> problems) on one-and-a-half* machines that lack a c99 compiler. This
>>> causes problems because svn uses a c99 convention of initializing
>>> structs with "non-static" data.
>>>
>>> The attached patch is needed for compilation to succeed on these
>>> platforms. Generally speaking, these problems are:
>>> - struct initialization with "non-const" data
>>> - comma after last item in an enum
>>> - initialize function pointers to NULL (use '0' instead)
>>>
>> Now, you do realize that we only aspire to C89/ANSI-C, right? This is
>> documented in our www/hacking.html file. So, some of what you recommend is
>> fine because it satisfies both C89 and C99. But some of it, methinks, won't
>> pan out well for C89 compilers, namely stuff like this:
>>
>>
>>> diff -ru subversion-1.6.0/subversion/tests/libsvn_client/client-test.c subversion-1.6.0-patched/subversion/tests/libsvn_client/client-test.c
>>> --- subversion-1.6.0/subversion/tests/libsvn_client/client-test.c 2008-07-30 08:05:17.000000000 -0700
>>> +++ subversion-1.6.0-patched/subversion/tests/libsvn_client/client-test.c 2009-03-25 14:57:04.536775000 -0700
>>> @@ -146,7 +146,10 @@
>>> apr_array_header_t *targets;
>>> apr_getopt_t *os;
>>> const int argc = 2;
>>> - const char *argv[] = { "opt-test", input, NULL };
>>> + const char *argv[3];
>>> + argv[0] = "opt-test";
>>> + argv[1] = input;
>>> + argv[2] = NULL;
>>> apr_status_t apr_err;
>>> svn_error_t *err;
>>>
>> Cases like this will (I'm guessing) cause problems because they declare
>> stack variables after other assignments have been made. We need to move
>> those "argv[N] =" lines to after all the variable declarations. Wanna take
>> another cut at the patch?
>>
>
> Also ... you actually *can* init almost all of argv here. :)
>
> const char *argv[] = { "opt-test", NULL, NULL };
>
> and later:
>
> argv[1] = input;

I find that kinda confusing, though (as a reader of the code). Don't you?

-- 
C. Michael Pilato <cmpilato_at_collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1432522

Received on 2009-03-26 18:14:12 CET

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.