From owner-cvs-lib Wed Dec 24 12:28:32 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id MAA28565 for cvs-lib-outgoing; Wed, 24 Dec 1997 12:28:32 -0800 (PST) (envelope-from owner-cvs-lib) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id MAA28504; Wed, 24 Dec 1997 12:27:55 -0800 (PST) (envelope-from ache@FreeBSD.org) From: "Andrey A. Chernov" Received: (from ache@localhost) by freefall.freebsd.org (8.8.6/8.8.5) id MAA07753; Wed, 24 Dec 1997 12:24:10 -0800 (PST) Date: Wed, 24 Dec 1997 12:24:10 -0800 (PST) Message-Id: <199712242024.MAA07753@freefall.freebsd.org> To: cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-lib@FreeBSD.ORG Subject: cvs commit: src/lib/libc/stdio snprintf.c vsnprintf.c Sender: owner-cvs-lib@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk ache 1997/12/24 12:24:10 PST Modified files: lib/libc/stdio snprintf.c vsnprintf.c Log: 1) Oops! Insert again if (n == 0) return 0. Final word is Bruce's quote: C9x specifies the BSD4.4-Lite behaviour: [#3] ... Thus, the null-terminated output has been completely written if and only if the returned value is less than n. It means that if we not have any null-terminated output as for n == 0 we can't return value less than n, so we forced to return value equal to n i.e. 0 The next good thing is glibc compatibility, of course. 2) Do check for too big n in machine-independent way. 3) Minor optimization assuming EOF is < 0 Revision Changes Path 1.8 +5 -5 src/lib/libc/stdio/snprintf.c 1.8 +5 -5 src/lib/libc/stdio/vsnprintf.c