summaryrefslogtreecommitdiffstats
path: root/Source/cmListFileCache.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmListFileCache.cxx')
-rw-r--r--Source/cmListFileCache.cxx15
1 files changed, 14 insertions, 1 deletions
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 898f379..f6ea4b1 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -57,13 +57,26 @@ cmListFileParser::~cmListFileParser()
bool cmListFileParser::ParseFile()
{
// Open the file.
- if(!cmListFileLexer_SetFileName(this->Lexer, this->FileName))
+ cmListFileLexer_BOM bom;
+ if(!cmListFileLexer_SetFileName(this->Lexer, this->FileName, &bom))
{
cmSystemTools::Error("cmListFileCache: error can not open file ",
this->FileName);
return false;
}
+ // Verify the Byte-Order-Mark, if any.
+ if(bom != cmListFileLexer_BOM_None &&
+ bom != cmListFileLexer_BOM_UTF8)
+ {
+ cmListFileLexer_SetFileName(this->Lexer, 0, 0);
+ cmOStringStream m;
+ m << "File\n " << this->FileName << "\n"
+ << "starts with a Byte-Order-Mark that is not UTF-8.";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str());
+ return false;
+ }
+
// Use a simple recursive-descent parser to process the token
// stream.
bool haveNewline = true;