From 593eaaed74f4b4543d83b0af92431921282800a3 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Sat, 23 Mar 2013 16:25:52 +0000 Subject: [PATCH 1/4] no need for ref in determineBlockHints The tightened rules for rvalues and ref parameters make this an error if it is passed a slice, as in initBlock. This commit fixes this. --- dyaml/emitter.d | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dyaml/emitter.d b/dyaml/emitter.d index 70178a2..7e9ccf8 100644 --- a/dyaml/emitter.d +++ b/dyaml/emitter.d @@ -1,4 +1,3 @@ - // Copyright Ferdinand Majerech 2011. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -1585,7 +1584,7 @@ struct ScalarWriter } ///Determine hints (indicators) for block scalar. - size_t determineBlockHints(ref char[] hints, uint bestIndent) const pure @trusted + size_t determineBlockHints(char[] hints, uint bestIndent) const pure @trusted { size_t hintsIdx = 0; if(text_.length == 0){return hintsIdx;} From da64d9e5c26168c93fe17bfb8ae443dcc192e787 Mon Sep 17 00:00:00 2001 From: John-Colvin Date: Sat, 23 Mar 2013 16:31:14 +0000 Subject: [PATCH 2/4] Fixed warning about slice assignment --- dyaml/reader.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dyaml/reader.d b/dyaml/reader.d index 22f9238..6ae638e 100644 --- a/dyaml/reader.d +++ b/dyaml/reader.d @@ -302,7 +302,7 @@ final class Reader try for(size_t c = 0; chars && !decoder_.done;) { const slice = decoder_.getDChars(chars); - buffer_[oldLength + c .. oldLength + c + slice.length] = slice; + buffer_[oldLength + c .. oldLength + c + slice.length] = slice[]; c += slice.length; chars -= slice.length; } From 36a7d7087f6e5f1ad9c5b97534a4cd3a64e8e7b6 Mon Sep 17 00:00:00 2001 From: John-Colvin Date: Sat, 23 Mar 2013 16:38:57 +0000 Subject: [PATCH 3/4] another ref parameter that wasn't needed --- dyaml/reader.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dyaml/reader.d b/dyaml/reader.d index 6ae638e..cdc6b2a 100644 --- a/dyaml/reader.d +++ b/dyaml/reader.d @@ -626,7 +626,7 @@ struct UTFBlockDecoder(size_t bufferSize_) if (bufferSize_ % 2 == 0) * * Returns: True if all the characters are printable, false otherwise. */ -bool printable(const ref dchar[] chars) pure @safe nothrow +bool printable(const dchar[] chars) pure @safe nothrow { foreach(c; chars) { From aedc2f0c7aef4a94d3f2f21cd7e19bae33246522 Mon Sep 17 00:00:00 2001 From: John-Colvin Date: Sat, 23 Mar 2013 17:01:33 +0000 Subject: [PATCH 4/4] parse can't take rvalue slices as it uses ref --- dyaml/constructor.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dyaml/constructor.d b/dyaml/constructor.d index f083045..5f13628 100644 --- a/dyaml/constructor.d +++ b/dyaml/constructor.d @@ -428,11 +428,11 @@ long constructLong(ref Node node) //Zero. if(value == "0") {result = cast(long)0;} //Binary. - else if(value.startsWith("0b")){result = sign * parse!int(value[2 .. $], 2);} + else if(value.startsWith("0b")){result = sign * to!int(value[2 .. $], 2);} //Hexadecimal. - else if(value.startsWith("0x")){result = sign * parse!int(value[2 .. $], 16);} + else if(value.startsWith("0x")){result = sign * to!int(value[2 .. $], 16);} //Octal. - else if(value[0] == '0') {result = sign * parse!int(value, 8);} + else if(value[0] == '0') {result = sign * to!int(value, 8);} //Sexagesimal. else if(value.canFind(":")) {