From 7ff692341e795a60df456d12b2486d6be2c656d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 28 May 2020 22:03:01 +0200 Subject: [PATCH] Fixed #9730 (Regression: TEXT macro not handled in windows code) --- lib/tokenize.cpp | 13 +++++++++---- test/testsimplifytokens.cpp | 6 ++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 33577c76e..a07ad9c48 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2484,14 +2484,19 @@ void Tokenizer::combineOperators() void Tokenizer::combineStringAndCharLiterals() { // Combine strings - for (Token *tok = list.front(); - tok; - tok = tok->next()) { + for (Token *tok = list.front(); tok; tok = tok->next()) { if (!isStringLiteral(tok->str())) continue; tok->str(simplifyString(tok->str())); - while (tok->next() && tok->next()->tokType() == Token::eString) { + + while (Token::Match(tok->next(), "%str%") || Token::Match(tok->next(), "_T|_TEXT|TEXT ( %str% )")) { + if (tok->next()->isName()) { + if (!mSettings->isWindowsPlatform()) + break; + tok->deleteNext(2); + tok->next()->deleteNext(); + } // Two strings after each other, combine them tok->concatStr(simplifyString(tok->next()->str())); tok->deleteNext(); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index d4772b2b3..f7e1b4452 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -1800,6 +1800,12 @@ private: "};\n" "}\n"; ASSERT_EQUALS(tok(code2), tok(code1)); + + const char code3[] = "x = L\"1\" TEXT(\"2\") L\"3\";"; + ASSERT_EQUALS("x = L\"123\" ;", tok(code3, false, Settings::Win64)); + + const char code4[] = "x = TEXT(\"1\") L\"2\";"; + ASSERT_EQUALS("x = L\"1\" L\"2\" ;", tok(code4, false, Settings::Win64)); } void combine_wstrings() {