diff --git a/src/checkclass.cpp b/src/checkclass.cpp index 822c3c9c6..108e405d8 100644 --- a/src/checkclass.cpp +++ b/src/checkclass.cpp @@ -1,6 +1,6 @@ /* * cppcheck - c/c++ syntax checking - * Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam + * Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam * * 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 @@ -26,6 +26,11 @@ #include #include + +#ifdef __BORLANDC__ +#include +#include +#endif //--------------------------------------------------------------------------- CheckClass::CheckClass(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) @@ -92,6 +97,7 @@ struct CheckClass::VAR *CheckClass::ClassChecking_GetVarList(const Token *tok1) if (varname) { struct VAR *var = new VAR; + memset(var, 0, sizeof(struct VAR)); var->name = varname; var->init = false; var->next = varlist; diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index d9ef2f0c2..f44e6f7bd 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -1,6 +1,6 @@ /* * cppcheck - c/c++ syntax checking - * Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam + * Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam * * 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 @@ -26,6 +26,12 @@ #include #include +#ifdef __BORLANDC__ +#include // <- memset +#else +#include +#endif + //--------------------------------------------------------------------------- diff --git a/src/preprocessor.cpp b/src/preprocessor.cpp index 7da73e81d..78cd3597f 100644 --- a/src/preprocessor.cpp +++ b/src/preprocessor.cpp @@ -1,6 +1,6 @@ /* * cppcheck - c/c++ syntax checking - * Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam + * Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam * * 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 @@ -25,6 +25,10 @@ #include +#ifdef __BORLANDC__ +#include +#endif + Preprocessor::Preprocessor() { @@ -50,7 +54,7 @@ std::string Preprocessor::read(std::istream &istr) ++lineno; // Replace assorted special chars with spaces.. - if ((ch != '\n') && (std::isspace(ch) || std::iscntrl(ch))) + if ((ch != '\n') && (isspace(ch) || iscntrl(ch))) ch = ' '; // Skip spaces after ' ' and after '#' diff --git a/src/token.cpp b/src/token.cpp index 33f1ee053..961ac27d4 100644 --- a/src/token.cpp +++ b/src/token.cpp @@ -1,6 +1,6 @@ /* * cppcheck - c/c++ syntax checking - * Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam + * Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam * * 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 @@ -22,6 +22,10 @@ #include #include +#ifdef __BORLANDC__ +#include // isalpha, isdigit +#endif + Token::Token() : _str(""), _cstr(0), @@ -46,8 +50,8 @@ void Token::str(const char s[]) _str = s; std::free(_cstr); _cstr = strdup(s); - _isName = bool(_str[0] == '_' || std::isalpha(_str[0])); - _isNumber = bool(std::isdigit(_str[0]) != 0); + _isName = bool(_str[0] == '_' || isalpha(_str[0])); + _isNumber = bool(isdigit(_str[0]) != 0); if (_str == "true" || _str == "false") _isBoolean = true; else diff --git a/src/tokenize.cpp b/src/tokenize.cpp index f21084ee1..b936ed11f 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -1,6 +1,6 @@ /* * cppcheck - c/c++ syntax checking - * Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam + * Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam * * 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 @@ -37,6 +37,12 @@ #include // <- strtoul #include +#ifdef __BORLANDC__ +#include +#include +#endif + + //--------------------------------------------------------------------------- Tokenizer::Tokenizer() @@ -96,10 +102,10 @@ void Tokenizer::Define(const char Name[], const char Value[]) bool dec = true, hex = true; for (int i = 0; Value[i]; i++) { - if (! std::isdigit(Value[i])) + if (! isdigit(Value[i])) dec = false; - if (! std::isxdigit(Value[i]) && (!(i == 1 && Value[i] == 'x'))) + if (! isxdigit(Value[i]) && (!(i == 1 && Value[i] == 'x'))) hex = false; } @@ -121,6 +127,7 @@ void Tokenizer::Define(const char Name[], const char Value[]) } DefineSymbol *NewSym = new DefineSymbol; + memset(NewSym, 0, sizeof(DefineSymbol)); NewSym->name = strdup(Name); NewSym->value = strValue; NewSym->next = _dsymlist; @@ -300,21 +307,21 @@ void Tokenizer::tokenizeCode(std::istream &code, const unsigned int FileIndex) { if (State == Space1 || State == Space2) { - if (std::isspace(line[i])) + if (isspace(line[i])) continue; State = (State == Space1) ? Id : Value; } else if (State == Id) { - if (std::isspace(line[i])) + if (isspace(line[i])) { strId = CurrentToken; CurrentToken.clear(); State = Space2; continue; } - else if (! std::isalnum(line[i])) + else if (! isalnum(line[i])) { break; } @@ -473,7 +480,7 @@ void Tokenizer::tokenizeCode(std::istream &code, const unsigned int FileIndex) } - if (std::isspace(ch) || std::iscntrl(ch)) + if (isspace(ch) || iscntrl(ch)) { addtoken(CurrentToken.c_str(), lineno, FileIndex); CurrentToken.clear();