checking multiple files

This commit is contained in:
Daniel Marjamäki 2008-02-17 18:28:51 +00:00
parent a51e012a5a
commit f06c65c071
2 changed files with 15 additions and 10 deletions

View File

@ -1,7 +1,4 @@
#include <iostream>
#include <sstream>
#include "tokenize.h" // <- Tokenizer
#include "CommonCheck.h"
@ -11,6 +8,9 @@
#include "CheckHeaders.h"
#include "CheckOther.h"
#include <iostream>
#include <sstream>
//---------------------------------------------------------------------------
bool Debug = false;
bool ShowAll = false;
@ -26,7 +26,8 @@ static void CppCheck(const char FileName[]);
int main(int argc, char* argv[])
{
const char *fname = NULL;
std::vector<std::string> filenames;
for (int i = 1; i < argc; i++)
{
if (strcmp(argv[i],"--debug") == 0)
@ -41,15 +42,15 @@ int main(int argc, char* argv[])
CheckCodingStyle = true;
else
fname = argv[i];
filenames.push_back( argv[i] );
}
if (!fname)
if (filenames.empty())
{
std::cout << "C/C++ code checking.\n"
"\n"
"Syntax:\n"
" cppcheck [--all] [--style] filename\n"
" cppcheck [--all] [--style] filename1 [filename2]\n"
"\n"
"Options:\n"
" --all Normally a message is only shown if cppcheck is sure\n"
@ -60,9 +61,12 @@ int main(int argc, char* argv[])
return 0;
}
CppCheck(fname);
std::cerr << errout.str();
for (unsigned int c = 0; c < filenames.size(); c++)
{
errout.str("");
CppCheck(filenames[c].c_str());
std::cerr << errout.str();
}
return 0;
}

View File

@ -259,6 +259,7 @@ static void buffer_overrun()
// test4: using strcpy -> check string length
// test5: constant array index
// test6: calculated array index that is out of bounds
// test7: unknown string length
const char test1[] = "void f()\n"
"{\n"