diff --git a/cfg/windows.cfg b/cfg/windows.cfg
index 7a7d47c39..4232b935c 100644
--- a/cfg/windows.cfg
+++ b/cfg/windows.cfg
@@ -5201,7 +5201,6 @@ HFONT CreateFont(
-
diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp
index 7cb23053b..2ef761997 100644
--- a/lib/tokenize.cpp
+++ b/lib/tokenize.cpp
@@ -9541,13 +9541,13 @@ void Tokenizer::simplifyMicrosoftStringFunctions()
if (match!=apis.end()) {
tok->str(ansi ? match->second.mbcs : match->second.unicode);
tok->originalName(match->first);
- } else if (Token::Match(tok, "_T ( %char%|%str% )")) {
+ } else if (Token::Match(tok, "_T|_TEXT|TEXT ( %char%|%str% )")) {
tok->deleteNext();
tok->deleteThis();
tok->deleteNext();
if (!ansi)
tok->isLong(true);
- while (Token::Match(tok->next(), "_T ( %char%|%str% )")) {
+ while (Token::Match(tok->next(), "_T|_TEXT|TEXT ( %char%|%str% )")) {
tok->next()->deleteNext();
tok->next()->deleteThis();
tok->next()->deleteNext();
diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp
index 3fbe8081d..8188287d1 100644
--- a/test/testtokenize.cpp
+++ b/test/testtokenize.cpp
@@ -364,6 +364,7 @@ private:
TEST_CASE(simplifyNamespaceStd);
TEST_CASE(microsoftMemory);
+ TEST_CASE(microsoftString);
TEST_CASE(borland);
@@ -5718,6 +5719,25 @@ private:
ASSERT_EQUALS("void foo ( ) { memset ( f ( 1 , g ( a , b ) ) , 255 , h ( i , j ( 0 , 1 ) ) ) ; }", tokenizeAndStringify(code7,false,true,Settings::Win32A));
}
+ void microsoftString() {
+ const char code1a[] = "void foo() { _tprintf (_T(\"test\") _T(\"1\")); }";
+ ASSERT_EQUALS("void foo ( ) { printf ( \"test1\" ) ; }", tokenizeAndStringify(code1a, false, true, Settings::Win32A));
+ const char code1b[] = "void foo() { _tprintf (_TEXT(\"test\") _TEXT(\"2\")); }";
+ ASSERT_EQUALS("void foo ( ) { printf ( \"test2\" ) ; }", tokenizeAndStringify(code1b, false, true, Settings::Win32A));
+ const char code1c[] = "void foo() { _tprintf (TEXT(\"test\") TEXT(\"3\")); }";
+ ASSERT_EQUALS("void foo ( ) { printf ( \"test3\" ) ; }", tokenizeAndStringify(code1c, false, true, Settings::Win32A));
+
+ const char code2a[] = "void foo() { _tprintf (_T(\"test\") _T(\"1\")); }";
+ ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test1\" ) ; }", tokenizeAndStringify(code2a, false, true, Settings::Win32W));
+ ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test1\" ) ; }", tokenizeAndStringify(code2a, false, true, Settings::Win64));
+ const char code2b[] = "void foo() { _tprintf (_TEXT(\"test\") _TEXT(\"2\")); }";
+ ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test2\" ) ; }", tokenizeAndStringify(code2b, false, true, Settings::Win32W));
+ ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test2\" ) ; }", tokenizeAndStringify(code2b, false, true, Settings::Win64));
+ const char code2c[] = "void foo() { _tprintf (TEXT(\"test\") TEXT(\"3\")); }";
+ ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test3\" ) ; }", tokenizeAndStringify(code2c, false, true, Settings::Win32W));
+ ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test3\" ) ; }", tokenizeAndStringify(code2c, false, true, Settings::Win64));
+ }
+
void borland() {
// __closure
ASSERT_EQUALS("int * a ;",