summaryrefslogtreecommitdiffstats
path: root/Source/cmCacheManager.cxx
diff options
context:
space:
mode:
authorAshley Whetter <ashley@awhetter.co.uk>2016-01-17 22:09:30 (GMT)
committerBrad King <brad.king@kitware.com>2016-01-19 15:19:42 (GMT)
commit77cd74a3ea964fa390d85c371902387e9ffc4a92 (patch)
tree1ae6b9fe22db03f0212886da31c5b7f78ea9041f /Source/cmCacheManager.cxx
parent249aac71d0b0022031d16963f3b46f9860919104 (diff)
downloadCMake-77cd74a3ea964fa390d85c371902387e9ffc4a92.zip
CMake-77cd74a3ea964fa390d85c371902387e9ffc4a92.tar.gz
CMake-77cd74a3ea964fa390d85c371902387e9ffc4a92.tar.bz2
Print line number of cache parse errors (#11109)
Track the line number while parsing `CMakeCache.txt` files and include it in a parse failure error message.
Diffstat (limited to 'Source/cmCacheManager.cxx')
-rw-r--r--Source/cmCacheManager.cxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index ce8af55..7466c29 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -64,12 +64,14 @@ bool cmCacheManager::LoadCache(const std::string& path,
const char *realbuffer;
std::string buffer;
std::string entryKey;
+ unsigned int lineno = 0;
while(fin)
{
// Format is key:type=value
std::string helpString;
CacheEntry e;
cmSystemTools::GetLineFromStream(fin, buffer);
+ lineno++;
realbuffer = buffer.c_str();
while(*realbuffer != '0' &&
(*realbuffer == ' ' ||
@@ -77,6 +79,7 @@ bool cmCacheManager::LoadCache(const std::string& path,
*realbuffer == '\r' ||
*realbuffer == '\n'))
{
+ if (*realbuffer == '\n') lineno++;
realbuffer++;
}
// skip blank lines and comment lines
@@ -96,6 +99,7 @@ bool cmCacheManager::LoadCache(const std::string& path,
helpString += &realbuffer[2];
}
cmSystemTools::GetLineFromStream(fin, buffer);
+ lineno++;
realbuffer = buffer.c_str();
if(!fin)
{
@@ -138,8 +142,10 @@ bool cmCacheManager::LoadCache(const std::string& path,
}
else
{
- cmSystemTools::Error("Parse error in cache file ", cacheFile.c_str(),
- ". Offending entry: ", realbuffer);
+ std::ostringstream error;
+ error << "Parse error in cache file " << cacheFile;
+ error << " on line " << lineno << ". Offending entry: " << realbuffer;
+ cmSystemTools::Error(error.str().c_str());
}
}
this->CacheMajorVersion = 0;