From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!news.mb-net.net!open-news-network.org!news.mind.de!bolzen.all.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: wait does not perform as expected Date: Thu, 23 Feb 2023 20:29:32 +0200 Organization: Tidorum Ltd Message-ID: References: <75c3990e-eaab-47eb-bdba-3827b9fd4751n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net YlOxiylQ+fE7qT2KVbHLEwWUftEdxo0EaG6WKF3rvof0HxuE7+ Cancel-Lock: sha1:ghyDZrw4mO1SgCnWP0Xx0ZVB9oE= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US In-Reply-To: Xref: reader01.eternal-september.org comp.lang.ada:64973 List-Id: On 2023-02-23 20:14, Dmitry A. Kazakov wrote: > 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. That seems in order. However, the crux of the question is in Get_Immediate. Do you know how that is implemented on various systems? It has to disable line buffering and line editing on the input stream. One question is whether and how such "tty" configuration changes affect whatever buffers getc/ungetc use. On my system, if Look_Ahead uses getc and ungetc, it seems Get_Immediate does not use the same buffers, and has no effect on those buffers. That could be desirable behaviour in some cases, undesirable in others. On AdaMagica's system, it seems that Get_Immediate uses the same buffers as Look_Ahead (getc/ungetc).