comp.lang.ada
 help / color / mirror / Atom feed
From: tornenvi <tornenvi@gmail.com>
Subject: Re: Ada.Text_IO.Get_Line issue in windows
Date: Fri, 05 Jun 2015 13:40:26 +0930
Date: 2015-06-05T13:40:26+09:30	[thread overview]
Message-ID: <55712134$0$12900$c3e8da3$5496439d@news.astraweb.com> (raw)
In-Reply-To: <mkm6up$2u7$1@dont-email.me>

On 6/3/2015 4:02 PM, Jeffrey R. Carter wrote:
> 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.
>

I have already reported the bug on bugzilla, the link to it is below.

   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66390

You can add your suggested change to the bug report, or I can update it if you like.
However I'm not set up to report patch files (tested) so I am only
adding the changes as comments to the bug report.

Also note that line 84 of \gcc\ada\a-tigeli.adb reads

   memset (S, 10, size_t (N));

I believe the hardcoded '10' here should be 'LM'.

I have added it as a comment to the bug report.




  reply	other threads:[~2015-06-05  4:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01  5:07 Ada.Text_IO.Get_Line issue in windows tornenvi
2015-06-02  2:44 ` AdaMagica
2015-06-03  5:54   ` tornenvi
2015-06-03  6:32     ` Jeffrey R. Carter
2015-06-05  4:10       ` tornenvi [this message]
2015-06-03  7:02 ` Simon Wright
2015-06-03 10:08   ` Simon Clubley
2015-06-03 11:14     ` Simon Wright
2015-06-08 22:47 ` wowwomenonwheels205
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox