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

Making ByteString.hGetLine behave like System.IO.hGetLine #327

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Commits on Oct 28, 2020

  1. Made BS.hGetLine's behavior like hGetLine.

    This closes issue haskell#13.
    
    The changes can be summarized as
    updating `findEOL` to look for "\r\n" in CRLF mode
    and updating the logic of `haveBuf` to resize the buffer
    according to the size of the newline.
    
    Additionally, tests were added to verify that both
    `hGetLine`s produce the same behavior.
    
    Some of the edge-cases to worry about here include
    
    * '\n' still counts as a line end.
    
        Thus line endings' length vary between 1 and 2 in CRLF mode.
    * "\r\r\n" can give a false-start.
    
        This means you can't always skip 2 characters when `c' /= '\n'`.
    * '\r' when not followed by '\n' isn't part of a newline.
    * Not reading out of the buffer when '\r' is the last character.
    dbramucci committed Oct 28, 2020
    Configuration menu
    Copy the full SHA
    5b169ec View commit details
    Browse the repository at this point in the history

Commits on Nov 7, 2020

  1. Configuration menu
    Copy the full SHA
    a70a788 View commit details
    Browse the repository at this point in the history
  2. Removed the redundant test for hGetLine.

    The old test had wrote a special file filled with strange line endings.
    Now that there is a reliable,
    and consistent property test available for hGetLine,
    this code can be removed at little cost.
    dbramucci committed Nov 7, 2020
    Configuration menu
    Copy the full SHA
    537080c View commit details
    Browse the repository at this point in the history

Commits on Nov 22, 2020

  1. Configuration menu
    Copy the full SHA
    a3d4c5f View commit details
    Browse the repository at this point in the history

Commits on Nov 27, 2020

  1. Cleaned up prop_hgetline_like_s8_hgetline and fixed a Windows testing…

    … bug.
    
    On Windows, the test data would be written using the platform newlines.
    This means that any lone \n would become a \r\n.
    The consequence is that the property would fail to test the
    implementation on linux line endings when developing on windows.
    The fix is to set the newlineMode to noNewlineTranslation before
    writing the test data.
    dbramucci committed Nov 27, 2020
    Configuration menu
    Copy the full SHA
    6f6a098 View commit details
    Browse the repository at this point in the history
  2. Slight tweak to hgetline property's newlines.

    The variables were renamed to make boolean correspondance clearer.
    Also, True was changed to CRLF in order to get QuickCheck to
    try shrinking from CRLF to LF if possible.
    dbramucci committed Nov 27, 2020
    Configuration menu
    Copy the full SHA
    3e34f48 View commit details
    Browse the repository at this point in the history