diff options
-rw-r--r-- | base/string_util.cc | 6 | ||||
-rw-r--r-- | base/string_util.h | 3 | ||||
-rw-r--r-- | chrome/common/libxml_utils.cc | 3 |
3 files changed, 11 insertions, 1 deletions
diff --git a/base/string_util.cc b/base/string_util.cc index 9db0f03..b38e182 100644 --- a/base/string_util.cc +++ b/base/string_util.cc @@ -1245,6 +1245,12 @@ std::wstring StringPrintf(const wchar_t* format, ...) { return result; } +std::string StringPrintV(const char* format, va_list ap) { + std::string result; + StringAppendV(&result, format, ap); + return result; +} + const std::string& SStringPrintf(std::string* dst, const char* format, ...) { va_list ap; va_start(ap, format); diff --git a/base/string_util.h b/base/string_util.h index 66518e9..723242e 100644 --- a/base/string_util.h +++ b/base/string_util.h @@ -453,6 +453,9 @@ double StringToDouble(const string16& value); std::string StringPrintf(const char* format, ...) PRINTF_FORMAT(1, 2); std::wstring StringPrintf(const wchar_t* format, ...) WPRINTF_FORMAT(1, 2); +// Return a C++ string given vprintf-like input. +std::string StringPrintV(const char* format, va_list ap) PRINTF_FORMAT(1, 0); + // Store result into a supplied string and return it const std::string& SStringPrintf(std::string* dst, const char* format, ...) PRINTF_FORMAT(2, 3); diff --git a/chrome/common/libxml_utils.cc b/chrome/common/libxml_utils.cc index 8b8e39f..f06df72 100644 --- a/chrome/common/libxml_utils.cc +++ b/chrome/common/libxml_utils.cc @@ -35,7 +35,8 @@ void XmlReader::GenericErrorCallback(void* context, const char* msg, ...) { va_start(args, msg); XmlReader* reader = static_cast<XmlReader*>(context); - reader->errors_.append(StringPrintf(msg, args)); + reader->errors_.append(StringPrintV(msg, args)); + va_end(args); } bool XmlReader::Load(const std::string& input) { |