AbstractMacroExpander: Allow escaping of %{Macros}

Use "%{}" to put a literal "%" into the output of the macro expander.
E.g. "%{}{Macro}" will be turned into "%{Macro}"

Change-Id: I592789e5cd8f2d52df424db679baf7ba04723202
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
Tobias Hunger
2014-07-14 18:05:38 +02:00
parent 4114297992
commit 0ed377466c
2 changed files with 15 additions and 0 deletions

View File

@@ -42,6 +42,10 @@ public:
*ret = QLatin1String("hi");
return true;
}
if (name == QLatin1String("foo")) {
*ret = QLatin1String("a");
return true;
}
return false;
}
};
@@ -102,11 +106,17 @@ void tst_StringUtils::testMacroExpander_data()
} vals[] = {
{ "text", "text" },
{ "%{a}", "hi" },
{ "%%{a}", "%hi" },
{ "%%%{a}", "%%hi" },
{ "%{b}", "%{b}" },
{ "pre%{a}", "prehi" },
{ "%{a}post", "hipost" },
{ "pre%{a}post", "prehipost" },
{ "%{a}%{a}", "hihi" },
{ "%{a}text%{a}", "hitexthi" },
{ "%{foo}%{a}text%{a}", "ahitexthi" },
{ "%{}{a}", "%{a}" },
{ "%{abc", "%{abc" }
};
for (unsigned i = 0; i < sizeof(vals)/sizeof(vals[0]); i++)