Skip to content

Commit

Permalink
Fix #309: Not to include \0 in the tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-tan committed Sep 21, 2022
1 parent acba077 commit 7939f44
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion source/dyaml/scanner.d
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,10 @@ struct Scanner
// is not Strip)
else
{
reader_.sliceBuilder.write(lineBreak);
if (lineBreak != '\0')
{
reader_.sliceBuilder.write(lineBreak);
}
}
}

Expand Down Expand Up @@ -1807,3 +1810,17 @@ struct Scanner
return '\0';
}
}

// Issue 309 - https://github.com/dlang-community/D-YAML/issues/309
@safe unittest
{
enum str = q"EOS
exp: |
foobar
EOS".chomp;

auto r = new Reader(cast(ubyte[])str.dup);
auto s = Scanner(r);
auto elems = s.map!"a.value".filter!"a.length > 0".array;
assert(elems[1] == "foobar");
}

0 comments on commit 7939f44

Please sign in to comment.