Fix issue 10773.

This commit is contained in:
H. S. Teoh 2013-08-07 13:48:02 -07:00
parent 86514b0015
commit 9fab541993

View file

@ -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;
}
@ -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))))
{