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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,386228a37afe967f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-17 02:38:25 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!uninett.no!ntnu.no!not-for-mail From: Preben Randhol Newsgroups: comp.lang.ada Subject: Re: Computer Language Shootout Date: Thu, 17 Jul 2003 09:38:25 +0000 (UTC) Organization: Norwegian university of science and technology Message-ID: References: <1ec946d1.0307150715.4ba69f85@posting.google.com> <3F149243.80304@attbi.com> <3F15930C.2070907@attbi.com> NNTP-Posting-Host: kiuk0152.chembio.ntnu.no X-Trace: tyfon.itea.ntnu.no 1058434705 552 129.241.83.78 (17 Jul 2003 09:38:25 GMT) X-Complaints-To: usenet@itea.ntnu.no NNTP-Posting-Date: Thu, 17 Jul 2003 09:38:25 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:40394 Date: 2003-07-17T09:38:25+00:00 List-Id: Robert I. Eachus wrote: > Matthew Heaney wrote: > >> Do you really mean that End_Of_File and Get_Line use Current_Output? I >> thought they used Current_Input. > > Oops! That's what I get for posting after midnight. > >> Aside: I don't ever use End_Of_Line, since the locution >> >> if Last < Line'Last then >> >> conveys all the information I need wrt whether the entire line has been >> consumed. What is End_Of_Line buying me that the idiom above does not? > > Has the actual end of line been consumed? If the line is the same > length as your buffer, the Get_Line can read exactly Last characters but > still be positioned at the end of line. In one case, you will be left > at the end of line, and in the other you won't. I sometimes use this procedure: procedure Get_Whole_Line (File : in File_Type; Item : out String; Last : out Natural) is begin Get_Line (File => File, Item => Item, Last => Last); if Last = Item'Last then -- The line was longer than allowed, skipping the rest. -- Can also raise an exception if necessary. Skip_Line (File => File); else -- Just to remove the extras although it is not really -- necessary, can be skipped. Fixed.Delete (Source => Item, From => Last + 1, Through => Item'Last); end if; end Get_Whole_Line; if I only want to read characters until Item'Last from a file and consider the rest the line as junk. > case I think you can read and count a bogus line if the input line is > exactly 133 characters long. The first read will get all 133 > characters, the second will get no characters and the new line. But the first is not counted only the second as Last < Item'Last, so I think it should be correct. -- Ada95 is good for you. http://www.crystalcode.com/codemage/MainMenu/Coding/Ada/IntroducingAda.php