Bug 1060419 - make nsChromeRegistry.cpp use Printf.h, r?froydnj
MozReview-Commit-ID: AMewawTLaGl
--- a/chrome/nsChromeRegistry.cpp
+++ b/chrome/nsChromeRegistry.cpp
@@ -3,18 +3,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsChromeRegistry.h"
#include "nsChromeRegistryChrome.h"
#include "nsChromeRegistryContent.h"
-#include "prprf.h"
-
#include "nsCOMPtr.h"
#include "nsError.h"
#include "nsEscape.h"
#include "nsNetUtil.h"
#include "nsString.h"
#include "nsQueryObject.h"
#include "mozilla/dom/URL.h"
@@ -24,16 +22,17 @@
#include "nsIDOMLocation.h"
#include "nsIDOMWindowCollection.h"
#include "nsIDOMWindow.h"
#include "nsIObserverService.h"
#include "nsIPresShell.h"
#include "nsIScriptError.h"
#include "nsIWindowMediator.h"
#include "nsIPrefService.h"
+#include "mozilla/Printf.h"
#include "mozilla/StyleSheet.h"
#include "mozilla/StyleSheetInlines.h"
#ifdef ENABLE_INTL_API
#include "unicode/uloc.h"
#endif
nsChromeRegistry* nsChromeRegistry::gChromeRegistry;
@@ -50,23 +49,23 @@ nsChromeRegistry::LogMessage(const char*
{
nsCOMPtr<nsIConsoleService> console
(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
if (!console)
return;
va_list args;
va_start(args, aMsg);
- char* formatted = PR_vsmprintf(aMsg, args);
+ char* formatted = mozilla::Vsmprintf(aMsg, args);
va_end(args);
if (!formatted)
return;
console->LogStringMessage(NS_ConvertUTF8toUTF16(formatted).get());
- PR_smprintf_free(formatted);
+ mozilla::SmprintfFree(formatted);
}
void
nsChromeRegistry::LogMessageWithContext(nsIURI* aURL, uint32_t aLineNumber, uint32_t flags,
const char* aMsg, ...)
{
nsresult rv;
@@ -75,30 +74,30 @@ nsChromeRegistry::LogMessageWithContext(
nsCOMPtr<nsIScriptError> error
(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
if (!console || !error)
return;
va_list args;
va_start(args, aMsg);
- char* formatted = PR_vsmprintf(aMsg, args);
+ char* formatted = mozilla::Vsmprintf(aMsg, args);
va_end(args);
if (!formatted)
return;
nsCString spec;
if (aURL)
aURL->GetSpec(spec);
rv = error->Init(NS_ConvertUTF8toUTF16(formatted),
NS_ConvertUTF8toUTF16(spec),
EmptyString(),
aLineNumber, 0, flags, "chrome registration");
- PR_smprintf_free(formatted);
+ mozilla::SmprintfFree(formatted);
if (NS_FAILED(rv))
return;
console->LogMessage(error);
}
nsChromeRegistry::~nsChromeRegistry()
--- a/chrome/nsChromeRegistry.h
+++ b/chrome/nsChromeRegistry.h
@@ -78,19 +78,21 @@ protected:
void FlushSkinCaches();
void FlushAllCaches();
// Update the selected locale used by the chrome registry, and fire a
// notification about this change
virtual nsresult UpdateSelectedLocale() = 0;
- static void LogMessage(const char* aMsg, ...);
+ static void LogMessage(const char* aMsg, ...)
+ MOZ_FORMAT_PRINTF(1, 2);
static void LogMessageWithContext(nsIURI* aURL, uint32_t aLineNumber, uint32_t flags,
- const char* aMsg, ...);
+ const char* aMsg, ...)
+ MOZ_FORMAT_PRINTF(4, 5);
virtual nsIURI* GetBaseURIFromPackage(const nsCString& aPackage,
const nsCString& aProvider,
const nsCString& aPath) = 0;
virtual nsresult GetFlagsFromPackage(const nsCString& aPackage,
uint32_t* aFlags) = 0;
nsresult SelectLocaleFromPref(nsIPrefBranch* prefs);