Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/dmd/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,18 @@ bool writeMixin(const(char)[] s, ref Loc loc)

// write by line to create consistent line endings
size_t lastpos = 0;
foreach (i,c; s)
for (size_t i = 0; i < s.length; ++i)
{
// detect LF and CRLF
const c = s[i];
if (c == '\n' || (c == '\r' && i+1 < s.length && s[i+1] == '\n'))
{
ob.writestring(s[lastpos .. i]);
ob.writenl();
global.params.mixinLines++;
lastpos = i + (c == '\r' ? 2 : 1);
if (c == '\r')
++i;
lastpos = i + 1;
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/runnable/extra-files/mixin.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// https://issues.dlang.org/show_bug.cgi?id=12790
string get()
{
return
q{int x;
return "int x =\n 123;\r\n" ~
q{
int y;


Expand Down
4 changes: 3 additions & 1 deletion test/runnable/extra-files/mixin.mixin
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// expansion at runnable/extra-files/mixin.d(16)
int x;
int x =
123;

int y;


Expand Down