From owner-cvs-all Fri Aug 31 15:48:17 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 7840037B405; Fri, 31 Aug 2001 15:48:09 -0700 (PDT) Received: (from ache@localhost) by nagual.pp.ru (8.11.6/8.11.6) id f7VMlue23461; Sat, 1 Sep 2001 02:47:56 +0400 (MSD) (envelope-from ache) Date: Sat, 1 Sep 2001 02:47:51 +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: <20010901024748.A23318@nagual.pp.ru> References: <200108311950.f7VJoPd48683@freefall.freebsd.org> <20010901010738.B21988@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20010901010738.B21988@nagual.pp.ru> 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 Sat, Sep 01, 2001 at 01:07:43 +0400, Andrey A. Chernov wrote: Really, allowing ungetc() at 0 cause direct conflicts inside POSIX specs. Lets look: > 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. Unspecified == any. Lets consider all possible variants. 1) Unspecified < 0 (as it was in FreeBSD). It is in coflict with POSIX specs about ftell(): Upon successful completion, ftell( ) and ftello ( ) shall return the current value of the file-position indicator for the stream measured in bytes from the beginning of the file. Otherwise, ftell( ) and ftello ( ) shall return -1, cast to long and off_t ^^^^^^^^^^ respectively, and set errno to indicate the error. It says "otherwise", i.e. ftell() can't return -1 normally, so we are in conflict. Moreover, offset calculation procedure is in conflict with fseek() for which POSIX directly disable negative offsets: [EINVAL] ... The resulting file-position indicator would be set to a negative value. 2) Unspecified >= 0 Look at another place of ungetc() description: The value of the file-position indicator for the stream after reading or discarding all pushed-back bytes shall be the same as it was before the bytes were pushed back. ^^^^^^^^ We can't make it "the same" in this case, because have value >= 0 as non-unique. -- 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