scanBlockScalarIndentation now scans into caller's slice.

This commit is contained in:
Ferdinand Majerech 2014-07-25 23:45:47 +02:00
parent 45468bff68
commit 537c3c06f3

View file

@ -1169,10 +1169,11 @@ final class Scanner
uint indent = max(1, indent_ + 1); uint indent = max(1, indent_ + 1);
if(increment == int.min) if(increment == int.min)
{ {
auto indentation = scanBlockScalarIndentation(); reader_.sliceBuilder.begin();
breaks = indentation[0]; auto indentation = scanBlockScalarIndentationToSlice();
endMark = indentation[2]; breaks = reader_.sliceBuilder.finish();
indent = max(indent, indentation[1]); endMark = indentation[1];
indent = max(indent, indentation[0]);
} }
else else
{ {
@ -1333,10 +1334,12 @@ final class Scanner
} }
/// Scan indentation in a block scalar, returning line breaks, max indent and end mark. /// Scan indentation in a block scalar, returning line breaks, max indent and end mark.
Tuple!(dstring, uint, Mark) scanBlockScalarIndentation() ///
/// Assumes that the caller is building a slice in Reader, and puts the scanned
/// characters into that slice.
Tuple!(uint, Mark) scanBlockScalarIndentationToSlice()
@system pure nothrow @nogc @system pure nothrow @nogc
{ {
reader_.sliceBuilder.begin();
uint maxIndent; uint maxIndent;
Mark endMark = reader_.mark; Mark endMark = reader_.mark;
@ -1352,7 +1355,7 @@ final class Scanner
maxIndent = max(reader_.column, maxIndent); maxIndent = max(reader_.column, maxIndent);
} }
return tuple(reader_.sliceBuilder.finish(), maxIndent, endMark); return tuple(maxIndent, endMark);
} }
/// Scan line breaks at lower or specified indentation in a block scalar. /// Scan line breaks at lower or specified indentation in a block scalar.