[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: Malcolm Rowe <malcolm-svn-dev_at_farside.org.uk>
Date: 2007-02-24 22:30:31 CET

On Sat, Feb 24, 2007 at 02:24:54PM -0600, Jonathan Gilbert wrote:
> 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);

Yes, it does. I like that. I'm pretty sure the return of sprintf() is
sensible, unlike, say, snprintf() - where some implementations return -1
on truncation.

> ..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));

That's a little less readable that what I was hoping for :-)


  • application/pgp-signature attachment: stored
Received on Sat Feb 24 22:31:13 2007

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