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

Re: svn commit: r1485007 - /subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_subr/io.c

From: Philip Martin <philip.martin_at_wandisco.com>
Date: Wed, 22 May 2013 10:09:17 +0100

"Bert Huijben" <bert_at_qqmail.nl> writes:

>> However this is an error path so I'd go for simplicity rather than
>> efficiency:
>>
>> const char *failed_command = "";
>> for (i = 0; cmd[i]; ++i)
>> {
>> failed_command = apr_pstrcat(pool, failed_command, cmd[i]);
>> failed_command = apr_pstrcat(pool, failed_command, " ");
>
> Note that apr_pstrcat needs a final NULL argument :)
>
> So you could use apr_pstrcat(pool, failed_command, " ", cmd[i], NULL);
>
> Bert
>> }
>>
>> or:
>>
>> const char *failed_command = "";
>> for (i = 0; cmd[i]; ++i)
>> failed_command = apr_psprintf(pool, "%s %s", failed_command,
>> cmd[i]);

My first loop results in a final trailing " " and my second loop results
in a leading " ". Perhaps:

       const char *failed_command = cmd[0];
       for (i = 1; cmd[i]; ++i)
         failed_command = apr_psprintf(pool, "%s %s", failed_command, cmd[i]);

-- 
Certified & Supported Apache Subversion Downloads:
http://www.wandisco.com/subversion/download
Received on 2013-05-22 11:09:56 CEST

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.