summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-02-01 15:06:20 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-02-01 15:06:27 (GMT)
commita28bb8de23ea27060b39e31d3a96f53260c65d42 (patch)
treed99d2300002ee7adfa5fe5e1a8843810c21c57fd /Source
parente9875b6164ae7d7cb4f8ff70d62bf71b32b31a9e (diff)
parent6e225efd8cd1c20bd45c062b168d79a6addb78e5 (diff)
downloadCMake-a28bb8de23ea27060b39e31d3a96f53260c65d42.zip
CMake-a28bb8de23ea27060b39e31d3a96f53260c65d42.tar.gz
CMake-a28bb8de23ea27060b39e31d3a96f53260c65d42.tar.bz2
Merge topic 'file-configure-newline'
6e225efd8c file(CONFIGURE): Fix newlines in CONTENT Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5747
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFileCommand.cxx14
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