Skip to content
Snippets Groups Projects
Commit 898dc6b9 authored by Peter Wu's avatar Peter Wu Committed by Brad King
Browse files

SystemTools: Fix GetLineFromStream to avoid libc++ bug on OS X 10.7

LLVM libc++ as included with Mac OS X 10.7 suffers from an issue where
the trailing character is discarded when the delimiter (LF) is not found
within the given buffer size (1024).  The returned length is also 1024
rather than 1023.

This issue results in truncated reads as observed with CMake 3.11.0 on
Mac OS X 10.7 and `cmake -E cmake_link_script link.txt`.

Solve this by replacing `istream::getline` by `std::getline` which does
not trigger the buffering issue.  There is one edge case that I decided
to leave up to the callers though: a file containing `\0` previously
resulted in line truncation, but is now included in the result.

Tested with Mac OS X 10.7 and 10.11:

    -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 -DCMAKE_CXX_FLAGS=-stdlib=libc++

and `./kwsysTestsCxx testSystemTools`.

Issue: cmake/cmake#15039
parent 5f757898
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment