Date: Fri, 05 Jan 2001 21:35:39 +0000 From: Brian Somers <brian@Awfulhak.org> To: Ben Smithurst <ben@FreeBSD.org> Cc: Brian Somers <brian@Awfulhak.org>, Matt Dillon <dillon@earth.backplane.com>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org, brian@Awfulhak.org Subject: Re: cvs commit: src/usr.bin/apply apply.c Message-ID: <200101052135.f05LZdi49344@hak.lan.Awfulhak.org> In-Reply-To: Message from Ben Smithurst <ben@FreeBSD.org> of "Fri, 05 Jan 2001 20:45:33 GMT." <20010105204533.O85794@strontium.scientia.demon.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
> Brian Somers wrote: > > >>> Yes, but not portably. The ANSI standard tried to standardize it but > >>> the reality is that only snprintf()'s return value is portable. If you > >>> try to use the return value from other functions as a count, your code > >>> won't be portable. asprintf() *might* be portable too, but nothing else. > >> > >> Oh hell. In that case I'll probably just make the paragraph about > >> snprintf's return value clearer and not touch anything else. > > > > Except that the paragraph that says > > > > These functions return the number of characters printed (not including > > the trailing `\0' used to end output to strings). > > > > is wrong :-/ > > ok, how about I update the paragraph to: > > These functions return the number of characters printed (not including > the trailing `\0' used to end output to strings). However, this is only > portable when referring to the snprintf() function; the other functions > may have different return conventions on other systems. But snprintf() doesn't return the number of characters printed. It returns the number of characters that it would print if the buffer is big enough (see the example in one of my other posts). How about something like snprintf() and vsnprintf() return the number of characters that would be emitted given a big enough ``size''. All other functions return the number of characters emitted. The trailing '\0' is not counted in any case. > -- > Ben Smithurst / ben@FreeBSD.org / PGP: 0x99392F7D -- Brian <brian@Awfulhak.org> <brian@[uk.]FreeBSD.org> <http://www.Awfulhak.org> <brian@[uk.]OpenBSD.org> Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200101052135.f05LZdi49344>