Skip to content

SystemTools: fix GetLineFromStream for Mac OS X 10.7

Peter Wu requested to merge Lekensteyn/kwsys:getline-fixes into master

LLVM libstdc++ 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. Since the character is lost, this would could potentially be fixed by "is.unget", but let's go for the "trivially" correct implementation to avoid hitting other issues (such as strings that were not nul-terminated in some versions of LLVM libstdc++).

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", see cmake/cmake#15039 (closed)

Tested with Mac OS X 10.7 and 10.11 (-DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 -DCMAKE_CXX_FLAGS=-stdlib=libc++) and "./kwsysTestsCxx testSystemTools".

Merge request reports

Loading