"Bert Huijben" <[email protected]> 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

Reply via email to