diff --git a/tests.cpp b/tests.cpp index 3617412e6..24535269f 100644 --- a/tests.cpp +++ b/tests.cpp @@ -766,5 +766,13 @@ static void unused_variable() "}\n"; check( CheckVariableScope, __LINE__, test5, "" ); + + + const char test6[] = "static void f()\n" + "{\n" + "#define F1(x, y, z) (z ^ (x & (y ^ z)))\n" + "}\n"; + check( CheckVariableScope, __LINE__, test6, "" ); + } diff --git a/tokenize.cpp b/tokenize.cpp index 994263eb9..589b8a9db 100644 --- a/tokenize.cpp +++ b/tokenize.cpp @@ -328,13 +328,20 @@ void TokenizeCode(std::istream &code, const unsigned int FileIndex) State = (State==Space1) ? Id : Value; } - else if (State==Id && std::isspace(line[i])) + else if (State==Id) { - strId = strdup(CurrentToken); - memset(CurrentToken, 0, sizeof(CurrentToken)); - pToken = CurrentToken; - State = Space2; - continue; + if ( std::isspace( line[i] ) ) + { + strId = strdup(CurrentToken); + memset(CurrentToken, 0, sizeof(CurrentToken)); + pToken = CurrentToken; + State = Space2; + continue; + } + else if ( ! std::isalnum(line[i]) ) + { + break; + } } *pToken = line[i];