Fix remaining format errors

This commit is contained in:
John-Colvin 2012-12-11 16:06:20 +00:00
parent 397ac65baa
commit 2b1abda154
5 changed files with 14 additions and 12 deletions

View file

@ -13,6 +13,8 @@ import std.array;
import std.string; import std.string;
import std.conv; import std.conv;
alias to!string str;
///Base class for all exceptions thrown by D:YAML. ///Base class for all exceptions thrown by D:YAML.
class YAMLException : Exception class YAMLException : Exception
@ -46,8 +48,8 @@ struct Mark
string toString() const @trusted string toString() const @trusted
{ {
//Line/column numbers start at zero internally, make them start at 1. //Line/column numbers start at zero internally, make them start at 1.
string clamped(ushort v){return to!string(v + 1) ~ (v == ushort.max ? " or higher" : "");} string clamped(ushort v){return str(v + 1) ~ (v == ushort.max ? " or higher" : "");}
return format("line ", clamped(line_), ",column ", clamped(column_)); return "line " ~ str(clamped(line_)) ~ ",column " ~ str(clamped(column_));
} }
} }

View file

@ -98,7 +98,7 @@ package class YAMLContainer(T) if (!Node.allowed!T): YAMLObject
} }
else else
{ {
return format("YAMLContainer(", value_.toString(), ")"); return format("YAMLContainer(%s)", value_.toString());
} }
} }

View file

@ -319,8 +319,8 @@ final class Reader
catch(UTFException e) catch(UTFException e)
{ {
const position = stream_.position; const position = stream_.position;
throw new ReaderException(format("Unicode decoding error between bytes ", throw new ReaderException(format("Unicode decoding error between bytes %s and %s : %s",
oldPosition, " and ", position, " : ", e.msg)); oldPosition, position, e.msg));
} }
catch(ReadException e) catch(ReadException e)
{ {

View file

@ -152,7 +152,7 @@ final class Representer
* //The node is guaranteed to be MyStruct as we add representer for MyStruct. * //The node is guaranteed to be MyStruct as we add representer for MyStruct.
* auto value = node.as!MyStruct; * auto value = node.as!MyStruct;
* //Using custom scalar format, x:y:z. * //Using custom scalar format, x:y:z.
* auto scalar = format(value.x, ":", value.y, ":", value.z); * auto scalar = format("%s:%s:%s", value.x, value.y, value.z);
* //Representing as a scalar, with custom tag to specify this data type. * //Representing as a scalar, with custom tag to specify this data type.
* return representer.representScalar("!mystruct.tag", scalar); * return representer.representScalar("!mystruct.tag", scalar);
* } * }
@ -199,7 +199,7 @@ final class Representer
* ///Useful for Node.as!string . * ///Useful for Node.as!string .
* override string toString() * override string toString()
* { * {
* return format("MyClass(", x, ", ", y, ", ", z, ")"); * return format("MyClass(%s, %s, %s)", x, y, z);
* } * }
* } * }
* *
@ -209,7 +209,7 @@ final class Representer
* //The node is guaranteed to be MyClass as we add representer for MyClass. * //The node is guaranteed to be MyClass as we add representer for MyClass.
* auto value = node.as!MyClass; * auto value = node.as!MyClass;
* //Using custom scalar format, x:y:z. * //Using custom scalar format, x:y:z.
* auto scalar = format(value.x, ":", value.y, ":", value.z); * auto scalar = format("%s:%s:%s", value.x, value.y, value.z);
* //Representing as a scalar, with custom tag to specify this data type. * //Representing as a scalar, with custom tag to specify this data type.
* return representer.representScalar("!myclass.tag", scalar); * return representer.representScalar("!myclass.tag", scalar);
* } * }
@ -268,7 +268,7 @@ final class Representer
* Node representMyStruct(ref Node node, Representer representer) * Node representMyStruct(ref Node node, Representer representer)
* { * {
* auto value = node.as!MyStruct; * auto value = node.as!MyStruct;
* auto scalar = format(value.x, ":", value.y, ":", value.z); * auto scalar = format("%s:%s:%s", value.x, value.y, value.z);
* return representer.representScalar("!mystruct.tag", scalar); * return representer.representScalar("!mystruct.tag", scalar);
* } * }
* -------------------- * --------------------
@ -661,7 +661,7 @@ class MyClass
///Useful for Node.as!string . ///Useful for Node.as!string .
override string toString() @trusted override string toString() @trusted
{ {
return format("MyClass(", x, ", ", y, ", ", z, ")"); return format("MyClass(%s, %s, %s)", x, y, z);
} }
} }

View file

@ -281,8 +281,8 @@ final class Scanner
if(checkPlain()) {return fetchPlain();} if(checkPlain()) {return fetchPlain();}
throw new Error(format("While scanning for the next token, found " throw new Error(format("While scanning for the next token, found "
"character \'", c, "\', index ",to!int(c), "character \'%s\', index %s that cannot start any token"
" that cannot start any token"), reader_.mark); , c, to!int(c)), reader_.mark);
} }