Bug 1388789 - make va_list nsTextFormatter private; r?froydnj
The runtime type-checking rewrite of nsTextFormatter will not support
va_list uses. So, make these functions private and fix the sole user.
MozReview-Commit-ID: IBWALVzIcHC
--- a/toolkit/components/commandlines/nsCommandLine.cpp
+++ b/toolkit/components/commandlines/nsCommandLine.cpp
@@ -478,24 +478,22 @@ nsCommandLine::Init(int32_t argc, const
appendArg(curarg);
}
mState = aState;
return NS_OK;
}
+template<typename ...T>
static void
-LogConsoleMessage(const char16_t* fmt, ...)
+LogConsoleMessage(const char16_t* fmt, T... args)
{
- va_list args;
- va_start(args, fmt);
nsString msg;
- nsTextFormatter::vssprintf(msg, fmt, args);
- va_end(args);
+ nsTextFormatter::ssprintf(msg, fmt, args...);
nsCOMPtr<nsIConsoleService> cs = do_GetService("@mozilla.org/consoleservice;1");
if (cs)
cs->LogStringMessage(msg.get());
}
nsresult
nsCommandLine::EnumerateHandlers(EnumerateHandlersCallback aCallback, void *aClosure)
--- a/xpcom/string/nsTextFormatter.h
+++ b/xpcom/string/nsTextFormatter.h
@@ -53,16 +53,18 @@ public:
const char16_t* aFmt, ...);
/*
* sprintf into an existing nsAString, overwriting any contents it already
* has. Infallible.
*/
static uint32_t ssprintf(nsAString& aOut, const char16_t* aFmt, ...);
+private:
+
/*
* va_list forms of the above.
*/
static uint32_t vsnprintf(char16_t* aOut, uint32_t aOutLen, const char16_t* aFmt,
va_list aAp);
static uint32_t vssprintf(nsAString& aOut, const char16_t* aFmt, va_list aAp);
};