Fix a crash when exception is throws in nested Format. Check automatically assigned argument index. Add double output method to BasicWriter.

This commit is contained in:
Victor Zverovich
2013-02-27 13:17:09 -08:00
parent dcb82310eb
commit 1e58ebf1b7
2 changed files with 129 additions and 104 deletions
+9 -3
View File
@@ -485,6 +485,11 @@ class BasicWriter {
return *this << IntFormatter<unsigned, TypeSpec<0> >(value, TypeSpec<0>());
}
BasicWriter &operator<<(double value) {
FormatDouble(value, FormatSpec(), -1);
return *this;
}
BasicWriter &operator<<(Char value) {
*GrowBuffer(1) = value;
return *this;
@@ -957,7 +962,8 @@ class BasicFormatter : public BasicWriter<Char> {
// so it will be alive in the Arg's destructor where Format is called.
// Note that the string object will not necessarily be alive when
// the destructor of ArgInserter is called.
formatter->CompleteFormatting();
if (formatter)
formatter->CompleteFormatting();
}
};
@@ -1291,9 +1297,9 @@ inline const typename BasicFormatter<Char>::Arg
}
next_arg_index_ = -1;
arg_index = ParseUInt(s);
if (arg_index >= args_.size())
ReportError(s, "argument index is out of range in format");
}
if (arg_index >= args_.size())
ReportError(s, "argument index is out of range in format");
return *args_[arg_index];
}