diff --git a/Makefile b/Makefile index 8ebf44596..0456c11d2 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SRCS=CheckBufferOverrun.cpp CheckClass.cpp CheckHeaders.cpp CheckMemoryLeak.cpp CheckFunctionUsage.cpp CheckOther.cpp FileLister.cpp preprocessor.cpp tokenize.cpp cppcheck.cpp settings.cpp token.cpp cppcheckexecutor.cpp +SRCS=checkbufferoverrun.cpp checkclass.cpp checkheaders.cpp checkmemoryleak.cpp checkfunctionusage.cpp checkother.cpp filelister.cpp preprocessor.cpp tokenize.cpp cppcheck.cpp settings.cpp token.cpp cppcheckexecutor.cpp OBJS=$(SRCS:%.cpp=%.o) TESTS=testbufferoverrun.o testcharvar.o testclass.o testconstructors.o testdivision.o testfunctionusage.o testincompletestatement.o testmemleak.o testpreprocessor.o testsimplifytokens.o testtokenize.o testtoken.o testunusedprivfunc.o testunusedvar.o testfilelister.o BIN = ${DESTDIR}/usr/bin @@ -9,43 +9,43 @@ test: ${OBJS} testrunner.o testsuite.o ${TESTS} g++ -Wall -g -o testrunner $^ cppcheckexecutor.o: cppcheckexecutor.cpp cppcheckexecutor.h cppcheck.h errorlogger.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -cppcheck.o: cppcheck.cpp cppcheck.h settings.h errorlogger.h preprocessor.h tokenize.h token.h CheckMemoryLeak.h CheckBufferOverrun.h CheckClass.h CheckHeaders.h CheckOther.h CheckFunctionUsage.h FileLister.h +cppcheck.o: cppcheck.cpp cppcheck.h settings.h errorlogger.h preprocessor.h tokenize.h token.h checkmemoryleak.h checkbufferoverrun.h checkclass.h checkheaders.h checkother.h checkfunctionusage.h filelister.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp main.o: main.cpp cppcheck.h settings.h errorlogger.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -CheckBufferOverrun.o: CheckBufferOverrun.cpp CheckBufferOverrun.h tokenize.h settings.h errorlogger.h token.h +checkbufferoverrun.o: checkbufferoverrun.cpp checkbufferoverrun.h tokenize.h settings.h errorlogger.h token.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -CheckClass.o: CheckClass.cpp CheckClass.h tokenize.h settings.h errorlogger.h token.h +checkclass.o: checkclass.cpp checkclass.h tokenize.h settings.h errorlogger.h token.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -CheckFunctionUsage.o: CheckFunctionUsage.cpp CheckFunctionUsage.h tokenize.h settings.h errorlogger.h token.h +checkfunctionusage.o: checkfunctionusage.cpp checkfunctionusage.h tokenize.h settings.h errorlogger.h token.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -CheckHeaders.o: CheckHeaders.cpp CheckHeaders.h tokenize.h settings.h errorlogger.h token.h +checkheaders.o: checkheaders.cpp checkheaders.h tokenize.h settings.h errorlogger.h token.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -CheckMemoryLeak.o: CheckMemoryLeak.cpp CheckMemoryLeak.h tokenize.h settings.h errorlogger.h token.h +checkmemoryleak.o: checkmemoryleak.cpp checkmemoryleak.h tokenize.h settings.h errorlogger.h token.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -CheckOther.o: CheckOther.cpp CheckOther.h tokenize.h settings.h errorlogger.h token.h +checkother.o: checkother.cpp checkother.h tokenize.h settings.h errorlogger.h token.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -FileLister.o: FileLister.cpp FileLister.h +filelister.o: filelister.cpp filelister.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp preprocessor.o: preprocessor.cpp preprocessor.h errorlogger.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp settings.o: settings.cpp settings.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -testbufferoverrun.o: testbufferoverrun.cpp tokenize.h settings.h errorlogger.h token.h CheckBufferOverrun.h testsuite.h +testbufferoverrun.o: testbufferoverrun.cpp tokenize.h settings.h errorlogger.h token.h checkbufferoverrun.h testsuite.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -testcharvar.o: testcharvar.cpp tokenize.h settings.h errorlogger.h token.h CheckOther.h testsuite.h +testcharvar.o: testcharvar.cpp tokenize.h settings.h errorlogger.h token.h checkother.h testsuite.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -testclass.o: testclass.cpp tokenize.h settings.h errorlogger.h token.h CheckClass.h testsuite.h +testclass.o: testclass.cpp tokenize.h settings.h errorlogger.h token.h checkclass.h testsuite.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -testconstructors.o: testconstructors.cpp tokenize.h settings.h errorlogger.h token.h CheckClass.h testsuite.h +testconstructors.o: testconstructors.cpp tokenize.h settings.h errorlogger.h token.h checkclass.h testsuite.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -testdivision.o: testdivision.cpp tokenize.h settings.h errorlogger.h token.h CheckOther.h testsuite.h +testdivision.o: testdivision.cpp tokenize.h settings.h errorlogger.h token.h checkother.h testsuite.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -testfunctionusage.o: testfunctionusage.cpp tokenize.h settings.h errorlogger.h token.h testsuite.h CheckFunctionUsage.h +testfunctionusage.o: testfunctionusage.cpp tokenize.h settings.h errorlogger.h token.h testsuite.h checkfunctionusage.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -testincompletestatement.o: testincompletestatement.cpp testsuite.h errorlogger.h tokenize.h settings.h token.h CheckOther.h +testincompletestatement.o: testincompletestatement.cpp testsuite.h errorlogger.h tokenize.h settings.h token.h checkother.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -testmemleak.o: testmemleak.cpp tokenize.h settings.h errorlogger.h token.h CheckMemoryLeak.h testsuite.h +testmemleak.o: testmemleak.cpp tokenize.h settings.h errorlogger.h token.h checkmemoryleak.h testsuite.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp testpreprocessor.o: testpreprocessor.cpp testsuite.h errorlogger.h preprocessor.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp @@ -59,15 +59,15 @@ testtoken.o: testtoken.cpp testsuite.h errorlogger.h token.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp testtokenize.o: testtokenize.cpp testsuite.h errorlogger.h tokenize.h settings.h token.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -testunusedprivfunc.o: testunusedprivfunc.cpp tokenize.h settings.h errorlogger.h token.h CheckClass.h testsuite.h +testunusedprivfunc.o: testunusedprivfunc.cpp tokenize.h settings.h errorlogger.h token.h checkclass.h testsuite.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -testunusedvar.o: testunusedvar.cpp testsuite.h errorlogger.h tokenize.h settings.h token.h CheckOther.h +testunusedvar.o: testunusedvar.cpp testsuite.h errorlogger.h tokenize.h settings.h token.h checkother.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -testfilelister.o: testfilelister.cpp FileLister.h +testfilelister.o: testfilelister.cpp filelister.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp token.o: token.cpp token.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp -tokenize.o: tokenize.cpp tokenize.h settings.h errorlogger.h token.h FileLister.h +tokenize.o: tokenize.cpp tokenize.h settings.h errorlogger.h token.h filelister.h g++ -Wall -pedantic -g -I. -o $@ -c $*.cpp clean: diff --git a/cppcheck.cbp b/cppcheck.cbp index 0419de521..7415d4667 100644 --- a/cppcheck.cbp +++ b/cppcheck.cbp @@ -30,50 +30,41 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - + + - - + + + - - + + - - + diff --git a/cppcheck.cpp b/cppcheck.cpp index 4b3c7018f..d520fbab3 100644 --- a/cppcheck.cpp +++ b/cppcheck.cpp @@ -20,13 +20,13 @@ #include "preprocessor.h" // preprocessor. #include "tokenize.h" // <- Tokenizer -#include "CheckMemoryLeak.h" -#include "CheckBufferOverrun.h" -#include "CheckClass.h" -#include "CheckHeaders.h" -#include "CheckOther.h" -#include "CheckFunctionUsage.h" -#include "FileLister.h" +#include "checkmemoryleak.h" +#include "checkbufferoverrun.h" +#include "checkclass.h" +#include "checkheaders.h" +#include "checkother.h" +#include "checkfunctionusage.h" +#include "filelister.h" #include #include diff --git a/cppcheck.h b/cppcheck.h index 7680e41a9..8f5a6204e 100644 --- a/cppcheck.h +++ b/cppcheck.h @@ -26,7 +26,7 @@ #include #include "settings.h" #include "errorlogger.h" -#include "CheckFunctionUsage.h" +#include "checkfunctionusage.h" /** * This is the base class which will use other classes to do diff --git a/testbufferoverrun.cpp b/testbufferoverrun.cpp index 1dcf23aef..046243641 100644 --- a/testbufferoverrun.cpp +++ b/testbufferoverrun.cpp @@ -19,7 +19,7 @@ #define UNIT_TESTING #include "tokenize.h" -#include "CheckBufferOverrun.h" +#include "checkbufferoverrun.h" #include "testsuite.h" #include diff --git a/testcharvar.cpp b/testcharvar.cpp index db38e0e60..f5a7dfcf0 100644 --- a/testcharvar.cpp +++ b/testcharvar.cpp @@ -19,7 +19,7 @@ #define UNIT_TESTING #include "tokenize.h" -#include "CheckOther.h" +#include "checkother.h" #include "testsuite.h" #include diff --git a/testclass.cpp b/testclass.cpp index 20863af07..101f508e2 100644 --- a/testclass.cpp +++ b/testclass.cpp @@ -20,7 +20,7 @@ #define UNIT_TESTING #include "tokenize.h" -#include "CheckClass.h" +#include "checkclass.h" #include "testsuite.h" #include diff --git a/testconstructors.cpp b/testconstructors.cpp index c15fa70f8..fb68dc6ce 100644 --- a/testconstructors.cpp +++ b/testconstructors.cpp @@ -20,7 +20,7 @@ #define UNIT_TESTING #include "tokenize.h" -#include "CheckClass.h" +#include "checkclass.h" #include "testsuite.h" #include diff --git a/testdivision.cpp b/testdivision.cpp index c35b5d637..c793997d6 100644 --- a/testdivision.cpp +++ b/testdivision.cpp @@ -23,7 +23,7 @@ #define UNIT_TESTING #include "tokenize.h" -#include "CheckOther.h" +#include "checkother.h" #include "testsuite.h" #include diff --git a/testfilelister.cpp b/testfilelister.cpp new file mode 100644 index 000000000..dcd0eb4ad --- /dev/null +++ b/testfilelister.cpp @@ -0,0 +1,53 @@ +/* + * c++check - c/c++ syntax checking + * Copyright (C) 2008 Daniel Marjamäki and Reijo Tomperi + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see +#include "testsuite.h" +#include "filelister.h" + +class TestFileLister : public TestFixture +{ +public: + TestFileLister() : TestFixture("TestFileLister") + { } + +private: + + void run() + { + TEST_CASE( simplify_path ); + } + + void simplify_path() + { + ASSERT_EQUALS( std::string( "index.h" ), FileLister::simplifyPath( "index.h" ) ); + ASSERT_EQUALS( std::string( "/index.h" ), FileLister::simplifyPath( "/index.h" ) ); + ASSERT_EQUALS( std::string( "/path/" ), FileLister::simplifyPath( "/path/" ) ); + ASSERT_EQUALS( std::string( "/" ), FileLister::simplifyPath( "/" ) ); + ASSERT_EQUALS( std::string( "./index.h" ), FileLister::simplifyPath( "./index.h" ) ); + ASSERT_EQUALS( std::string( "../index.h" ), FileLister::simplifyPath( "../index.h" ) ); + ASSERT_EQUALS( std::string( "/index.h" ), FileLister::simplifyPath( "/path/../index.h" ) ); + ASSERT_EQUALS( std::string( "/index.h" ), FileLister::simplifyPath( "/path/../other/../index.h" ) ); + ASSERT_EQUALS( std::string( "/index.h" ), FileLister::simplifyPath( "/path/../other///././../index.h" ) ); + ASSERT_EQUALS( std::string( "../path/index.h" ), FileLister::simplifyPath( "../path/other/../index.h" ) ); + } + + +}; + +REGISTER_TEST( TestFileLister ) diff --git a/testfunctionusage.cpp b/testfunctionusage.cpp index 253f19afa..395108672 100644 --- a/testfunctionusage.cpp +++ b/testfunctionusage.cpp @@ -20,7 +20,7 @@ #define UNIT_TESTING #include "tokenize.h" #include "testsuite.h" -#include "CheckFunctionUsage.h" +#include "checkfunctionusage.h" #include extern std::ostringstream errout; diff --git a/testincompletestatement.cpp b/testincompletestatement.cpp index 203d4a052..b7de36522 100644 --- a/testincompletestatement.cpp +++ b/testincompletestatement.cpp @@ -23,7 +23,7 @@ #define UNIT_TESTING #include "testsuite.h" #include "tokenize.h" -#include "CheckOther.h" +#include "checkother.h" #include diff --git a/testmemleak.cpp b/testmemleak.cpp index 643306932..540f89baf 100644 --- a/testmemleak.cpp +++ b/testmemleak.cpp @@ -21,7 +21,7 @@ #define UNIT_TESTING #include "tokenize.h" -#include "CheckMemoryLeak.h" +#include "checkmemoryleak.h" #include "testsuite.h" #include diff --git a/testunusedprivfunc.cpp b/testunusedprivfunc.cpp index 28b037399..05212b6ff 100644 --- a/testunusedprivfunc.cpp +++ b/testunusedprivfunc.cpp @@ -19,7 +19,7 @@ #define UNIT_TESTING #include "tokenize.h" -#include "CheckClass.h" +#include "checkclass.h" #include "testsuite.h" #include diff --git a/testunusedvar.cpp b/testunusedvar.cpp index aecad26bb..8da319bab 100644 --- a/testunusedvar.cpp +++ b/testunusedvar.cpp @@ -23,7 +23,7 @@ #define UNIT_TESTING #include "testsuite.h" #include "tokenize.h" -#include "CheckOther.h" +#include "checkother.h" #include extern std::ostringstream errout; diff --git a/tokenize.cpp b/tokenize.cpp index 50f919aa2..b1a5a5d1d 100644 --- a/tokenize.cpp +++ b/tokenize.cpp @@ -34,7 +34,7 @@ #include #include // <- strtoul #include -#include +#include #ifdef __BORLANDC__ #include