Commit 46da4066 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen
Browse files

don't be tricked by scope blocks with colons

people write strange code ...
parent 00ac132d
...@@ -271,7 +271,7 @@ void ProWriter::putVarValues(ProFile *profile, QStringList *lines, ...@@ -271,7 +271,7 @@ void ProWriter::putVarValues(ProFile *profile, QStringList *lines,
if (scopeStart < 0) { if (scopeStart < 0) {
added = QLatin1Char('\n') + scope + QLatin1String(" {"); added = QLatin1Char('\n') + scope + QLatin1String(" {");
} else { } else {
QRegExp rx(QLatin1String("(\\s*") + scope + QLatin1String("\\s*:\\s*).*")); QRegExp rx(QLatin1String("(\\s*") + scope + QLatin1String("\\s*:\\s*)[^\\s{].*"));
if (rx.exactMatch(lines->at(scopeStart))) { if (rx.exactMatch(lines->at(scopeStart))) {
(*lines)[scopeStart].replace(0, rx.cap(1).length(), (*lines)[scopeStart].replace(0, rx.cap(1).length(),
QString(scope + QLatin1String(" {\n "))); QString(scope + QLatin1String(" {\n ")));
......
...@@ -394,6 +394,17 @@ void tst_ProFileWriter::adds_data() ...@@ -394,6 +394,17 @@ void tst_ProFileWriter::adds_data()
" foo\n" " foo\n"
"}" "}"
}, },
{
PW::AppendValues|PW::AppendOperator|PW::OneLine,
"scoped new / pseudo-oneline-scope", f_foo, "dog",
"# test file\n"
"dog: {\n"
"}",
"# test file\n"
"dog: {\n"
" SOURCES += foo\n"
"}"
},
{ {
PW::AppendValues|PW::AppendOperator|PW::MultiLine, PW::AppendValues|PW::AppendOperator|PW::MultiLine,
"scoped append", f_foo, "dog", "scoped append", f_foo, "dog",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment