diff --git a/lib/filelister.cpp b/lib/filelister.cpp index 01e5c5a1d..105364555 100644 --- a/lib/filelister.cpp +++ b/lib/filelister.cpp @@ -87,7 +87,11 @@ std::string FileLister::simplifyPath(const char *originalPath) return oss.str(); } - +// This wrapper exists because Sun's CC does not allow a static_cast +// from extern "C" int(*)(int) to int(*)(int). +static int tolowerWrapper(int c) { + return std::tolower(c); +} bool FileLister::acceptFile(const std::string &filename) { @@ -96,7 +100,7 @@ bool FileLister::acceptFile(const std::string &filename) return false; std::string extension = filename.substr(dotLocation); - std::transform(extension.begin(), extension.end(), extension.begin(), static_cast < int(*)(int) > (std::tolower)); + std::transform(extension.begin(), extension.end(), extension.begin(), tolowerWrapper); if (extension == ".cpp" || extension == ".cxx" || @@ -306,7 +310,7 @@ void FileLister::recursiveAddFiles(std::vector &filenames, const st bool FileLister::sameFileName(const char fname1[], const char fname2[]) { -#ifdef __linux__ +#if defined(__linux__) || defined(__sun) return bool(strcmp(fname1, fname2) == 0); #endif #ifdef __GNUC__ diff --git a/lib/filelister.h b/lib/filelister.h index 29093b30b..8c6a61ea7 100644 --- a/lib/filelister.h +++ b/lib/filelister.h @@ -26,19 +26,6 @@ /// @{ -// Check that the compiler are supported -// This program should be compiled with either GCC/BORLAND/MSC to work.. -#ifndef __GNUC__ -#ifndef __BORLANDC__ -#ifndef _MSC_VER -#error "Cppcheck must be compiled by either GCC/BORLAND/MSC to work fully.\n" -#error "Please report that you couldn't compile cppcheck through the web page:\n" -#error " https://sourceforge.net/projects/cppcheck/" -#endif -#endif -#endif - - class FileLister { public: diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 0558d120e..2bbc508e7 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -1207,6 +1207,14 @@ int Preprocessor::getHeaderFileName(std::string &str) return 2; } + +// This wrapper exists because Sun's CC does not allow a static_cast +// from extern "C" int(*)(int) to int(*)(int). +static int tolowerWrapper(int c) { + return std::tolower(c); +} + + void Preprocessor::handleIncludes(std::string &code, const std::string &filename, const std::list &includePaths) { std::list paths; @@ -1247,7 +1255,7 @@ void Preprocessor::handleIncludes(std::string &code, const std::string &filename continue; std::string tempFile = filename; - std::transform(tempFile.begin(), tempFile.end(), tempFile.begin(), static_cast < int(*)(int) > (std::tolower)); + std::transform(tempFile.begin(), tempFile.end(), tempFile.begin(), tolowerWrapper); if (handledFiles.find(tempFile) != handledFiles.end()) { // We have processed this file already once, skip