summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-08 01:52:13 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-08 01:52:13 +0000
commit969f815e00942ba68f6ddd7bf4b0ce9f6da9479c (patch)
tree1d6b467f0e36248fbfa9278b98c91c087bdb05c8
parentce5ae299183322b9accc2532d17c9599bbc2f7d1 (diff)
downloadchromium_src-969f815e00942ba68f6ddd7bf4b0ce9f6da9479c.zip
chromium_src-969f815e00942ba68f6ddd7bf4b0ce9f6da9479c.tar.gz
chromium_src-969f815e00942ba68f6ddd7bf4b0ce9f6da9479c.tar.bz2
Add StringPrintV, fix libxml_utils.cc to use it
Review URL: http://codereview.chromium.org/464064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34029 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/string_util.cc6
-rw-r--r--base/string_util.h3
-rw-r--r--chrome/common/libxml_utils.cc3
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) {