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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Ada.Text_IO.Get_Line issue in windows Date: Tue, 02 Jun 2015 23:32:02 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <556be876$0$2775$c3e8da3$76491128@news.astraweb.com> <4c705bb2-6bf8-4ff2-a3a8-651a5ba204fa@googlegroups.com> <556e96a4$0$11114$c3e8da3@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Wed, 3 Jun 2015 06:30:51 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="a3855fbfe1a666be9aefba0563039ed5"; logging-data="3015"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18KmaHtqSV0y1hZogC9IZE3vcLdarIVXR4=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: <556e96a4$0$11114$c3e8da3@news.astraweb.com> Cancel-Lock: sha1:KG+m+0vr8WNcTjN7cZlAC+ijJk8= Xref: news.eternal-september.org comp.lang.ada:26147 Date: 2015-06-02T23:32:02-07:00 List-Id: On 06/02/2015 10:54 PM, tornenvi wrote: > > I believe I have found the problem in that file (a-tigeli.adb) > > I believe line 193 which is > > elsif ch /= LM then > > should read > > elsif ch /= LM and ch /=EOF then In context, this is ch := Getc (File); -- If we get EOF after already reading data, this is an incomplete -- last line, in which case no End_Error should be raised. if ch = EOF and then Last < Item'First then raise End_Error; elsif ch /= LM then -- Buffer really is full without having seen LM, update col Last := Last + 1; Item (Last) := Character'Val (ch); File.Col := File.Col + Count (Last - Item'First + 1); return; end if; We can see that if EOF is encountered after reading characters into Item then the EOF is incorrectly stored in Item, so you have found an error in Get_Line. While your change will work, it might be better to rewrite the "if" as if ch = EOF then if Last < Item'First then raise End_Error; end if; elsif ch = LM then null; else -- ch /= EOF and ch /= LM ... end if; to divide the code into the 3 cases of interest: EOF, in which case we either raise End_Error or do nothing, depending on Last; LM, do nothing; and anything else, store the character in Item. It's disturbing that EOF can be converted into a valid Character. -- Jeff Carter "Frankie Wolf, wanted by Federal authorities for dancing with a mailman." Take the Money and Run 143