From 506fc0e16d243d3f9446375391b19d474c27924d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 19 Mar 2008 17:09:51 +0000 Subject: [PATCH] tokenize: Fixed two bugs * don't hang if we can't find the ending of a string. * don't divide by zero --- tokenize.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tokenize.cpp b/tokenize.cpp index 589b8a9db..ee7efcb6e 100644 --- a/tokenize.cpp +++ b/tokenize.cpp @@ -466,7 +466,7 @@ void TokenizeCode(std::istream &code, const unsigned int FileIndex) // Get next character c = (char)code.get(); } - while (special || c != '\"'); + while (!code.eof() && (special || c != '\"')); *pToken = '\"'; addtoken(CurrentToken, lineno, FileIndex); memset(CurrentToken, 0, sizeof(CurrentToken)); @@ -808,10 +808,13 @@ void SimplifyTokenList() IsNumber(getstr(tok,3)) && strchr("],);=<>",*(getstr(tok,4))) ) { - done = false; - int i1 = atoi(getstr(tok,1)); int i2 = atoi(getstr(tok,3)); + if ( i2 == 0 && *(getstr(tok,2)) == '/' ) + { + continue; + } + switch (*(getstr(tok,2))) { case '+': i1 += i2; break; @@ -828,6 +831,8 @@ void SimplifyTokenList() { DeleteNextToken(tok); } + + done = false; } } }