Date: Sat, 1 Sep 2001 02:47:51 +0400 From: "Andrey A. Chernov" <ache@nagual.pp.ru> To: "Peter S. Housel" <housel@acm.org> 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> In-Reply-To: <20010901010738.B21988@nagual.pp.ru> References: <200108311950.f7VJoPd48683@freefall.freebsd.org> <mu9n14g2bq8.wl@cx281057-a.irvn1.occa.home.com> <20010901010738.B21988@nagual.pp.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010901024748.A23318>