Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: "Paul Edwards" Newsgroups: comp.lang.c Subject: Re: C90 fpeek Date: Fri, 24 Jan 2025 16:41:39 +1100 Organization: A noiseless patient Spider Lines: 38 Message-ID: References: <87plkc6bgm.fsf@nosuchdomain.example.com> Injection-Date: Fri, 24 Jan 2025 06:41:45 +0100 (CET) Injection-Info: dont-email.me; posting-host="fda4a84c3bda6e185fc69fc9e52e89a8"; logging-data="2208950"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Yk8sUYkE9ivJ6GzTAzPfaT2HJEk3rRcw=" Cancel-Lock: sha1:TX3s1U/Ns34Cc2mNEr0sQg2D6XQ= X-MSMail-Priority: Normal X-Priority: 3 X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Bytes: 2376 "Keith Thompson" wrote in message news:87plkc6bgm.fsf@nosuchdomain.example.com... > "Paul Edwards" 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. fpeek would tell you whether there are any characters available to be read, on a bidirectional data stream, opened with r+b or whatever. For an ordinary disk file, it wouldn't necessarily do anything, and just return with "unknown" or whatever, for the application to decide what to do. But for a serial port/modem connected to a BBS, the infrastructure would likely already know if there are characters sitting at the COM port (or some corresponding buffer), so it would be in a position to confirm/deny the presence of pending characters to be read. It also occurred to me that games could use this, fpeek of stdin to see if a key has been pressed. Apologies for not making this clearer in the original post. BFN. Paul.