Reverted [890] it cause more problems with Visual C++

This commit is contained in:
Daniel Marjamäki 2009-01-07 15:43:20 +00:00
parent 9239ebc6d1
commit 40637e436f
5 changed files with 41 additions and 14 deletions

View File

@ -1,6 +1,6 @@
/* /*
* cppcheck - c/c++ syntax checking * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -26,6 +26,11 @@
#include <cstring> #include <cstring>
#include <algorithm> #include <algorithm>
#ifdef __BORLANDC__
#include <ctype.h>
#include <mem.h>
#endif
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
CheckClass::CheckClass(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) 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) if (varname)
{ {
struct VAR *var = new VAR; struct VAR *var = new VAR;
memset(var, 0, sizeof(struct VAR));
var->name = varname; var->name = varname;
var->init = false; var->init = false;
var->next = varlist; var->next = varlist;

View File

@ -1,6 +1,6 @@
/* /*
* cppcheck - c/c++ syntax checking * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -26,6 +26,12 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#ifdef __BORLANDC__
#include <mem.h> // <- memset
#else
#include <string.h>
#endif
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/* /*
* cppcheck - c/c++ syntax checking * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -25,6 +25,10 @@
#include <sstream> #include <sstream>
#ifdef __BORLANDC__
#include <ctype>
#endif
Preprocessor::Preprocessor() Preprocessor::Preprocessor()
{ {
@ -50,7 +54,7 @@ std::string Preprocessor::read(std::istream &istr)
++lineno; ++lineno;
// Replace assorted special chars with spaces.. // Replace assorted special chars with spaces..
if ((ch != '\n') && (std::isspace(ch) || std::iscntrl(ch))) if ((ch != '\n') && (isspace(ch) || iscntrl(ch)))
ch = ' '; ch = ' ';
// Skip spaces after ' ' and after '#' // Skip spaces after ' ' and after '#'

View File

@ -1,6 +1,6 @@
/* /*
* cppcheck - c/c++ syntax checking * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -22,6 +22,10 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
#ifdef __BORLANDC__
#include <ctype.h> // isalpha, isdigit
#endif
Token::Token() : Token::Token() :
_str(""), _str(""),
_cstr(0), _cstr(0),
@ -46,8 +50,8 @@ void Token::str(const char s[])
_str = s; _str = s;
std::free(_cstr); std::free(_cstr);
_cstr = strdup(s); _cstr = strdup(s);
_isName = bool(_str[0] == '_' || std::isalpha(_str[0])); _isName = bool(_str[0] == '_' || isalpha(_str[0]));
_isNumber = bool(std::isdigit(_str[0]) != 0); _isNumber = bool(isdigit(_str[0]) != 0);
if (_str == "true" || _str == "false") if (_str == "true" || _str == "false")
_isBoolean = true; _isBoolean = true;
else else

View File

@ -1,6 +1,6 @@
/* /*
* cppcheck - c/c++ syntax checking * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -37,6 +37,12 @@
#include <stdlib.h> // <- strtoul #include <stdlib.h> // <- strtoul
#include <stdio.h> #include <stdio.h>
#ifdef __BORLANDC__
#include <ctype.h>
#include <mem.h>
#endif
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
Tokenizer::Tokenizer() Tokenizer::Tokenizer()
@ -96,10 +102,10 @@ void Tokenizer::Define(const char Name[], const char Value[])
bool dec = true, hex = true; bool dec = true, hex = true;
for (int i = 0; Value[i]; i++) for (int i = 0; Value[i]; i++)
{ {
if (! std::isdigit(Value[i])) if (! isdigit(Value[i]))
dec = false; dec = false;
if (! std::isxdigit(Value[i]) && (!(i == 1 && Value[i] == 'x'))) if (! isxdigit(Value[i]) && (!(i == 1 && Value[i] == 'x')))
hex = false; hex = false;
} }
@ -121,6 +127,7 @@ void Tokenizer::Define(const char Name[], const char Value[])
} }
DefineSymbol *NewSym = new DefineSymbol; DefineSymbol *NewSym = new DefineSymbol;
memset(NewSym, 0, sizeof(DefineSymbol));
NewSym->name = strdup(Name); NewSym->name = strdup(Name);
NewSym->value = strValue; NewSym->value = strValue;
NewSym->next = _dsymlist; NewSym->next = _dsymlist;
@ -300,21 +307,21 @@ void Tokenizer::tokenizeCode(std::istream &code, const unsigned int FileIndex)
{ {
if (State == Space1 || State == Space2) if (State == Space1 || State == Space2)
{ {
if (std::isspace(line[i])) if (isspace(line[i]))
continue; continue;
State = (State == Space1) ? Id : Value; State = (State == Space1) ? Id : Value;
} }
else if (State == Id) else if (State == Id)
{ {
if (std::isspace(line[i])) if (isspace(line[i]))
{ {
strId = CurrentToken; strId = CurrentToken;
CurrentToken.clear(); CurrentToken.clear();
State = Space2; State = Space2;
continue; continue;
} }
else if (! std::isalnum(line[i])) else if (! isalnum(line[i]))
{ {
break; 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); addtoken(CurrentToken.c_str(), lineno, FileIndex);
CurrentToken.clear(); CurrentToken.clear();