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!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Weird Bug in Get_Line Date: Wed, 26 Apr 2017 19:03:36 +0200 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <1896933e-e985-420b-a4fe-9cca76af9976@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 26 Apr 2017 17:00:27 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="d32ef2015f3fb48e04cc0229a4348b26"; logging-data="16532"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19f2Mhj1xMvJsiGg/1xqMQfF3ajPmedspU=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: <1896933e-e985-420b-a4fe-9cca76af9976@googlegroups.com> Cancel-Lock: sha1:OqKa7BNiJlNBkpKlffMn+NGokig= Xref: news.eternal-september.org comp.lang.ada:46635 Date: 2017-04-26T19:03:36+02:00 List-Id: On 04/26/2017 09:38 AM, Brian Kolden wrote: > I came across an interesting issue in the Get_Line function. When piping in a > file (using the linux cammand '<') GNAT "raises ADA.IO_EXCEPTIONS.END_ERROR : > a-tigeli.adb:96". > > However, the interesting issue is this only happens for a very small number > of line lengths. I've noticed the exception is only thrown on lines with > length 500, 501, 1000, 1001. Lines bigger or smaller don't seem to raise the > issue, even other multiples of 500. This only is effected when using a file > as input, copying and pasting the line into the terminal does not seem to > trigger it. And also > I forgot to mention the line has to be the very last line, otherwise there > would be no EOF character to read. No newline character should be there, vim > auto inserts one by default, for example. I was also able to trigger it on > Redhat 5.11.0.9 running GNAT 4.1.2. According to the ARM (A.10), Text_IO operates on "text files" as defined there. Part of that definition is that "the end of a line is marked by a _line terminator_" and "the end of a file is marked by the combination of a line terminator immediately followed by a page terminator and then a _file terminator_" [A.10(7)]. So technically, an implementation of Text_IO is not required to work on files that aren't valid Text_IO text files, and the error is that your file is not a valid Text_IO text file. However, such an implementation of Text_IO is pretty useless on most systems, and compiler writers usually try hard to make sure that Text_IO works on foreign files. AdaCore certainly does. Still, if you produce files without a final line terminator, it's usually a good idea to find out why and fix that. -- Jeff Carter "Hold your temper. Count ten.... Now let 'er go. You got a good aim." Never Give a Sucker an Even Break 105