From owner-cvs-all Fri Aug 31 14: 8:10 2001 Delivered-To: cvs-all@freebsd.org Received: from nagual.pp.ru (pobrecita.freebsd.ru [194.87.13.42]) by hub.freebsd.org (Postfix) with ESMTP id 75D3737B407; Fri, 31 Aug 2001 14:08:03 -0700 (PDT) Received: (from ache@localhost) by nagual.pp.ru (8.11.6/8.11.6) id f7VL7mh22261; Sat, 1 Sep 2001 01:07:49 +0400 (MSD) (envelope-from ache) Date: Sat, 1 Sep 2001 01:07:43 +0400 From: "Andrey A. Chernov" To: "Peter S. Housel" Cc: cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Subject: Re: cvs commit: src/lib/libc/stdio ftell.c ungetc.c Message-ID: <20010901010738.B21988@nagual.pp.ru> References: <200108311950.f7VJoPd48683@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.21i Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Aug 31, 2001 at 13:52:47 -0700, Peter S. Housel wrote: > > Section 7.19.7.11 of ISO/IEC 9899:1999 says that one character of > ungetc is guaranteed. It also says that the file position indicator > value is indeterminate if was zero before the call. > > Section 7.26.9 says that pusing back characters at position 0 is an > "obsolescent feature" that will probably go away in the next revision > of the standard. But that doesn't mean you can disallow it now. 1) The pure reason behind all of this is that ungetc() at 0 cause resulting negative file offset, f.e. -1, which is disallowed by POSIX for stdio and is the same as fseek/ftell error code. 2) This issue not related to one character buffer at all. One character buffer is size of storage (really FreeBSD have it limited by malloc() only), not conditions ungetc() fail. 3) Use more recent POSIX document: IEEE P1003.1 Draft 6, April 2001, it says for ungetc(): 48179 .... If ungetc() is called too many times on the same stream 48180 without an intervening read or file-positioning operation on that stream, the operation may fail. 48185 .... The file-position indicator is decremented 48186 by each successful call to ungetc(); if its value was 0 before a call, its value is unspecified after 48187 the call. What I implement are 'too many times' and 'unspecified' conditions. -- Andrey A. Chernov http://ache.pp.ru/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message