cppcheck doesn't always report a filename for an error.

Added some error checking so this tool doesn't crash.
This commit is contained in:
Henrik Nilsson 2009-12-15 13:28:26 +01:00
parent f1ad308f5f
commit c83f446412
1 changed files with 5 additions and 0 deletions

View File

@ -161,6 +161,8 @@ class CppCheckHandler(XmlContentHandler):
if name != "error":
return
if attributes["file"] == "":
sys.stderr.write("ERROR: cppcheck error reported without a file name.\n")
self.errors.append(
{
"file" : attributes["file"],
@ -233,6 +235,9 @@ if __name__ == '__main__':
lines.append(error["line"])
source_file = os.path.join(source_dir, filename)
if not os.path.isfile(source_file):
sys.stderr.write("ERROR: Source file '%s' not found.\n" % source_file)
continue
stream = file(source_file)
content = stream.read()
stream.close()