checking multiple files
This commit is contained in:
parent
a51e012a5a
commit
f06c65c071
24
main.cpp
24
main.cpp
|
@ -1,7 +1,4 @@
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include "tokenize.h" // <- Tokenizer
|
#include "tokenize.h" // <- Tokenizer
|
||||||
#include "CommonCheck.h"
|
#include "CommonCheck.h"
|
||||||
|
|
||||||
|
@ -11,6 +8,9 @@
|
||||||
#include "CheckHeaders.h"
|
#include "CheckHeaders.h"
|
||||||
#include "CheckOther.h"
|
#include "CheckOther.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
bool Debug = false;
|
bool Debug = false;
|
||||||
bool ShowAll = false;
|
bool ShowAll = false;
|
||||||
|
@ -26,7 +26,8 @@ static void CppCheck(const char FileName[]);
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
const char *fname = NULL;
|
std::vector<std::string> filenames;
|
||||||
|
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
if (strcmp(argv[i],"--debug") == 0)
|
if (strcmp(argv[i],"--debug") == 0)
|
||||||
|
@ -41,15 +42,15 @@ int main(int argc, char* argv[])
|
||||||
CheckCodingStyle = true;
|
CheckCodingStyle = true;
|
||||||
|
|
||||||
else
|
else
|
||||||
fname = argv[i];
|
filenames.push_back( argv[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fname)
|
if (filenames.empty())
|
||||||
{
|
{
|
||||||
std::cout << "C/C++ code checking.\n"
|
std::cout << "C/C++ code checking.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Syntax:\n"
|
"Syntax:\n"
|
||||||
" cppcheck [--all] [--style] filename\n"
|
" cppcheck [--all] [--style] filename1 [filename2]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" --all Normally a message is only shown if cppcheck is sure\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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CppCheck(fname);
|
for (unsigned int c = 0; c < filenames.size(); c++)
|
||||||
|
{
|
||||||
std::cerr << errout.str();
|
errout.str("");
|
||||||
|
CppCheck(filenames[c].c_str());
|
||||||
|
std::cerr << errout.str();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,6 +259,7 @@ static void buffer_overrun()
|
||||||
// test4: using strcpy -> check string length
|
// test4: using strcpy -> check string length
|
||||||
// test5: constant array index
|
// test5: constant array index
|
||||||
// test6: calculated array index that is out of bounds
|
// test6: calculated array index that is out of bounds
|
||||||
|
// test7: unknown string length
|
||||||
|
|
||||||
const char test1[] = "void f()\n"
|
const char test1[] = "void f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue