summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2016-06-09 07:58:15 (GMT)
committerStephen Kelly <steveire@gmail.com>2016-06-13 18:19:16 (GMT)
commit0a9094cd1017057d3c5141fdacdc6a89fb14acfc (patch)
tree803e0f4f68a99a197cb765719d3ad9eb1cbee419
parent8d80c8961fce8f4b38f412de664f773c213a69b8 (diff)
downloadCMake-0a9094cd1017057d3c5141fdacdc6a89fb14acfc.zip
CMake-0a9094cd1017057d3c5141fdacdc6a89fb14acfc.tar.gz
CMake-0a9094cd1017057d3c5141fdacdc6a89fb14acfc.tar.bz2
Parser: Issue file open error messages through dedicated API
-rw-r--r--Source/cmListFileCache.cxx15
-rw-r--r--Tests/RunCMake/Syntax/BOM-UTF-16-BE-stderr.txt6
-rw-r--r--Tests/RunCMake/Syntax/BOM-UTF-16-LE-stderr.txt6
-rw-r--r--Tests/RunCMake/Syntax/BOM-UTF-32-BE-stderr.txt6
-rw-r--r--Tests/RunCMake/Syntax/BOM-UTF-32-LE-stderr.txt6
5 files changed, 13 insertions, 26 deletions
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 036a2b1..4df542f 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -23,6 +23,7 @@ struct cmListFileParser
{
cmListFileParser(cmListFile* lf, cmMakefile* mf, const char* filename);
~cmListFileParser();
+ void IssueFileOpenError(std::string const& text) const;
bool ParseFile();
bool ParseFunction(const char* name, long line);
bool AddArgument(cmListFileLexer_Token* token,
@@ -54,23 +55,25 @@ cmListFileParser::~cmListFileParser()
cmListFileLexer_Delete(this->Lexer);
}
+void cmListFileParser::IssueFileOpenError(const std::string& text) const
+{
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, text);
+}
+
bool cmListFileParser::ParseFile()
{
// Open the file.
cmListFileLexer_BOM bom;
if (!cmListFileLexer_SetFileName(this->Lexer, this->FileName, &bom)) {
- cmSystemTools::Error("cmListFileCache: error can not open file ",
- this->FileName);
+ this->IssueFileOpenError("cmListFileCache: error can not open file.");
return false;
}
// Verify the Byte-Order-Mark, if any.
if (bom != cmListFileLexer_BOM_None && bom != cmListFileLexer_BOM_UTF8) {
cmListFileLexer_SetFileName(this->Lexer, 0, 0);
- std::ostringstream 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());
+ this->IssueFileOpenError(
+ "File starts with a Byte-Order-Mark that is not UTF-8.");
return false;
}
diff --git a/Tests/RunCMake/Syntax/BOM-UTF-16-BE-stderr.txt b/Tests/RunCMake/Syntax/BOM-UTF-16-BE-stderr.txt
index a845ffb..f0b6783 100644
--- a/Tests/RunCMake/Syntax/BOM-UTF-16-BE-stderr.txt
+++ b/Tests/RunCMake/Syntax/BOM-UTF-16-BE-stderr.txt
@@ -1,8 +1,4 @@
CMake Error in BOM-UTF-16-BE.cmake:
- File
-
- .*/Tests/RunCMake/Syntax/BOM-UTF-16-BE.cmake
-
- starts with a Byte-Order-Mark that is not UTF-8.
+ File starts with a Byte-Order-Mark that is not UTF-8.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/BOM-UTF-16-LE-stderr.txt b/Tests/RunCMake/Syntax/BOM-UTF-16-LE-stderr.txt
index cc4244b..bcc9c38 100644
--- a/Tests/RunCMake/Syntax/BOM-UTF-16-LE-stderr.txt
+++ b/Tests/RunCMake/Syntax/BOM-UTF-16-LE-stderr.txt
@@ -1,8 +1,4 @@
CMake Error in BOM-UTF-16-LE.cmake:
- File
-
- .*/Tests/RunCMake/Syntax/BOM-UTF-16-LE.cmake
-
- starts with a Byte-Order-Mark that is not UTF-8.
+ File starts with a Byte-Order-Mark that is not UTF-8.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/BOM-UTF-32-BE-stderr.txt b/Tests/RunCMake/Syntax/BOM-UTF-32-BE-stderr.txt
index 5f851bf..7bd74c9 100644
--- a/Tests/RunCMake/Syntax/BOM-UTF-32-BE-stderr.txt
+++ b/Tests/RunCMake/Syntax/BOM-UTF-32-BE-stderr.txt
@@ -1,8 +1,4 @@
CMake Error in BOM-UTF-32-BE.cmake:
- File
-
- .*/Tests/RunCMake/Syntax/BOM-UTF-32-BE.cmake
-
- starts with a Byte-Order-Mark that is not UTF-8.
+ File starts with a Byte-Order-Mark that is not UTF-8.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/BOM-UTF-32-LE-stderr.txt b/Tests/RunCMake/Syntax/BOM-UTF-32-LE-stderr.txt
index d8fafd0..678013f 100644
--- a/Tests/RunCMake/Syntax/BOM-UTF-32-LE-stderr.txt
+++ b/Tests/RunCMake/Syntax/BOM-UTF-32-LE-stderr.txt
@@ -1,8 +1,4 @@
CMake Error in BOM-UTF-32-LE.cmake:
- File
-
- .*/Tests/RunCMake/Syntax/BOM-UTF-32-LE.cmake
-
- starts with a Byte-Order-Mark that is not UTF-8.
+ File starts with a Byte-Order-Mark that is not UTF-8.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)