From 4fdb420454cc22fa139ead2d1ac538a09b7b8b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 5 Nov 2010 20:05:57 +0100 Subject: [PATCH] Tokenizer: simplifyknownvariables, improved handling of string constant --- lib/tokenize.cpp | 7 ++++--- test/testsimplifytokens.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 0ecb79228..430480523 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5773,6 +5773,7 @@ bool Tokenizer::simplifyKnownVariables() (Token::Match(tok2, "%var% = %num% ;") || Token::Match(tok2, "%var% = %str% ;") || Token::Match(tok2, "%var% [ ] = %str% ;") || + Token::Match(tok2, "%var% [ %num% ] = %str% ;") || Token::Match(tok2, "%var% = %bool% ;") || Token::Match(tok2, "%var% = %var% ;") || Token::Match(tok2, "%var% = & %var% ;") || @@ -5834,10 +5835,10 @@ bool Tokenizer::simplifyKnownVariables() { value = tok2->strAt(2); valueVarId = tok2->tokAt(2)->varId(); - if (value == "]") + if (Token::simpleMatch(tok2->next(), "[")) { - value = tok2->strAt(4); - valueVarId = tok2->tokAt(4)->varId(); + value = tok2->next()->link()->strAt(2); + valueVarId = 0; } else if (value == "&") { diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 7c1f3a8ff..2a2461689 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -1434,7 +1434,7 @@ private: " const char s [ 5 ] = \"abcd\" ;" " 4 ; " "}"; - TODO_ASSERT_EQUALS(expected, tok(code)); + ASSERT_EQUALS(expected, tok(code)); } }