Bug 553032 - change sprintf_append to be a varargs function; r?evilpie
MozReview-Commit-ID: I5aECiK5Coz
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -758,21 +758,26 @@ FormatValue(JSContext* cx, const Value&
const char* found = strstr(buf, "function ");
if (found && (found - buf <= 2))
return "[function]";
return buf;
}
// Wrapper for JS_sprintf_append() that reports allocation failure to the
// context.
-template <typename... Args>
static char*
-sprintf_append(JSContext* cx, char* buf, Args&&... args)
+MOZ_FORMAT_PRINTF(3, 4)
+sprintf_append(JSContext* cx, char* buf, const char* fmt, ...)
{
- char* result = JS_sprintf_append(buf, mozilla::Forward<Args>(args)...);
+ va_list ap;
+
+ va_start(ap, fmt);
+ char* result = JS_vsprintf_append(buf, fmt, ap);
+ va_end(ap);
+
if (!result) {
ReportOutOfMemory(cx);
return nullptr;
}
return result;
}