From owner-cvs-lib Wed Dec 24 04:35:51 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id EAA05159 for cvs-lib-outgoing; Wed, 24 Dec 1997 04:35:51 -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 EAA05116; Wed, 24 Dec 1997 04:35:19 -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 EAA19337; Wed, 24 Dec 1997 04:31:37 -0800 (PST) Date: Wed, 24 Dec 1997 04:31:37 -0800 (PST) Message-Id: <199712241231.EAA19337@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 04:31:35 PST Modified files: lib/libc/stdio snprintf.c vsnprintf.c Log: snprintf return value fixes to conform Single Unix specs: 1) if buffer size is smaller than arguments size, return buffer size, not arguments size as before. 2) if buffer size is 0, return 0, not EOF as before. (now it is compatible with Linux and Apache implementations too). NOTE: Single Unix specs says: If the value of n {buffer size} is zero on a call to snprintf(), an unspecified value less than 1 is returned. It means we can't return EOF since EOF can take *any* value in general not especially < 1. Better variant will be return -1 (it is less then 1 and different with n == 1 case) but -1 value is already occuped by EOF in our implementation, so we can't distinguish true IO error in that case. So 0 here is only possible case still conforming to Single Unix specs. Revision Changes Path 1.6 +8 -3 src/lib/libc/stdio/snprintf.c 1.6 +8 -3 src/lib/libc/stdio/vsnprintf.c