Fix bug with multi-line string literals

This commit is contained in:
Hackerpilot 2016-02-01 00:35:26 -08:00
parent 3bc810dcd4
commit fd214032a4
4 changed files with 51 additions and 1 deletions

View File

@ -1398,6 +1398,9 @@ private:
void writeToken() void writeToken()
{ {
import std.range:retro;
import std.algorithm.searching:countUntil;
if (current.text is null) if (current.text is null)
{ {
immutable s = str(current.type); immutable s = str(current.type);
@ -1412,7 +1415,18 @@ private:
output.put(current.text.replace("\r", "")); output.put(current.text.replace("\r", ""));
else else
output.put(current.text); output.put(current.text);
switch (current.type)
{
case tok!"stringLiteral":
case tok!"wstringLiteral":
case tok!"dstringLiteral":
immutable o = current.text.retro().countUntil('\n');
currentLineLength += o == -1 ? current.text.length : o;
break;
default:
currentLineLength += current.text.length; currentLineLength += current.text.length;
break;
}
} }
index++; index++;
} }

View File

@ -0,0 +1,12 @@
unittest
{
someFunctionCall(`
multi-line string
multi-line string
multi-line string
multi-line string
multi-line string
multi-line string
multi-line string
`, paramater);
}

13
tests/multiline_string.d Normal file
View File

@ -0,0 +1,13 @@
unittest
{
someFunctionCall(`
multi-line string
multi-line string
multi-line string
multi-line string
multi-line string
multi-line string
multi-line string
`,
paramater);
}

View File

@ -0,0 +1,11 @@
unittest {
someFunctionCall(`
multi-line string
multi-line string
multi-line string
multi-line string
multi-line string
multi-line string
multi-line string
`, paramater);
}