summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorPeter Kuemmel <syntheticpp@gmx.net>2011-11-20 13:04:11 (GMT)
committerBrad King <brad.king@kitware.com>2011-11-28 18:48:59 (GMT)
commita087490697c416d429d30fdf389cca2f13d9d14e (patch)
treecad0b1147f3451b012f0b4d2cd474452721315fb /Source/cmMakefile.cxx
parent6580434f16cf4c6db1fde6d804e95d40f27c0f45 (diff)
downloadCMake-a087490697c416d429d30fdf389cca2f13d9d14e.zip
CMake-a087490697c416d429d30fdf389cca2f13d9d14e.tar.gz
CMake-a087490697c416d429d30fdf389cca2f13d9d14e.tar.bz2
Add NEWLINE_STYLE option to configure_file (#3957)
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx18
1 files changed, 15 insertions, 3 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 573c430..7939d73 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3213,7 +3213,8 @@ void cmMakefile::ConfigureString(const std::string& input,
}
int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
- bool copyonly, bool atOnly, bool escapeQuotes)
+ bool copyonly, bool atOnly, bool escapeQuotes,
+ const cmNewLineStyle& newLine)
{
int res = 1;
if ( !this->CanIWriteThisFile(outfile) )
@@ -3250,9 +3251,20 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
}
else
{
+ std::string newLineCharacters;
+ std::ios_base::openmode omode = std::ios_base::out | std::ios_base::trunc;
+ if (newLine.IsValid())
+ {
+ newLineCharacters = newLine.GetCharacters();
+ omode |= std::ios::binary;
+ }
+ else
+ {
+ newLineCharacters = "\n";
+ }
std::string tempOutputFile = soutfile;
tempOutputFile += ".tmp";
- std::ofstream fout(tempOutputFile.c_str());
+ std::ofstream fout(tempOutputFile.c_str(), omode);
if(!fout)
{
cmSystemTools::Error(
@@ -3277,7 +3289,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
{
outLine = "";
this->ConfigureString(inLine, outLine, atOnly, escapeQuotes);
- fout << outLine.c_str() << "\n";
+ fout << outLine.c_str() << newLineCharacters;
}
// close the files before attempting to copy
fin.close();