Skip to content
  • Tim-Philipp Müller's avatar
    orcc: fix reading .orc files with win32 line endings on windows · 1430f02c
    Tim-Philipp Müller authored
    We used to open the files in text/translation mode, which
    makes fread() convert all windows-style line endings (\r\n)
    to unix style line endings (\n) under the hood. However, the
    file size we get from the seek is apparently still the original
    binary size, and then we just get less data because the \r have
    been removed. This means we put our zero terminator in the wrong
    place, and there might be some junk between the end of the
    text data and the zero terminator.
    
    Fix this by reading the file in binary mode (who knows what
    else the text mode might mess up or trip over, e.g. unicode
    chars in comments or such) and pass it to the orc parser
    as-is now that the parser can handle win32 line endings.
    
    Spotted by Ray Molenkamp.
    1430f02c