Bug in GNAT Ada.Text_IO.Get_Line

About 20 years ago I noted a bug in Ada.Text_IO.Get_Line. The bug affects files where the LF is missing on the last line and the length of last line is multiple of the internal buffer length. Very obscure.

Back then I wrote a workaround but today I noted that it’s not needed as AdaCore has fixed the bug. :tada: β€” Only, AdaCore did not fix the bug in Ada.Wide_Text_IO.Get_Line and Ada.Wide_Wide_Text_IO.Get_Line. :persevere:.

You can see the bug in the source code. Im Ada.Text_IO line 752 you can see the check for End_Of_File while in Ada.Wide_Text_IO the check for End_Of_File is missing.

And worse of all: my workaround is not working any more because Get_Line will now try to read arbitrary long lines.

1 Like

I have corrected version of Get_Line in AdaCL.Wide_Strings.IO and AdaCL.Wide_Wide_Strings.IO.

There are alse unit test in AdaCL.Wide_Strings.IO.Test and AdaCL.Wide_Wide_Strings.IO.Test so I know it actually works.

1 Like