From 9fab541993c846fd5ddffedfa4a2014634b88cfc Mon Sep 17 00:00:00 2001 From: "H. S. Teoh" Date: Wed, 7 Aug 2013 13:48:02 -0700 Subject: [PATCH] Fix issue 10773. --- std/algorithm.d | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/std/algorithm.d b/std/algorithm.d index 75bb75c4e55..a492d9dbd08 100644 --- a/std/algorithm.d +++ b/std/algorithm.d @@ -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)))) {