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-Thread: 103376,68cd50941308f5a9 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s72.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: End_Of_File but not really References: <1165514423.562024.70510@j72g2000cwa.googlegroups.com> In-Reply-To: <1165514423.562024.70510@j72g2000cwa.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s72 1165522642 12.201.97.213 (Thu, 07 Dec 2006 20:17:22 GMT) NNTP-Posting-Date: Thu, 07 Dec 2006 20:17:22 GMT Date: Thu, 07 Dec 2006 20:17:22 GMT Xref: g2news2.google.com comp.lang.ada:7855 Date: 2006-12-07T20:17:22+00:00 List-Id: Adam Beneschan wrote: > > If I try this on Linux, on a file whose bytes are abc, then the > message "End_Of_File returned TRUE but Get_Line did not raise an > exception". This strikes me as bizarre---if End_Of_File returns True, > then a subsequent read operation should raise an End_Error, but that > isn't what's happening. One of these must be true: This is the behavior I described in an earlier post. From a Text_IO point of view, this is a degenerate file, since it doesn't end in . But consider if you wrote this file with Text_IO: File : Ada.Text_IO.File_Type; ... Ada.Text_IO.Create (File => File, Mode => Ada.Text_IO.Out_File, Name => "f1"); Ada.Text_IO.Put_Line (File => File, Item => "abc"); Ada.Text_IO.Put_Line (File => File, Item => ""); Ada.Text_IO.Close (File => File); Then you would get what Text_IO considers a correct text file, containing abc (however those are encoded for your OS/compiler). After the first Get_Line, the remainder of the file contains --the definition of the condition when End_Of_File returns True. Yet clearly there is an empty line still to be read in that file, since it was created by writing "abc" followed by writing an empty line. So the situation you describe is true even for a file written by Text_IO: End_Of_File returns True and Get_Line reads an empty string. Another way of looking at it: End_Of_File looks ahead and sees , so it returns True. Get_Line reads , so it sets Last to Item'First - 1 and returns. I'm not saying this is sensible, just that it's what the RM specifies. Text_IO would be better without pages, and without column and line (and page) counting. -- Jeff Carter "Every sperm is sacred." Monty Python's the Meaning of Life 55