diff --git a/CheckMemoryLeak.cpp b/CheckMemoryLeak.cpp index 3450bdb2a..d417407e7 100644 --- a/CheckMemoryLeak.cpp +++ b/CheckMemoryLeak.cpp @@ -155,10 +155,6 @@ static void CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const char varname[] { Alloc = alloc; alloc_indentlevel = indentlevel; - - // Is there a comment such as "var is deleted automaticly" - if ( Alloc == New && isdeleted(tok->str) > 0 ) - return; } } diff --git a/tokenize.cpp b/tokenize.cpp index 08543b947..6202a7dc5 100644 --- a/tokenize.cpp +++ b/tokenize.cpp @@ -287,18 +287,8 @@ void Tokenize(const char FileName[]) // Tokenize - tokenizes input stream //--------------------------------------------------------------------------- -struct DeleteComment -{ - unsigned int LineNr; - std::string Str; -}; - -std::list< DeleteComment > DeleteComments; - void TokenizeCode(std::istream &code, const unsigned int FileIndex) { - DeleteComments.clear(); - // Tokenize the file. unsigned int lineno = 1; char CurrentToken[1000] = {0}; @@ -415,14 +405,25 @@ void TokenizeCode(std::istream &code, const unsigned int FileIndex) if (ch == '/') { std::string comment; - getline( code, comment ); - if ( newstatement && comment.find(" delete")!=std::string::npos ) + getline( code, comment ); // Parse in the whole comment + + // If the comment says something like "fred is deleted" then generate appropriate tokens for that + comment = comment + " "; + if ( newstatement && comment.find(" deleted ")!=std::string::npos ) { - DeleteComment dc; - dc.LineNr = lineno; - dc.Str = comment; - DeleteComments.push_back( dc ); + // delete + addtoken( "delete", lineno, FileIndex ); + + // fred + std::string::size_type pos1 = comment.find_first_not_of(" \t"); + std::string::size_type pos2 = comment.find(" ", pos1); + std::string firstWord = comment.substr( pos1, pos2-pos1 ); + addtoken( firstWord.c_str(), lineno, FileIndex ); + + // ; + addtoken( ";", lineno, FileIndex ); } + lineno++; continue; } @@ -1113,15 +1114,3 @@ void DeallocateTokens() -int isdeleted( const char varname[] ) -{ - std::list::const_iterator it; - for ( it = DeleteComments.begin(); it != DeleteComments.end(); it++ ) - { - const DeleteComment &dc = *it; - if ( dc.Str.find( varname ) != std::string::npos ) - return dc.LineNr; - } - return -1; -} - diff --git a/tokenize.h b/tokenize.h index d8bc250fb..a249ae074 100644 --- a/tokenize.h +++ b/tokenize.h @@ -40,10 +40,6 @@ const TOKEN *gettok(const TOKEN *tok, int index); const char *getstr(const TOKEN *tok, int index); -// Delete comments such as "fred is deleted automaticly" -int isdeleted( const char varname[] ); - - //--------------------------------------------------------------------------- #endif