From 8591786867111568298394242a80ddc0a321f5ad Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 2 Oct 2001 17:28:55 -0400 Subject: ENH: add better error reports in parsing cmake files, like what file has the error --- Source/cmListFileCache.cxx | 3 ++- Source/cmMakefile.cxx | 4 +++- Source/cmSystemTools.cxx | 10 ++++++---- Source/cmSystemTools.h | 6 ++++-- Source/ctest.cxx | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 1fade07..19eafac 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -76,7 +76,8 @@ bool cmListFileCache::CacheFile(const char* path) cmListFileFunction inFunction; if(cmSystemTools::ParseFunction(fin, inFunction.m_Name, - inFunction.m_Arguments)) + inFunction.m_Arguments, + path)) { inFile.m_Functions.push_back(inFunction); } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f3e777e..760fe36 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -256,7 +256,9 @@ void cmMakefile::ExecuteCommand(std::string &name, } else { - cmSystemTools::Error("unknown CMake command ", name.c_str()); + cmSystemTools::Error("unknown CMake command:", name.c_str(), + "\nReading cmake file in directory:" , + m_cmCurrentDirectory.c_str()); } } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 0e5c81e..a7df5bf 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -486,7 +486,8 @@ const char *cmSystemTools::ConvertToWindowsSlashesAndCleanUp(std::string& path) bool cmSystemTools::ParseFunction(std::ifstream& fin, std::string& name, - std::vector& arguments) + std::vector& arguments, + const char* filename) { name = ""; arguments = std::vector(); @@ -551,8 +552,8 @@ bool cmSystemTools::ParseFunction(std::ifstream& fin, } else { - cmSystemTools::Error("Parse error in read function missing end )", - inbuffer); + cmSystemTools::Error("Parse error in read function missing end )\nIn File: ", + filename, "\nCurrent line:", inbuffer); return false; } } @@ -560,7 +561,8 @@ bool cmSystemTools::ParseFunction(std::ifstream& fin, } else { - cmSystemTools::Error("Parse error in read function ", inbuffer); + cmSystemTools::Error("Parse error in read function\nIn file:", + filename, "\nCurrent line:", inbuffer); return false; } } diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index b724bc7..2f03f47 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -122,11 +122,13 @@ public: /** * Read a CMake command (or function) from an input file. This * returns the name of the function and a list of its - * arguments. + * arguments. The last argument is the name of the file that + * the ifstream points to, and is used for debug info only. */ static bool ParseFunction(std::ifstream&, std::string& name, - std::vector& arguments); + std::vector& arguments, + const char* filename); /** * Extract white-space separated arguments from a string. diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 8395b1e..24cf666 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -109,7 +109,7 @@ void ctest::ProcessDirectory(int &passed, int &failed) while ( fin ) { - if(cmSystemTools::ParseFunction(fin, name, args)) + if(cmSystemTools::ParseFunction(fin, name, args, "DartTestfile.txt")) { if (name == "SUBDIRS") { -- cgit v0.12