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.conv;
alias to!string str;
///Base class for all exceptions thrown by D:YAML.
class YAMLException : Exception
@ -46,8 +48,8 @@ struct Mark
string toString() const @trusted
{
//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" : "");}
return format("line ", clamped(line_), ",column ", clamped(column_));
string clamped(ushort v){return str(v + 1) ~ (v == ushort.max ? " or higher" : "");}
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
{
return format("YAMLContainer(", value_.toString(), ")");
return format("YAMLContainer(%s)", value_.toString());
}
}

View file

@ -319,8 +319,8 @@ final class Reader
catch(UTFException e)
{
const position = stream_.position;
throw new ReaderException(format("Unicode decoding error between bytes ",
oldPosition, " and ", position, " : ", e.msg));
throw new ReaderException(format("Unicode decoding error between bytes %s and %s : %s",
oldPosition, position, e.msg));
}
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.
* auto value = node.as!MyStruct;
* //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.
* return representer.representScalar("!mystruct.tag", scalar);
* }
@ -199,7 +199,7 @@ final class Representer
* ///Useful for Node.as!string .
* 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.
* auto value = node.as!MyClass;
* //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.
* return representer.representScalar("!myclass.tag", scalar);
* }
@ -268,7 +268,7 @@ final class Representer
* Node representMyStruct(ref Node node, Representer representer)
* {
* 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);
* }
* --------------------
@ -661,7 +661,7 @@ class MyClass
///Useful for Node.as!string .
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();}
throw new Error(format("While scanning for the next token, found "
"character \'", c, "\', index ",to!int(c),
" that cannot start any token"), reader_.mark);
"character \'%s\', index %s that cannot start any token"
, c, to!int(c)), reader_.mark);
}