From owner-cvs-all Fri Jan 5 13:36:52 2001 From owner-cvs-all@FreeBSD.ORG Fri Jan 5 13:36:47 2001 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from Awfulhak.org (awfulhak.demon.co.uk [194.222.196.252]) by hub.freebsd.org (Postfix) with ESMTP id B353437B400; Fri, 5 Jan 2001 13:36:45 -0800 (PST) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [172.16.0.12]) by Awfulhak.org (8.11.1/8.11.1) with ESMTP id f05LTIv02412; Fri, 5 Jan 2001 21:29:18 GMT (envelope-from brian@lan.Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.11.1/8.11.1) with ESMTP id f05LZdi49344; Fri, 5 Jan 2001 21:35:39 GMT (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200101052135.f05LZdi49344@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.2 06/23/2000 with nmh-1.0.4 To: Ben Smithurst Cc: Brian Somers , Matt Dillon , cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org, brian@Awfulhak.org Subject: Re: cvs commit: src/usr.bin/apply apply.c In-Reply-To: Message from Ben Smithurst of "Fri, 05 Jan 2001 20:45:33 GMT." <20010105204533.O85794@strontium.scientia.demon.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 05 Jan 2001 21:35:39 +0000 From: Brian Somers Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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 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