diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 61dcfe9e0..12cdae703 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -103,30 +103,30 @@ void CmdLineParser::PrintMessage(const std::string &message) bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) { for (int i = 1; i < argc; i++) { - if (strcmp(argv[i], "--version") == 0) { + if (std::strcmp(argv[i], "--version") == 0) { _showVersion = true; _exitAfterPrint = true; return true; } // Flag used for various purposes during debugging - else if (strcmp(argv[i], "--debug") == 0) + else if (std::strcmp(argv[i], "--debug") == 0) _settings->debug = _settings->debugwarnings = true; // Show debug warnings - else if (strcmp(argv[i], "--debug-warnings") == 0) + else if (std::strcmp(argv[i], "--debug-warnings") == 0) _settings->debugwarnings = true; // Print out code that triggers false positive - else if (strcmp(argv[i], "--debug-fp") == 0) + else if (std::strcmp(argv[i], "--debug-fp") == 0) _settings->debugFalsePositive = true; // Inconclusive checking (still in testing phase) - else if (strcmp(argv[i], "--inconclusive") == 0) + else if (std::strcmp(argv[i], "--inconclusive") == 0) _settings->inconclusive = true; // Enforce language (--language=, -x) - else if (strncmp(argv[i], "--language=", 11) == 0 || strcmp(argv[i], "-x") == 0) { + else if (std::strncmp(argv[i], "--language=", 11) == 0 || std::strcmp(argv[i], "-x") == 0) { std::string str; if (argv[i][2]) { str = argv[i]+11; @@ -150,16 +150,16 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } // Filter errors - else if (strncmp(argv[i], "--exitcode-suppressions", 23) == 0) { + else if (std::strncmp(argv[i], "--exitcode-suppressions", 23) == 0) { std::string filename; // exitcode-suppressions filename.txt // Deprecated - if (strcmp(argv[i], "--exitcode-suppressions") == 0) { + if (std::strcmp(argv[i], "--exitcode-suppressions") == 0) { ++i; - if (i >= argc || strncmp(argv[i], "-", 1) == 0 || - strncmp(argv[i], "--", 2) == 0) { + if (i >= argc || std::strncmp(argv[i], "-", 1) == 0 || + std::strncmp(argv[i], "--", 2) == 0) { PrintMessage("cppcheck: No filename specified for the '--exitcode-suppressions' option."); return false; } @@ -183,15 +183,15 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } // Filter errors - else if (strncmp(argv[i], "--suppressions-list=", 20) == 0) { + else if (std::strncmp(argv[i], "--suppressions-list=", 20) == 0) { std::string filename = argv[i]+20; std::ifstream f(filename.c_str()); if (!f.is_open()) { std::string message("cppcheck: Couldn't open the file: \""); message += filename; message += "\"."; - if (count(filename.begin(), filename.end(), ',') > 0 || - count(filename.begin(), filename.end(), '.') > 1) { + if (std::count(filename.begin(), filename.end(), ',') > 0 || + std::count(filename.begin(), filename.end(), '.') > 1) { // If user tried to pass multiple files (we can only guess that) // e.g. like this: --suppressions-list=a.txt,b.txt // print more detailed error message to tell user how he can solve the problem @@ -211,7 +211,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) // Filter errors // This is deprecated, see --supressions-list above - else if (strcmp(argv[i], "--suppressions") == 0) { + else if (std::strcmp(argv[i], "--suppressions") == 0) { ++i; if (i >= argc) { @@ -234,7 +234,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } } - else if (strncmp(argv[i], "--suppress=", 11) == 0) { + else if (std::strncmp(argv[i], "--suppress=", 11) == 0) { std::string suppression = argv[i]+11; const std::string errmsg(_settings->nomsg.addSuppressionLine(suppression)); if (!errmsg.empty()) { @@ -244,21 +244,21 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } // Enables inline suppressions. - else if (strcmp(argv[i], "--inline-suppr") == 0) + else if (std::strcmp(argv[i], "--inline-suppr") == 0) _settings->_inlineSuppressions = true; // Verbose error messages (configuration info) - else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) + else if (std::strcmp(argv[i], "-v") == 0 || std::strcmp(argv[i], "--verbose") == 0) _settings->_verbose = true; // Force checking of files that have "too many" configurations - else if (strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "--force") == 0) + else if (std::strcmp(argv[i], "-f") == 0 || std::strcmp(argv[i], "--force") == 0) _settings->_force = true; // Output relative paths - else if (strcmp(argv[i], "-rp") == 0 || strcmp(argv[i], "--relative-paths") == 0) + else if (std::strcmp(argv[i], "-rp") == 0 || std::strcmp(argv[i], "--relative-paths") == 0) _settings->_relativePaths = true; - else if (strncmp(argv[i], "-rp=", 4) == 0 || strncmp(argv[i], "--relative-paths=", 17) == 0) { + else if (std::strncmp(argv[i], "-rp=", 4) == 0 || std::strncmp(argv[i], "--relative-paths=", 17) == 0) { _settings->_relativePaths = true; if (argv[i][argv[i][3]=='='?4:17] != 0) { std::string paths = argv[i]+(argv[i][3]=='='?4:17); @@ -275,11 +275,11 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } // Write results in results.xml - else if (strcmp(argv[i], "--xml") == 0) + else if (std::strcmp(argv[i], "--xml") == 0) _settings->_xml = true; // Define the XML file version (and enable XML output) - else if (strncmp(argv[i], "--xml-version=", 14) == 0) { + else if (std::strncmp(argv[i], "--xml-version=", 14) == 0) { std::string numberString(argv[i]+14); std::istringstream iss(numberString); @@ -299,11 +299,11 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } // Only print something when there are errors - else if (strcmp(argv[i], "-q") == 0 || strcmp(argv[i], "--quiet") == 0) + else if (std::strcmp(argv[i], "-q") == 0 || std::strcmp(argv[i], "--quiet") == 0) _settings->_errorsOnly = true; // Append userdefined code to checked source code - else if (strncmp(argv[i], "--append=", 9) == 0) { + else if (std::strncmp(argv[i], "--append=", 9) == 0) { const std::string filename = 9 + argv[i]; if (!_settings->append(filename)) { PrintMessage("cppcheck: Couldn't open the file: \"" + filename + "\"."); @@ -311,7 +311,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } } - else if (strncmp(argv[i], "--enable=", 9) == 0) { + else if (std::strncmp(argv[i], "--enable=", 9) == 0) { const std::string errmsg = _settings->addEnabled(argv[i] + 9); if (!errmsg.empty()) { PrintMessage(errmsg); @@ -325,7 +325,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } // --error-exitcode=1 - else if (strncmp(argv[i], "--error-exitcode=", 17) == 0) { + else if (std::strncmp(argv[i], "--error-exitcode=", 17) == 0) { std::string temp = argv[i]+17; std::istringstream iss(temp); if (!(iss >> _settings->_exitCode)) { @@ -336,11 +336,11 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } // User define - else if (strncmp(argv[i], "-D", 2) == 0) { + else if (std::strncmp(argv[i], "-D", 2) == 0) { std::string define; // "-D define" - if (strcmp(argv[i], "-D") == 0) { + if (std::strcmp(argv[i], "-D") == 0) { ++i; if (i >= argc || argv[i][0] == '-') { PrintMessage("cppcheck: argument to '-D' is missing."); @@ -367,11 +367,11 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) _settings->userDefines += define; } // User undef - else if (strncmp(argv[i], "-U", 2) == 0) { + else if (std::strncmp(argv[i], "-U", 2) == 0) { std::string undef; // "-U undef" - if (strcmp(argv[i], "-U") == 0) { + if (std::strcmp(argv[i], "-U") == 0) { ++i; if (i >= argc || argv[i][0] == '-') { PrintMessage("cppcheck: argument to '-U' is missing."); @@ -389,11 +389,11 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } // Include paths - else if (strncmp(argv[i], "-I", 2) == 0) { + else if (std::strncmp(argv[i], "-I", 2) == 0) { std::string path; // "-I path/" - if (strcmp(argv[i], "-I") == 0) { + if (std::strcmp(argv[i], "-I") == 0) { ++i; if (i >= argc || argv[i][0] == '-') { PrintMessage("cppcheck: argument to '-I' is missing."); @@ -414,23 +414,23 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) path += '/'; _settings->_includePaths.push_back(path); - } else if (strncmp(argv[i], "--includes-file=", 16) == 0) { + } else if (std::strncmp(argv[i], "--includes-file=", 16) == 0) { // open this file and read every input file (1 file name per line) AddInclPathsToList(16 + argv[i], _settings->_includePaths); } // file list specified - else if (strncmp(argv[i], "--file-list=", 12) == 0) { + else if (std::strncmp(argv[i], "--file-list=", 12) == 0) { // open this file and read every input file (1 file name per line) AddFilesToList(12 + argv[i], _pathnames); } // Ignored paths - else if (strncmp(argv[i], "-i", 2) == 0) { + else if (std::strncmp(argv[i], "-i", 2) == 0) { std::string path; // "-i path/" - if (strcmp(argv[i], "-i") == 0) { + if (std::strcmp(argv[i], "-i") == 0) { ++i; if (i >= argc || argv[i][0] == '-') { PrintMessage("cppcheck: argument to '-i' is missing."); @@ -459,28 +459,28 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } // Report progress - else if (strcmp(argv[i], "--report-progress") == 0) { + else if (std::strcmp(argv[i], "--report-progress") == 0) { _settings->reportProgress = true; } // --std - else if (strcmp(argv[i], "--std=posix") == 0) { + else if (std::strcmp(argv[i], "--std=posix") == 0) { _settings->standards.posix = true; - } else if (strcmp(argv[i], "--std=c89") == 0) { + } else if (std::strcmp(argv[i], "--std=c89") == 0) { _settings->standards.c = Standards::C89; - } else if (strcmp(argv[i], "--std=c99") == 0) { + } else if (std::strcmp(argv[i], "--std=c99") == 0) { _settings->standards.c = Standards::C99; - } else if (strcmp(argv[i], "--std=c11") == 0) { + } else if (std::strcmp(argv[i], "--std=c11") == 0) { _settings->standards.c = Standards::C11; - } else if (strcmp(argv[i], "--std=c++03") == 0) { + } else if (std::strcmp(argv[i], "--std=c++03") == 0) { _settings->standards.cpp = Standards::CPP03; - } else if (strcmp(argv[i], "--std=c++11") == 0) { + } else if (std::strcmp(argv[i], "--std=c++11") == 0) { _settings->standards.cpp = Standards::CPP11; } // Output formatter - else if (strcmp(argv[i], "--template") == 0 || - strncmp(argv[i], "--template=", 11) == 0) { + else if (std::strcmp(argv[i], "--template") == 0 || + std::strncmp(argv[i], "--template=", 11) == 0) { // "--template path/" if (argv[i][10] == '=') _settings->_outputFormat = argv[i] + 11; @@ -501,11 +501,11 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } // Checking threads - else if (strncmp(argv[i], "-j", 2) == 0) { + else if (std::strncmp(argv[i], "-j", 2) == 0) { std::string numberString; // "-j 3" - if (strcmp(argv[i], "-j") == 0) { + if (std::strcmp(argv[i], "-j") == 0) { ++i; if (i >= argc || argv[i][0] == '-') { PrintMessage("cppcheck: argument to '-j' is missing."); @@ -534,14 +534,14 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } // print all possible error messages.. - else if (strcmp(argv[i], "--errorlist") == 0) { + else if (std::strcmp(argv[i], "--errorlist") == 0) { _showErrorMessages = true; _settings->_xml = true; _exitAfterPrint = true; } // documentation.. - else if (strcmp(argv[i], "--doc") == 0) { + else if (std::strcmp(argv[i], "--doc") == 0) { std::ostringstream doc; // Get documentation.. for (std::list::iterator it = Check::instances().begin(); it != Check::instances().end(); ++it) { @@ -558,7 +558,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } // show timing information.. - else if (strncmp(argv[i], "--showtime=", 11) == 0) { + else if (std::strncmp(argv[i], "--showtime=", 11) == 0) { const std::string showtimeMode = argv[i] + 11; if (showtimeMode == "file") _settings->_showtime = SHOWTIME_FILE; @@ -572,14 +572,14 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) #ifdef HAVE_RULES // Rule given at command line - else if (strncmp(argv[i], "--rule=", 7) == 0) { + else if (std::strncmp(argv[i], "--rule=", 7) == 0) { Settings::Rule rule; rule.pattern = 7 + argv[i]; _settings->rules.push_back(rule); } // Rule file - else if (strncmp(argv[i], "--rule-file=", 12) == 0) { + else if (std::strncmp(argv[i], "--rule-file=", 12) == 0) { TiXmlDocument doc; if (doc.LoadFile(12+argv[i])) { TiXmlElement *node = doc.FirstChildElement(); @@ -614,12 +614,12 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) #endif // Check configuration - else if (strcmp(argv[i], "--check-config") == 0) { + else if (std::strcmp(argv[i], "--check-config") == 0) { _settings->checkConfiguration = true; } // Specify platform - else if (strncmp(argv[i], "--platform=", 11) == 0) { + else if (std::strncmp(argv[i], "--platform=", 11) == 0) { std::string platform(11+argv[i]); if (platform == "win32A") @@ -642,7 +642,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } // Set maximum number of #ifdef configurations to check - else if (strncmp(argv[i], "--max-configs=", 14) == 0) { + else if (std::strncmp(argv[i], "--max-configs=", 14) == 0) { _settings->_force = false; std::istringstream iss(14+argv[i]); @@ -658,14 +658,14 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } // Print help - else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + else if (std::strcmp(argv[i], "-h") == 0 || std::strcmp(argv[i], "--help") == 0) { _pathnames.clear(); _showHelp = true; _exitAfterPrint = true; break; } - else if (strncmp(argv[i], "-", 1) == 0 || strncmp(argv[i], "--", 2) == 0) { + else if (std::strncmp(argv[i], "-", 1) == 0 || std::strncmp(argv[i], "--", 2) == 0) { std::string message("cppcheck: error: unrecognized command line option: \""); message += argv[i]; message += "\"."; diff --git a/cli/threadexecutor.cpp b/cli/threadexecutor.cpp index 708e7bd0c..f06cdb709 100644 --- a/cli/threadexecutor.cpp +++ b/cli/threadexecutor.cpp @@ -40,6 +40,9 @@ #include #endif +// required for FD_ZERO +using std::memset; + ThreadExecutor::ThreadExecutor(const std::map &files, Settings &settings, ErrorLogger &errorLogger) : _files(files), _settings(settings), _errorLogger(errorLogger), _fileCount(0) { @@ -82,19 +85,19 @@ int ThreadExecutor::handleRead(int rpipe, unsigned int &result) if (type != REPORT_OUT && type != REPORT_ERROR && type != REPORT_INFO && type != CHILD_END) { std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl; - exit(0); + std::exit(0); } unsigned int len = 0; if (read(rpipe, &len, sizeof(len)) <= 0) { std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl; - exit(0); + std::exit(0); } char *buf = new char[len]; if (read(rpipe, buf, len) <= 0) { std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl; - exit(0); + std::exit(0); } if (type == REPORT_OUT) { @@ -154,26 +157,26 @@ unsigned int ThreadExecutor::check() if (i != _files.end() && rpipes.size() < _settings._jobs) { int pipes[2]; if (pipe(pipes) == -1) { - std::cerr << "pipe() failed: "<< strerror(errno) << std::endl; - exit(EXIT_FAILURE); + std::cerr << "pipe() failed: "<< std::strerror(errno) << std::endl; + std::exit(EXIT_FAILURE); } int flags = 0; if ((flags = fcntl(pipes[0], F_GETFL, 0)) < 0) { - std::cerr << "fcntl(F_GETFL) failed: "<< strerror(errno) << std::endl; - exit(EXIT_FAILURE); + std::cerr << "fcntl(F_GETFL) failed: "<< std::strerror(errno) << std::endl; + std::exit(EXIT_FAILURE); } if (fcntl(pipes[0], F_SETFL, flags | O_NONBLOCK) < 0) { - std::cerr << "fcntl(F_SETFL) failed: "<< strerror(errno) << std::endl; - exit(EXIT_FAILURE); + std::cerr << "fcntl(F_SETFL) failed: "<< std::strerror(errno) << std::endl; + std::exit(EXIT_FAILURE); } pid_t pid = fork(); if (pid < 0) { // Error - std::cerr << "Failed to create child process: "<< strerror(errno) << std::endl; - exit(EXIT_FAILURE); + std::cerr << "Failed to create child process: "<< std::strerror(errno) << std::endl; + std::exit(EXIT_FAILURE); } else if (pid == 0) { close(pipes[0]); _wpipe = pipes[1]; @@ -193,7 +196,7 @@ unsigned int ThreadExecutor::check() std::ostringstream oss; oss << resultOfCheck; writeToPipe(CHILD_END, oss.str()); - exit(0); + std::exit(0); } close(pipes[1]); @@ -288,7 +291,7 @@ void ThreadExecutor::writeToPipe(PipeSignal type, const std::string &data) delete [] out; out = 0; std::cerr << "#### ThreadExecutor::writeToPipe, Failed to write to pipe" << std::endl; - exit(0); + std::exit(0); } delete [] out; diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 9f3a33ba8..1181b76b0 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -94,7 +94,7 @@ static const char * const call_func_white_list[] = { static int call_func_white_list_compare(const void *a, const void *b) { - return strcmp((const char *)a, *(const char * const *)b); + return std::strcmp((const char *)a, *(const char * const *)b); } //--------------------------------------------------------------------------- diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index f5c9981a5..7ca512971 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1015,7 +1015,7 @@ std::set UninitVar::uvarFunctions; /// @} -void CheckUninitVar::analyse(const Token * const tokens, std::set &func) const +void CheckUninitVar::analyse(const Token * tokens, std::set &func) const { UninitVar::analyseFunctions(tokens, func); } diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index b55ff3458..6a25df691 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -750,9 +750,9 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const // bailout when for_each is used if (Token::Match(tok,"%var% (") && Token::simpleMatch(tok->linkAt(1),") {")) { // does the name contain "for_each" or "foreach"? - std::string name(tok->str()); - std::transform(name.begin(),name.end(),name.begin(),static_cast(std::tolower)); - if (name.find("foreach") != std::string::npos || name.find("for_each") != std::string::npos) { + std::string nameTok(tok->str()); + std::transform(nameTok.begin(),nameTok.end(),nameTok.begin(),::tolower); + if (nameTok.find("foreach") != std::string::npos || nameTok.find("for_each") != std::string::npos) { // bailout all variables in the body that are used more than once. // TODO: there is no need to bailout if variable is only read or only written std::set varid; diff --git a/lib/mathlib.cpp b/lib/mathlib.cpp index c43d239a3..e5304bc41 100644 --- a/lib/mathlib.cpp +++ b/lib/mathlib.cpp @@ -304,7 +304,7 @@ std::string MathLib::mod(const std::string &first, const std::string &second) throw InternalError(0, "Internal Error: Division by zero"); return longToString(toLongNumber(first) % b); } - return doubleToString(fmod(toDoubleNumber(first),toDoubleNumber(second))); + return doubleToString(std::fmod(toDoubleNumber(first),toDoubleNumber(second))); } std::string MathLib::calculate(const std::string &first, const std::string &second, char action) diff --git a/lib/path.cpp b/lib/path.cpp index 6ee2eb403..54a8d7d9a 100644 --- a/lib/path.cpp +++ b/lib/path.cpp @@ -58,7 +58,7 @@ std::string Path::fromNativeSeparators(std::string path) std::string Path::simplifyPath(const char *originalPath) { // Skip ./ at the beginning - if (strlen(originalPath) > 2 && originalPath[0] == '.' && + if (std::strlen(originalPath) > 2 && originalPath[0] == '.' && originalPath[1] == '/') { originalPath += 2; } diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index ff7952544..e4d389b90 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -35,6 +35,13 @@ #define LLONG_MAX LONG_MAX #endif +// Define ULLONG_MAX and LLONG_MAX for SunCC on non-Solaris systems +#if (defined(__SUNPRO_C) || defined(__SUNPRO_CC)) && \ + !(defined (__sun) || defined (__sun__)) +#define ULLONG_MAX ULONG_MAX +#define LLONG_MAX LONG_MAX +#endif + //--------------------------------------------------------------------------- SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) diff --git a/lib/token.cpp b/lib/token.cpp index 57019a1f7..0222bf559 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -322,7 +322,7 @@ const std::string &Token::strAt(int index) const static bool strisop(const char str[]) { if (str[1] == 0) { - if (strchr("+-*/%&|^~!<>", *str)) + if (std::strchr("+-*/%&|^~!<>", *str)) return true; } else if (str[2] == 0) { if ((str[0] == '&' && str[1] == '&') || @@ -469,21 +469,21 @@ bool Token::simpleMatch(const Token *tok, const char pattern[]) const char *current, *next; current = pattern; - next = strchr(pattern, ' '); + next = std::strchr(pattern, ' '); if (!next) - next = pattern + strlen(pattern); + next = pattern + std::strlen(pattern); while (*current) { std::size_t length = static_cast(next - current); - if (!tok || length != tok->_str.length() || strncmp(current, tok->_str.c_str(), length)) + if (!tok || length != tok->_str.length() || std::strncmp(current, tok->_str.c_str(), length)) return false; current = next; if (*next) { - next = strchr(++current, ' '); + next = std::strchr(++current, ' '); if (!next) - next = current + strlen(current); + next = current + std::strlen(current); } tok = tok->next(); } @@ -691,7 +691,7 @@ bool Token::Match(const Token *tok, const char pattern[], unsigned int varid) break; default: //unknown %cmd%, abort - abort(); + std::abort(); } } diff --git a/lib/token.h b/lib/token.h index f3ad4f7b9..2a1a9acfd 100644 --- a/lib/token.h +++ b/lib/token.h @@ -306,7 +306,7 @@ public: * @param prepend Insert the new token before this token when it's not * the first one on the tokens list. */ - void insertToken(const std::string &tokenStr, const bool prepend=false); + void insertToken(const std::string &tokenStr, bool prepend=false); Token *previous() const { return _previous; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 4ed2fb182..7bf3c419c 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1680,7 +1680,7 @@ bool Tokenizer::tokenize(std::istream &code, const char c2 = tok->next()->str()[0]; // combine +-*/ and = - if (c2 == '=' && (strchr("+-*/%&|^=!<>", c1))) { + if (c2 == '=' && (std::strchr("+-*/%&|^=!<>", c1))) { tok->str(tok->str() + c2); tok->deleteNext(); continue; @@ -5132,7 +5132,7 @@ void Tokenizer::simplifyVarDecl(bool only_k_r_fpar) else if (tok2->str() == "<" && tok2->previous()->isName() && !tok2->previous()->varId()) tok2->findClosingBracket(tok2); - else if (strchr(";,", tok2->str()[0])) { + else if (std::strchr(";,", tok2->str()[0])) { // "type var =" => "type var; var =" const Token *VarTok = type0->tokAt((int)typelen); while (Token::Match(VarTok, "*|&|const")) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 6e551b3c5..b96e28e2d 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -73,10 +73,10 @@ void TokenList::addtoken(const char str[], const unsigned int lineno, const unsi return; // If token contains # characters, split it up - if (split && strstr(str, "##")) { + if (split && std::strstr(str, "##")) { std::string temp; for (unsigned int i = 0; str[i]; ++i) { - if (strncmp(&str[i], "##", 2) == 0) { + if (std::strncmp(&str[i], "##", 2) == 0) { addtoken(temp.c_str(), lineno, fileno, false); temp.clear(); addtoken("##", lineno, fileno, false); @@ -92,7 +92,7 @@ void TokenList::addtoken(const char str[], const unsigned int lineno, const unsi std::ostringstream str2; if (MathLib::isHex(str) || MathLib::isOct(str) || MathLib::isBin(str)) { str2 << MathLib::toLongNumber(str); - } else if (strncmp(str, "_Bool", 5) == 0) { + } else if (std::strncmp(str, "_Bool", 5) == 0) { str2 << "bool"; } else { str2 << str; @@ -273,7 +273,7 @@ bool TokenList::createTokens(std::istream &code, const std::string& file0) CurrentToken.length() > 0 && std::isdigit(CurrentToken[0])) { // Don't separate doubles "5.4" - } else if (strchr("+-", ch) && + } else if (std::strchr("+-", ch) && CurrentToken.length() > 0 && std::isdigit(CurrentToken[0]) && (CurrentToken[CurrentToken.length()-1] == 'e' || @@ -283,7 +283,7 @@ bool TokenList::createTokens(std::istream &code, const std::string& file0) } else if (CurrentToken.empty() && ch == '.' && std::isdigit(code.peek())) { // tokenize .125 into 0.125 CurrentToken = "0"; - } else if (strchr("+-*/%&|^?!=<>[](){};:,.~\n ", ch)) { + } else if (std::strchr("+-*/%&|^?!=<>[](){};:,.~\n ", ch)) { if (CurrentToken == "#file") { // Handle this where strings are handled continue; @@ -316,7 +316,7 @@ bool TokenList::createTokens(std::istream &code, const std::string& file0) CurrentToken += ch; // Add "++", "--", ">>" or ... token - if (strchr("+-<>=:&|", ch) && (code.peek() == ch)) + if (std::strchr("+-<>=:&|", ch) && (code.peek() == ch)) CurrentToken += (char)code.get(); addtoken(CurrentToken.c_str(), lineno, FileIndex); _back->setExpandedMacro(expandedMacro);