Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Sep 2001 01:07:43 +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:  <20010901010738.B21988@nagual.pp.ru>
In-Reply-To: <mu9n14g2bq8.wl@cx281057-a.irvn1.occa.home.com>
References:  <200108311950.f7VJoPd48683@freefall.freebsd.org> <mu9n14g2bq8.wl@cx281057-a.irvn1.occa.home.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010901010738.B21988>