Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ksum doesn't read past SUB control characters (Windows) #7

Closed
damaki opened this issue Feb 2, 2020 · 0 comments · Fixed by #8
Closed

ksum doesn't read past SUB control characters (Windows) #7

damaki opened this issue Feb 2, 2020 · 0 comments · Fixed by #8
Labels

Comments

@damaki
Copy link
Owner

damaki commented Feb 2, 2020

On Windows, if the file contains SUB control characters 16#1A#, then ksum reaches end-of-file at these bytes. This affects both text and binary modes, although the behaviour is slightly different between the two. In text mode, ksum doesn't read past the first SUB byte. In binary mode, the first read from the file is OK, but the second read will fail in the same way - stopping at the next SUB byte.

This bug does not occur on Linux, so far it has only been encountered on Windows (and not tested on Mac).

After some debugging this seems to be caused by using End_Of_File to determine the end of the file stream. This makes sense since SUB can be used to signal the end of file in text files, and Text_IO is used. An alternative approach could be to use the number of bytes read from the stream as the loop exit condition instead of End_Of_File. E.g. exit when 0 bytes are read.

The version of GNAT I used was GNAT Community 2019 20190517 for Windows x64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant