Code Monkey home page Code Monkey logo

ksum's People

Contributors

damaki avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sallypemdas

ksum's Issues

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

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

Text mode is ignored on Windows.

When ksum is run on Windows the expected behaviour of --text mode is that CRLF newlines are converted to LF newlines when reading input data. However, file data is always read in binary mode and CRLF are not converted, i.e. --text mode has the same behaviour as --binary on all systems.

After some investigation, this seems to be caused by using Ada.Text_IO.Text_Streams to read from the input files. Even when the file is opened with Form="text_translation=yes", stream reading always sets the file to binary mode before performing the read. See Ada RM A.12.2/6 which mentions mixing text/binary modes for text streams.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.