From: "Dmitry A. Kazakov" <[email protected]>
Subject: Re: wait does not perform as expected
Date: Thu, 23 Feb 2023 19:14:38 +0100 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 2023-02-23 18:35, Niklas Holsti wrote:
> On 2023-02-23 16:26, AdaMagica wrote:
>> Niklas Holsti schrieb am Mittwoch, 22. Februar 2023 um 18:36:06 UTC+1:
>>> On my system, Get_Immediate does /not/ use the inputs collected (but not
>>> "consumed") by Look_Ahead, but instead checks if there are _new_ input
>>> keystrokes. If there are none, Get_Immediate returns "not Available"
>>> (Hit is False) and so the loop continues.
>>
>> Are you sure?
>
> That is what I observe.
The implementation of Look_Ahead calls getc followed by ungetc. Thus it
blocks until an input if there is no buffered. And not just input, but
for a line or file end.
As for ungetc POSIX layer under Windows, ungetc probably does not work
correctly, I am too lazy to verify. One possibility is that file
positioning (fseek etc) kill unget buffer.
In any case, subprograms like Look_Ahead, End_Of_File etc exit strictly
for decoration, not for any practical reason. As a rule of thumb no
program should ever use them.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2023-02-23 18:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-22 16:34 wait does not perform as expected Daniel Gaudry
2023-02-22 17:36 ` Niklas Holsti
2023-02-23 14:26 ` AdaMagica
2023-02-23 14:32 ` AdaMagica
2023-02-23 14:33 ` Daniel Gaudry
2023-02-23 14:39 ` AdaMagica
2023-02-23 17:15 ` Niklas Holsti
2023-02-23 17:35 ` Niklas Holsti
2023-02-23 17:49 ` Niklas Holsti
2023-02-23 18:14 ` Dmitry A. Kazakov [this message]
2023-02-23 18:29 ` Niklas Holsti
2023-02-23 18:47 ` Daniel Gaudry
2023-02-23 19:08 ` Niklas Holsti
2023-02-23 19:31 ` Niklas Holsti
2023-02-23 20:41 ` Dmitry A. Kazakov
2023-02-24 15:10 ` AdaMagica
2023-02-24 18:23 ` Niklas Holsti
2023-02-24 21:16 ` Jeffrey R.Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox