Formatting: uniformize end of lines.

This commit is contained in:
Nicolas Le Cam 2008-12-13 11:39:36 +00:00
parent 13bcb66c14
commit 661068bcd4
11 changed files with 377 additions and 377 deletions

View File

@ -72,17 +72,17 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
varc = 2 * ( varc - 1 );
// Array index..
if ( varid > 0 )
{
if ( TOKEN::Match(tok, "%varid% [ %num% ]", 0, 0, varid) )
{
const char *num = tok->strAt(2);
if (strtol(num, NULL, 10) >= size)
{
ReportError(tok->next(), "Array index out of bounds");
}
}
// Array index..
if ( varid > 0 )
{
if ( TOKEN::Match(tok, "%varid% [ %num% ]", 0, 0, varid) )
{
const char *num = tok->strAt(2);
if (strtol(num, NULL, 10) >= size)
{
ReportError(tok->next(), "Array index out of bounds");
}
}
}
else if ( TOKEN::Match(tok, "%var1% [ %num% ]", varname) )
{
@ -108,18 +108,18 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
if ( indentlevel < 0 )
return;
}
// Array index..
if ( varid > 0 )
{
if ( !tok->isName() && !TOKEN::Match(tok,"[.&]") && TOKEN::Match(tok->next(), "%varid% [ %num% ]", 0, 0, varid) )
{
const char *num = tok->strAt(3);
if (strtol(num, NULL, 10) >= size)
{
ReportError(tok->next(), "Array index out of bounds");
}
}
// Array index..
if ( varid > 0 )
{
if ( !tok->isName() && !TOKEN::Match(tok,"[.&]") && TOKEN::Match(tok->next(), "%varid% [ %num% ]", 0, 0, varid) )
{
const char *num = tok->strAt(3);
if (strtol(num, NULL, 10) >= size)
{
ReportError(tok->next(), "Array index out of bounds");
}
}
}
else if ( !tok->isName() && !TOKEN::Match(tok,"[.&]") && TOKEN::Match(tok->next(), "%var1% [ %num% ]", varname) )
{
@ -133,22 +133,22 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
}
// memset, memcmp, memcpy, strncpy, fgets..
if ( varid > 0 )
{
if ( TOKEN::Match(tok, "memset|memcpy|memmove|memcmp|strncpy|fgets") )
{
if ( TOKEN::Match( tok->next(), "( %varid% , %num% , %num% )", 0, 0, varid ) ||
TOKEN::Match( tok->next(), "( %var% , %varid% , %num% )", 0, 0, varid ) )
{
const char *num = tok->strAt(6);
if ( atoi(num) > total_size )
{
ReportError(tok, "Buffer overrun");
}
}
continue;
}
// memset, memcmp, memcpy, strncpy, fgets..
if ( varid > 0 )
{
if ( TOKEN::Match(tok, "memset|memcpy|memmove|memcmp|strncpy|fgets") )
{
if ( TOKEN::Match( tok->next(), "( %varid% , %num% , %num% )", 0, 0, varid ) ||
TOKEN::Match( tok->next(), "( %var% , %varid% , %num% )", 0, 0, varid ) )
{
const char *num = tok->strAt(6);
if ( atoi(num) > total_size )
{
ReportError(tok, "Buffer overrun");
}
}
continue;
}
}
else if (TOKEN::Match(tok,"memset|memcpy|memmove|memcmp|strncpy|fgets") )
{
@ -359,14 +359,14 @@ void CheckBufferOverrunClass::CheckBufferOverrun_LocalVariable()
{
const char *varname[2] = {0};
unsigned int size = 0;
const char *type = 0;
const char *type = 0;
unsigned int varid = 0;
if (TOKEN::Match(tok, "%type% %var% [ %num% ] ;"))
{
varname[0] = tok->strAt(1);
size = strtoul(tok->strAt(3), NULL, 10);
type = tok->aaaa();
type = tok->aaaa();
varid = tok->tokAt(1)->varId();
}
else if (indentlevel > 0 && TOKEN::Match(tok, "[*;{}] %var% = new %type% [ %num% ]"))
@ -374,7 +374,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_LocalVariable()
varname[0] = tok->strAt(1);
size = strtoul(tok->strAt(6), NULL, 10);
type = tok->strAt(4);
varid = tok->tokAt(1)->varId();
varid = tok->tokAt(1)->varId();
}
else
{

View File

@ -281,14 +281,14 @@ void CheckMemoryLeakClass::MismatchError( const TOKEN *Tok1, const std::list<con
void CheckMemoryLeakClass::MemoryLeak( const TOKEN *tok, const char varname[], AllocType alloctype )
{
std::ostringstream errmsg;
errmsg << _tokenizer->fileLine(tok);
if( alloctype == CheckMemoryLeakClass::FOPEN ||
alloctype == CheckMemoryLeakClass::POPEN )
errmsg << ": Resource leak: ";
else
errmsg << ": Memory leak: ";
errmsg << _tokenizer->fileLine(tok);
if( alloctype == CheckMemoryLeakClass::FOPEN ||
alloctype == CheckMemoryLeakClass::POPEN )
errmsg << ": Resource leak: ";
else
errmsg << ": Memory leak: ";
errmsg << varname;
_errorLogger->reportErr( errmsg.str() );
}
@ -403,21 +403,21 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *>
// assignment..
else
{
// is the pointer in rhs?
bool rhs = false;
for ( const TOKEN *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next() )
{
if ( tok2->str() == ";" )
break;
if ( tok2->str() == varname )
{
rhs = true;
break;
}
}
{
// is the pointer in rhs?
bool rhs = false;
for ( const TOKEN *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next() )
{
if ( tok2->str() == ";" )
break;
if ( tok2->str() == varname )
{
rhs = true;
break;
}
}
addtoken( rhs ? "use" : "assign" );
}
}

View File

@ -197,7 +197,7 @@ void CppCheck::check()
_checkFunctionUsage.check();
}
_errorList.clear();
}
@ -215,9 +215,9 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
std::istringstream istr(code);
_tokenizer.tokenize(istr, FileName);
}
// Set variable id
_tokenizer.setVarId();
// Set variable id
_tokenizer.setVarId();
_tokenizer.fillFunctionList();

View File

@ -30,7 +30,7 @@
Preprocessor::Preprocessor()
{
}
/** Just read the code into a string. Perform simple cleanup of the code */
@ -46,7 +46,7 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename)
for (char ch = (char)istr.get(); istr.good(); ch = (char)istr.get())
{
if ( ch < 0 )
continue;
continue;
if ( ch == '\n' )
++lineno;

View File

@ -25,13 +25,13 @@
#include <istream>
#include <string>
#include <list>
class Preprocessor
{
public:
Preprocessor();
void preprocess(std::istream &istr, std::map<std::string, std::string> &result, const std::string &filename);
/** Just read the code into a string. Perform simple cleanup of the code */

View File

@ -42,9 +42,9 @@ private:
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize( istr, "test.cpp" );
tokenizer.simplifyTokenList();
// Assign variable ids
tokenizer.simplifyTokenList();
// Assign variable ids
tokenizer.setVarId();
// Fill function list
@ -81,9 +81,9 @@ private:
TEST_CASE( array_index_12 );
TEST_CASE( buffer_overrun_1 );
TEST_CASE( buffer_overrun_2 );
TEST_CASE( varid1 );
TEST_CASE( buffer_overrun_2 );
TEST_CASE( varid1 );
TEST_CASE( varid2 );
}
@ -358,37 +358,37 @@ private:
ASSERT_EQUALS( std::string("[test.cpp:8]: Buffer overrun\n"), errout.str() );
}
void varid1()
{
check( "void foo()\n"
"{\n"
" char str[10];\n"
" if (str[0])\n"
" {\n"
" char str[50];\n"
" str[30] = 0;\n"
" }\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}
void varid2()
{
check( "void foo()\n"
"{\n"
" char str[10];\n"
" if (str[0])\n"
" {\n"
" char str[50];\n"
" memset(str,0,50);\n"
" }\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}
void varid1()
{
check( "void foo()\n"
"{\n"
" char str[10];\n"
" if (str[0])\n"
" {\n"
" char str[50];\n"
" str[30] = 0;\n"
" }\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}
void varid2()
{
check( "void foo()\n"
"{\n"
" char str[10];\n"
" if (str[0])\n"
" {\n"
" char str[50];\n"
" memset(str,0,50);\n"
" }\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}
};

View File

@ -103,8 +103,8 @@ private:
TEST_CASE( switch2 );
TEST_CASE( ret1 );
TEST_CASE( ret2 );
TEST_CASE( ret3 );
TEST_CASE( ret2 );
TEST_CASE( ret3 );
TEST_CASE( ret4 );
TEST_CASE( mismatch1 );
@ -116,7 +116,7 @@ private:
TEST_CASE( func5 );
TEST_CASE( func6 );
// TODO TEST_CASE( func7 );
TEST_CASE( func8 ); // Using callback
TEST_CASE( func8 ); // Using callback
// TODO TEST_CASE( func9 ); // Embedding the function call in a if-condition
TEST_CASE( class1 );
@ -692,24 +692,24 @@ private:
ASSERT_EQUALS( std::string("[test.cpp:6]: Memory leak: abc\n"), errout.str() );
}
void ret3()
{
check( "void foo()\n"
"{\n"
" FILE *filep = fopen(\"myfile.txt\",\"w\");\n"
"}\n" );
ASSERT_EQUALS( std::string("[test.cpp:4]: Resource leak: filep\n"), errout.str() );
void ret3()
{
check( "void foo()\n"
"{\n"
" FILE *filep = fopen(\"myfile.txt\",\"w\");\n"
"}\n" );
ASSERT_EQUALS( std::string("[test.cpp:4]: Resource leak: filep\n"), errout.str() );
}
void ret4()
{
check( "void foo()\n"
"{\n"
" FILE *p = popen( \"ls -l\", \"r\");\n"
"}\n" );
ASSERT_EQUALS( std::string("[test.cpp:4]: Resource leak: p\n"), errout.str() );
void ret4()
{
check( "void foo()\n"
"{\n"
" FILE *p = popen( \"ls -l\", \"r\");\n"
"}\n" );
ASSERT_EQUALS( std::string("[test.cpp:4]: Resource leak: p\n"), errout.str() );
}
void mismatch1()
@ -845,23 +845,23 @@ private:
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}
void func9()
{
check( "int b()\n"
"{\n"
" return 0;\n"
"}\n"
"\n"
"void a()\n"
"{\n"
" char *a = new char[10];\n"
" if (b())\n"
" return;\n"
" delete [] a;\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
void func9()
{
check( "int b()\n"
"{\n"
" return 0;\n"
"}\n"
"\n"
"void a()\n"
"{\n"
" char *a = new char[10];\n"
" if (b())\n"
" return;\n"
" delete [] a;\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}
@ -1066,15 +1066,15 @@ private:
" free(a - 10);\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
check( "void foo()\n"
"{\n"
" char *a = (char *)malloc(10);\n"
" a = (void *)a + 10;\n"
" free(a - 10);\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
check( "void foo()\n"
"{\n"
" char *a = (char *)malloc(10);\n"
" a = (void *)a + 10;\n"
" free(a - 10);\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}

View File

@ -50,8 +50,8 @@ private:
TEST_CASE( multi_compare );
TEST_CASE( match1 );
TEST_CASE( match1 );
TEST_CASE( match2 );
TEST_CASE( varid1 );
@ -265,68 +265,68 @@ private:
}
}
void match2()
{
{
const std::string code("");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// Match..
ASSERT_EQUALS( true, TOKEN::Match(tokenizer.tokens(), "!!else") );
}
{
const std::string code("if ;");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// Match..
ASSERT_EQUALS( true, TOKEN::Match(tokenizer.tokens(), "if ; !!else") );
}
{
const std::string code("if ; something");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// Match..
ASSERT_EQUALS( true, TOKEN::Match(tokenizer.tokens(), "if ; !!else") );
}
{
const std::string code("else");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// Match..
ASSERT_EQUALS( false, TOKEN::Match(tokenizer.tokens(), "!!else") );
}
{
const std::string code("if ; else");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// Match..
ASSERT_EQUALS( false, TOKEN::Match(tokenizer.tokens(), "if ; !!else") );
}
}
void match2()
{
{
const std::string code("");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// Match..
ASSERT_EQUALS( true, TOKEN::Match(tokenizer.tokens(), "!!else") );
}
{
const std::string code("if ;");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// Match..
ASSERT_EQUALS( true, TOKEN::Match(tokenizer.tokens(), "if ; !!else") );
}
{
const std::string code("if ; something");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// Match..
ASSERT_EQUALS( true, TOKEN::Match(tokenizer.tokens(), "if ; !!else") );
}
{
const std::string code("else");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// Match..
ASSERT_EQUALS( false, TOKEN::Match(tokenizer.tokens(), "!!else") );
}
{
const std::string code("if ; else");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// Match..
ASSERT_EQUALS( false, TOKEN::Match(tokenizer.tokens(), "if ; !!else") );
}
}
void varid1()
{

186
token.cpp
View File

@ -19,7 +19,7 @@
#include "token.h"
#include <cstdlib>
#include <cstring>
#include <string>
#include <string>
#include <iostream>
#ifdef __BORLANDC__
@ -32,11 +32,11 @@ TOKEN::TOKEN()
_cstr = 0;
_str = "";
_linenr = 0;
_next = 0;
_next = 0;
_previous = 0;
_varId = 0;
_isName = false;
_isNumber = false;
_isNumber = false;
}
TOKEN::~TOKEN()
@ -141,24 +141,24 @@ int TOKEN::multiCompare( const char *needle, const char *haystack )
return -1;
}
bool TOKEN::Match(const TOKEN *tok, const char pattern[], const char *varname1[], const char *varname2[], unsigned int varid)
{
const char *p = pattern;
while ( *p )
{
{
// Skip spaces in pattern..
while ( *p == ' ' )
p++;
if (!tok)
{
// If we have no tokens, pattern "!!else" should return true
if( isNotPattern( p ) )
return true;
else
return false;
}
if (!tok)
{
// If we have no tokens, pattern "!!else" should return true
if( isNotPattern( p ) )
return true;
else
return false;
}
// Extract token from pattern..
// TODO: Refactor this so there can't be buffer overflows
@ -221,7 +221,7 @@ bool TOKEN::Match(const TOKEN *tok, const char pattern[], const char *varname1[]
if ( tok->varId() != varid )
return false;
}
else if (strcmp(str,"%num%")==0)
{
if ( ! tok->isNumber() )
@ -257,13 +257,13 @@ bool TOKEN::Match(const TOKEN *tok, const char pattern[], const char *varname1[]
// No match
return false;
}
}
// Parse "not" options. Token can be anything except the given one
else if( isNotPattern( str ) )
{
if( strcmp( tok->aaaa(), &(str[2]) ) == 0 )
return false;
}
// Parse "not" options. Token can be anything except the given one
else if( isNotPattern( str ) )
{
if( strcmp( tok->aaaa(), &(str[2]) ) == 0 )
return false;
}
else if (str != tok->_str)
@ -275,14 +275,14 @@ bool TOKEN::Match(const TOKEN *tok, const char pattern[], const char *varname1[]
// The end of the pattern has been reached and nothing wrong has been found
return true;
}
bool TOKEN::isNotPattern( const char *pattern )
{
if( pattern && strlen(pattern) > 2 && pattern[0] == '!' && pattern[1] == '!' )
return true;
else
return false;
}
bool TOKEN::isNotPattern( const char *pattern )
{
if( pattern && strlen(pattern) > 2 && pattern[0] == '!' && pattern[1] == '!' )
return true;
else
return false;
}
bool TOKEN::isName() const
{
@ -355,50 +355,50 @@ void TOKEN::next( TOKEN *next )
{
_next = next;
}
TOKEN *TOKEN::previous() const
{
return _previous;
}
void TOKEN::previous( TOKEN *previous )
{
_previous = previous;
}
void TOKEN::insertToken( const char *str )
{
TOKEN *newToken = new TOKEN;
newToken->setstr( str );
if( this->next() )
{
newToken->next( this->next() );
newToken->next()->previous( newToken );
}
this->next( newToken );
newToken->previous( this );
}
void TOKEN::eraseTokens( TOKEN *begin, const TOKEN *end )
{
if ( ! begin )
return;
while ( begin->next() && begin->next() != end )
{
begin->eraseToken();
}
}
void TOKEN::eraseToken()
{
TOKEN *next = this->next();
this->next( next->next() );
if ( next->next() )
next->next()->previous( this );
delete next;
}
TOKEN *TOKEN::previous() const
{
return _previous;
}
void TOKEN::previous( TOKEN *previous )
{
_previous = previous;
}
void TOKEN::insertToken( const char *str )
{
TOKEN *newToken = new TOKEN;
newToken->setstr( str );
if( this->next() )
{
newToken->next( this->next() );
newToken->next()->previous( newToken );
}
this->next( newToken );
newToken->previous( this );
}
void TOKEN::eraseTokens( TOKEN *begin, const TOKEN *end )
{
if ( ! begin )
return;
while ( begin->next() && begin->next() != end )
{
begin->eraseToken();
}
}
void TOKEN::eraseToken()
{
TOKEN *next = this->next();
this->next( next->next() );
if ( next->next() )
next->next()->previous( this );
delete next;
}
unsigned int TOKEN::fileIndex() const
{
@ -419,22 +419,22 @@ void TOKEN::linenr( unsigned int linenr )
{
_linenr = linenr;
}
void TOKEN::printOut( const char *title ) const
{
std::cout << std::endl << "###";
if ( title )
std::cout << " " << title << " ";
else
std::cout << "########";
std::cout << "###" << std::endl;
for( const TOKEN *t = this; t; t = t->next() )
{
std::cout << t->linenr() << ": " << t->str();
if ( t->varId() )
std::cout << " ("<< t->varId() <<")";
std::cout << std::endl;
}
}
void TOKEN::printOut( const char *title ) const
{
std::cout << std::endl << "###";
if ( title )
std::cout << " " << title << " ";
else
std::cout << "########";
std::cout << "###" << std::endl;
for( const TOKEN *t = this; t; t = t->next() )
{
std::cout << t->linenr() << ": " << t->str();
if ( t->varId() )
std::cout << " ("<< t->varId() <<")";
std::cout << std::endl;
}
}

92
token.h
View File

@ -70,11 +70,11 @@ public:
* "%num%" Any numeric token, e.g. "23"
* "%str%" Any token starting with "-character (C-string).
* "%var1%" Match with parameter varname1
* "%var2%" Match with parameter varname2
* "%var2%" Match with parameter varname2
* "%varid%" Match with parameter varid
* "[abc]" Any of the characters 'a' or 'b' or 'c'
* "int|void|char" Any of the strings, int, void or char
* "int|void|char|" Any of the strings, int, void or char or empty string
* "int|void|char|" Any of the strings, int, void or char or empty string
* "!!else" No tokens or any token that is not "else".
* "someRandomText" If token contains "someRandomText".
*
@ -92,7 +92,7 @@ public:
* @return true if given token matches with given pattern
* false if given token does not match with given pattern
*/
static bool Match(const TOKEN *tok, const char pattern[], const char *varname1[]=0, const char *varname2[]=0, unsigned int varid=0);
static bool Match(const TOKEN *tok, const char pattern[], const char *varname1[]=0, const char *varname2[]=0, unsigned int varid=0);
bool isName() const;
bool isNumber() const;
@ -124,59 +124,59 @@ public:
TOKEN *next() const;
/**
* Delete tokens between begin and end. E.g. if begin = 1
* and end = 5, tokens 2,3 and 4 would be erased.
*
* @param begin Tokens after this will be erased.
* @param end Tokens before this will be erased.
*/
static void eraseTokens( TOKEN *begin, const TOKEN *end );
void eraseToken();
/**
* Insert new token after this token. This function will handle
* relations between next and previous token also.
* @param str String for the new token.
*/
void insertToken( const char *str );
TOKEN *previous() const;
/**
* Delete tokens between begin and end. E.g. if begin = 1
* and end = 5, tokens 2,3 and 4 would be erased.
*
* @param begin Tokens after this will be erased.
* @param end Tokens before this will be erased.
*/
static void eraseTokens( TOKEN *begin, const TOKEN *end );
void eraseToken();
/**
* Insert new token after this token. This function will handle
* relations between next and previous token also.
* @param str String for the new token.
*/
void insertToken( const char *str );
TOKEN *previous() const;
unsigned int varId() const;
void varId( unsigned int id );
/**
* For debugging purposes, prints token and all tokens
* followed by it.
* @param title Title for the printout or use default parameter or 0
* for no title.
*/
void varId( unsigned int id );
/**
* For debugging purposes, prints token and all tokens
* followed by it.
* @param title Title for the printout or use default parameter or 0
* for no title.
*/
void printOut( const char *title = 0 ) const;
private:
void next( TOKEN *next );
void previous( TOKEN *previous );
/**
* Return true if pattern is e.g. "!!else".
* See Match() for more info.
*
* @param pattern Pattern to match, e.g. "if ; !!else"
* @return true if pattern starts with "!!" and contains 3
* or more characters.
*/
static bool isNotPattern( const char *pattern );
private:
void next( TOKEN *next );
void previous( TOKEN *previous );
/**
* Return true if pattern is e.g. "!!else".
* See Match() for more info.
*
* @param pattern Pattern to match, e.g. "if ; !!else"
* @return true if pattern starts with "!!" and contains 3
* or more characters.
*/
static bool isNotPattern( const char *pattern );
std::string _str;
char * _cstr;
bool _isName;
bool _isNumber;
unsigned int _varId;
TOKEN *_next;
TOKEN *_next;
TOKEN *_previous;
unsigned int _fileIndex;
unsigned int _linenr;

View File

@ -160,19 +160,19 @@ void Tokenizer::addtoken(const char str[], const unsigned int lineno, const unsi
}
if (_tokensBack)
{
_tokensBack->insertToken( str2.str().c_str() );
_tokensBack = _tokensBack->next();
{
_tokensBack->insertToken( str2.str().c_str() );
_tokensBack = _tokensBack->next();
}
else
{
_tokens = new TOKEN;
_tokensBack = _tokens;
_tokens = new TOKEN;
_tokensBack = _tokens;
_tokensBack->setstr( str2.str().c_str() );
}
_tokensBack->linenr( lineno );
_tokensBack->fileIndex( fileno );
}
_tokensBack->linenr( lineno );
_tokensBack->fileIndex( fileno );
// Check if str is defined..
for (DefineSymbol *sym = _dsymlist; sym; sym = sym->next)
@ -212,10 +212,10 @@ int Tokenizer::SizeOfType(const char type[]) const
void Tokenizer::InsertTokens(TOKEN *dest, TOKEN *src, unsigned int n)
{
while (n > 0)
{
dest->insertToken( src->aaaa() );
dest->next()->fileIndex( src->fileIndex() );
dest->next()->linenr( src->linenr() );
{
dest->insertToken( src->aaaa() );
dest->next()->fileIndex( src->fileIndex() );
dest->next()->linenr( src->linenr() );
dest = dest->next();
src = src->next();
n--;
@ -562,9 +562,9 @@ void Tokenizer::tokenizeCode(std::istream &code, const unsigned int FileIndex)
if (tok2->aaaa()!=type3 && (tok2->str() == type3))
{
tok2->setstr(type1);
tok2->insertToken( type2 );
tok2->next()->fileIndex( tok2->fileIndex() );
tok2->next()->linenr( tok2->linenr() );
tok2->insertToken( type2 );
tok2->next()->fileIndex( tok2->fileIndex() );
tok2->next()->linenr( tok2->linenr() );
tok2 = tok2->next();
}
}
@ -581,8 +581,8 @@ void Tokenizer::tokenizeCode(std::istream &code, const unsigned int FileIndex)
{
bool last = TOKEN::Match( tok->next(), "}" );
// Unlink and delete tok->next()
tok->eraseToken();
// Unlink and delete tok->next()
tok->eraseToken();
// break if this was the last token to delete..
if (last)