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

Re: [PATCH] svndumpfilter's use of %n

From: Jonathan Gilbert <o2w9gs702_at_sneakemail.com>
Date: 2007-02-24 21:24:54 CET

At 06:01 PM 2/24/2007 +0000, Malcolm Rowe wrote:
>> - sprintf(buf, "%d%n", namelen, &bytes_used);
>> - svn_stringbuf_appendbytes(*strbuf, buf, bytes_used);
>> + sprintf(buf, "%d", namelen);
>> + svn_stringbuf_appendbytes(*strbuf, buf, strlen(buf));
>> svn_stringbuf_appendbytes(*strbuf, "\n", 1);
>
>Slightly less efficient, but a whole lot clearer.

Doesn't sprintf() return the number of bytes it wrote into the buffer anyway?

  bytes_used = sprintf(buf, "%d", namelen);
  svn_stringbuf_appendbytes(*strbuf, buf, bytes_used);

..or if one is feeling daring (might not be wise, since in the case of
failure, a negative number is returned -- but then, what could go wrong
with this particular invocation? :-):

  svn_stringbuf_appendbytes(*strbuf, buf,
    sprintf(buf, "%d", namelen));

Jonathan Gilbert

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Feb 24 21:25:40 2007

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