diff options
author | Clinton Stimpson <clinton@elemtech.com> | 2014-03-07 05:55:07 (GMT) |
---|---|---|
committer | Clinton Stimpson <clinton@elemtech.com> | 2014-03-17 20:01:55 (GMT) |
commit | 98383f802aadcd2d469c4d7543e0a2abe8c3cdb9 (patch) | |
tree | 86a419ec22832a1597b52da6d85b1d989cb1fbea /Source/cmMakefile.cxx | |
parent | e21ffaf8fe5499426604b4ebb9cd08798ee6107c (diff) | |
download | CMake-98383f802aadcd2d469c4d7543e0a2abe8c3cdb9.zip CMake-98383f802aadcd2d469c4d7543e0a2abe8c3cdb9.tar.gz CMake-98383f802aadcd2d469c4d7543e0a2abe8c3cdb9.tar.bz2 |
Unicode: check encoding of files given to configure_file.
UTF-16 and UTF-32 files are rejected.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 92177c8..d0e6c30 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3518,6 +3518,20 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, return 0; } + cmsys::FStream::BOM bom = cmsys::FStream::ReadBOM(fin); + if(bom != cmsys::FStream::BOM_None && + bom != cmsys::FStream::BOM_UTF8) + { + cmOStringStream e; + e << "File starts with a Byte-Order-Mark that is not UTF-8:\n " + << sinfile; + this->IssueMessage(cmake::FATAL_ERROR, e.str()); + return 0; + } + // rewind to copy BOM to output file + fin.seekg(0); + + // now copy input to output and expand variables in the // input file at the same time std::string inLine; |