From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, LOTS_OF_MONEY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a8525c0786dd76cb X-Google-Attributes: gid103376,public From: "Randy Brukardt" Subject: Re: Possible gnat and ObjectAda bugs? Date: 2000/11/27 Message-ID: <_hzU5.244$GX6.97465@homer.alpha.net>#1/1 X-Deja-AN: 698367599 References: <9VPT5.39609$A2.8013565@newsrump.sjc.telocity.net> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3719.2500 X-Complaints-To: abuse@alpha.net X-Trace: homer.alpha.net 975356154 156.46.62.124 (Mon, 27 Nov 2000 14:15:54 CST) NNTP-Posting-Date: Mon, 27 Nov 2000 14:15:54 CST Newsgroups: comp.lang.ada Date: 2000-11-27T00:00:00+00:00 List-Id: David C. Hoos, Sr. wrote in message <9VPT5.39609$A2.8013565@newsrump.sjc.telocity.net>... >The code at the end of this message produces strange results with GNAT >3.13p, and even more bizarre results with ObjectAda 7.1: > >What is strange is that when Standard Input is from the keyboard, the >program does not enter the loop until the enter key has been pressed. > >Is this a bug, or am I missing something here? You're missing something. A correct implementation of End_of_File has to look past a line terminator and page terminator to check for a file terminator. This means it has to read from the input. Presumably, the implementations you tried did that in "cooked" mode, meaning that you have to enter an entire line before the program gets any of it. (This is the way that Janus/Ada works.) However, your code shows that you are trying to use Get_Immediate, which reads in raw mode (keys are immediately returned to the program). But that won't happen, because End_of_File has already done the read in "cooked" mode. Certainly, you should never use any of the End_of_xxx functions with Get_Immediate. Moreover (because of the lookahead), I'd recommend never using them when you want to read from the keyboard (even in "cooked" mode). Indeed, my personal style is to never use them at all, because they are pretty complex, and thus slow the program down a bit. The check for End_Error is always done in Text_IO whether you handle it or not, so that is essentially free. So the only cost is for the End_Error handler; I recommend putting it outside the loop (so it isn't entered and left many times), but otherwise its function isn't critical (it only is executed once per file). Randy.