Deutsch   English   Français   Italiano  
<vn07r3$28bkd$3@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: James Kuyper <jameskuyper@alumni.caltech.edu>
Newsgroups: comp.lang.c
Subject: Re: C90 fpeek
Date: Fri, 24 Jan 2025 09:24:35 -0500
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <vn07r3$28bkd$3@dont-email.me>
References: <vmv082$1u6pm$1@dont-email.me>
 <87plkc6bgm.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 24 Jan 2025 15:24:36 +0100 (CET)
Injection-Info: dont-email.me; posting-host="3b73afc4db4b2cef9846b763bdfb0026";
	logging-data="2371213"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19GBor+q1Uwl+oBypA8MGrXNTQZ4hZqocQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:RNoAuz8+tt7EqOSXqPVaOWDswrE=
Content-Language: en-US
In-Reply-To: <87plkc6bgm.fsf@nosuchdomain.example.com>
Bytes: 2085

On 1/24/25 00:13, Keith Thompson wrote:
> "Paul Edwards" <mutazilah@gmail.com> writes:
> [...]
>> With the benefit of hindsight, is there any reason why fpeek
>> couldn't have been added to C90, with implementations
>> being allowed with just a macro that returns some sort of
>> "unsupported"?
>>
>> If fpeek (or similar) makes sense, can someone suggest an
>> appropriate interface?
> [...]
> 
> It would help to know what "fpeek" is supposed to do.  There no such
> function in any edition of the C standard or in any implementation
> that I'm aware of.

A google search uncovered a stackoverflow question for which the answer was:

int fpeek(FILE *stream)
{
    int c;

    c = fgetc(stream);
    ungetc(c, stream);

    return c;
}

I don't see any reason why such a function is needed in the standard
library. However, if it were added, since fgetc() and ungetc() are
mandatory for hosted implementations, I also see no reason to allow for
it to be unsupported.