Skip to content

Commit

Permalink
Merge pull request #76 from schveiguy/fix75
Browse files Browse the repository at this point in the history
Fix #75. Handles cases where a line ends before seeing a break character
  • Loading branch information
s-ludwig authored Mar 5, 2020
2 parents 7dd4bad + c55d7bc commit f40e6db
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion source/diet/parser.d
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ private string parseIdent(in ref string str, ref size_t start,
/* We could have consumed the complete string and still have elements
on the stack or have ended non breakChars character.
*/
if(stack.length == 0) {
if(i < str.length && stack.length == 0) {
foreach(char it; breakChars) {
if(str[i] == it) {
size_t startC = start;
Expand All @@ -714,6 +714,14 @@ private string parseIdent(in ref string str, ref size_t start,
assert(false);
}

unittest { // issue #75
string foo = "(failure";
Location loc;
size_t pos = 1;
import std.exception : assertThrown;
assertThrown!(DietParserException)(parseIdent(foo, pos, ")", loc));
}

private Node[] parseDietWithExtensions(FileInfo[] files, size_t file_index, ref BlockInfo[] blocks, size_t[] import_stack)
{
import std.algorithm : all, any, canFind, countUntil, filter, find, map;
Expand Down

0 comments on commit f40e6db

Please sign in to comment.