summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2018-12-05 15:03:30 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2018-12-06 11:39:19 +0000
commit83c3b2cad0d9387d4918dae970693bda7aa54966 (patch)
tree66caad3553ccfbe2b487715c6405a8bf1c9fe0c2
parenta78974f95b1e4851728b8f6a47715022f11f9059 (diff)
Fix handling of a double backslash at the end of line
The double backslash at EOL shall not be altered. Task-number: QTCREATORBUG-20550 Change-Id: Ib4cc73da7a6634233d222945f01dd7974d112971 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r--src/jomlib/makefilelinereader.cpp4
-rw-r--r--tests/makefiles/macrotest.mk1
-rw-r--r--tests/tests.cpp1
3 files changed, 6 insertions, 0 deletions
diff --git a/src/jomlib/makefilelinereader.cpp b/src/jomlib/makefilelinereader.cpp
index 60a1cbf..ee20d86 100644
--- a/src/jomlib/makefilelinereader.cpp
+++ b/src/jomlib/makefilelinereader.cpp
@@ -139,6 +139,8 @@ MakefileLine MakefileLineReader::readLine_impl_local8bit()
if (bufLength >= 3 && buf[bufLength - 3] == '^') {
buf[bufLength - 3] = '\\'; // replace "^\\\n" -> "\\\\\n"
bufLength -= 2; // remove "\\\n"
+ } else if (bufLength >= 3 && buf[bufLength - 3] == '\\') {
+ bufLength--; // remove trailing \n
} else {
bufLength -= 2; // remove "\\\n"
line.continuation = LineContinuationType::Backslash;
@@ -172,6 +174,8 @@ MakefileLine MakefileLineReader::readLine_impl_unicode()
if (str.endsWith(QLatin1String("^\\"))) {
str.remove(str.length() - 2, 1);
+ } else if (str.endsWith(QLatin1String("\\\\"))) {
+ // Do nothing. Double backslash at the end is not altered.
} else if (str.endsWith(QLatin1Char('\\'))) {
str.chop(1);
line.continuation = LineContinuationType::Backslash;
diff --git a/tests/makefiles/macrotest.mk b/tests/makefiles/macrotest.mk
index 18db82d..eabeacb 100644
--- a/tests/makefiles/macrotest.mk
+++ b/tests/makefiles/macrotest.mk
@@ -17,6 +17,7 @@ Literal4 = backslash at the end^\
!UNDEF ThisIsNotDefined
Literal5 = backslash at the end\#
Literal6 = backslash at the end\ # errm i don't have anything to say...
+Literal7 = double backslash at the end\\
SplitOverLines= \
one \
two\
diff --git a/tests/tests.cpp b/tests/tests.cpp
index 0d8ee79..03541dc 100644
--- a/tests/tests.cpp
+++ b/tests/tests.cpp
@@ -127,6 +127,7 @@ void Tests::macros()
QCOMPARE(macroTable.macroValue("Literal4"), QLatin1String("backslash at the end\\"));
QCOMPARE(macroTable.macroValue("Literal5"), QLatin1String("backslash at the end\\"));
QCOMPARE(macroTable.macroValue("Literal6"), QLatin1String("backslash at the end\\"));
+ QCOMPARE(macroTable.macroValue("Literal7"), QLatin1String("double backslash at the end\\\\"));
QCOMPARE(macroTable.macroValue("SplitOverLines"), QLatin1String("one two three"));
QCOMPARE(macroTable.macroValue("Incremental"), QLatin1String("one two"));
QCOMPARE(macroTable.expandMacros(macroTable.macroValue("LateDefinition")),