diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2021-01-29 10:57:03 (GMT) |
---|---|---|
committer | Cristian Adam <cristian.adam@gmail.com> | 2021-01-29 13:25:33 (GMT) |
commit | 6e225efd8cd1c20bd45c062b168d79a6addb78e5 (patch) | |
tree | 6dbb81a6e9e86bf0717485430d0dba44a0980384 /Source | |
parent | 59b5b6e11c243e4d45e57caf939107ef9fc44c75 (diff) | |
download | CMake-6e225efd8cd1c20bd45c062b168d79a6addb78e5.zip CMake-6e225efd8cd1c20bd45c062b168d79a6addb78e5.tar.gz CMake-6e225efd8cd1c20bd45c062b168d79a6addb78e5.tar.bz2 |
file(CONFIGURE): Fix newlines in CONTENT
Fixes: #21749
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFileCommand.cxx | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 576f015..9377baa 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3105,15 +3105,13 @@ bool HandleConfigureCommand(std::vector<std::string> const& args, cmSystemTools::MakeDirectory(path); } - std::string newLineCharacters; - bool open_with_binary_flag = false; + std::string newLineCharacters = "\n"; if (newLineStyle.IsValid()) { - open_with_binary_flag = true; newLineCharacters = newLineStyle.GetCharacters(); } cmGeneratedFileStream fout; - fout.Open(outputFile, false, open_with_binary_flag); + fout.Open(outputFile, false, true); if (!fout) { cmSystemTools::Error("Could not open file for write in copy operation " + outputFile); @@ -3126,11 +3124,15 @@ bool HandleConfigureCommand(std::vector<std::string> const& args, std::stringstream sin(parsedArgs.Content, std::ios::in); std::string inLine; std::string outLine; - while (cmSystemTools::GetLineFromStream(sin, inLine)) { + bool hasNewLine = false; + while (cmSystemTools::GetLineFromStream(sin, inLine, &hasNewLine)) { outLine.clear(); makeFile.ConfigureString(inLine, outLine, parsedArgs.AtOnly, parsedArgs.EscapeQuotes); - fout << outLine << newLineCharacters; + fout << outLine; + if (hasNewLine || newLineStyle.IsValid()) { + fout << newLineCharacters; + } } // close file before attempting to copy |