Skip to content

Commit

Permalink
Fix issue 10773.
Browse files Browse the repository at this point in the history
  • Loading branch information
H. S. Teoh committed Aug 8, 2013
1 parent 86514b0 commit 9fab541
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion std/algorithm.d
Expand Up @@ -2432,7 +2432,8 @@ if (is(typeof(Range.init.front == Separator.init.front) : bool)
if (_frontLength != _frontLength.max) return;
assert(!_input.empty);
// compute front length
_frontLength = _input.length - find(_input, _separator).length;
_frontLength = (_separator.empty) ? 1 :
_input.length - find(_input, _separator).length;
static if (isBidirectionalRange!Range)
if (_frontLength == _input.length) _backLength = _frontLength;
}
Expand Down Expand Up @@ -2607,6 +2608,17 @@ unittest
assert(equal(sp6, ["", ""][]));
}

unittest
{
// Issue 10773
auto s = splitter("abc", "");
auto expected = ["a", "b", "c"];
foreach (e; s) {
assert(e.equal(expected.front));
expected.popFront();
}
}

auto splitter(alias isTerminator, Range)(Range input)
if (is(typeof(unaryFun!(isTerminator)(ElementType!(Range).init))))
{
Expand Down

0 comments on commit 9fab541

Please sign in to comment.