Bug 756786 - Remove NSPR usage from nsXULRunnerApp.cpp. r=bsmedberg,a=akeybl
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 07 Jun 2012 10:41:59 +0200
changeset 96463 db2d1dd99271df6b914ab64fa0e6cd696bae69b2
parent 96462 90a5cad9b438538f2ca9cfd4ab4ed7a1977451e1
child 96464 f11c642254b244844b4cac8ce4c3eabe91203cd2
push id160
push userlsblakk@mozilla.com
push dateFri, 13 Jul 2012 18:18:57 +0000
treeherdermozilla-release@228ba1a111fc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, akeybl
bugs756786
milestone14.0
Bug 756786 - Remove NSPR usage from nsXULRunnerApp.cpp. r=bsmedberg,a=akeybl
xulrunner/app/nsXULRunnerApp.cpp
--- a/xulrunner/app/nsXULRunnerApp.cpp
+++ b/xulrunner/app/nsXULRunnerApp.cpp
@@ -70,59 +70,48 @@
  *        printf-style format string followed by arguments.
  */
 static void Output(bool isError, const char *fmt, ... )
 {
   va_list ap;
   va_start(ap, fmt);
 
 #if (defined(XP_WIN) && !MOZ_WINCONSOLE)
-  char *msg = PR_vsmprintf(fmt, ap);
-  if (msg)
-  {
-    UINT flags = MB_OK;
-    if (isError)
-      flags |= MB_ICONERROR;
-    else
-      flags |= MB_ICONINFORMATION;
+  PRUnichar msg[2048];
+  _vsnwprintf(msg, sizeof(msg)/sizeof(msg[0]), NS_ConvertUTF8toUTF16(fmt).get(), ap);
+
+  UINT flags = MB_OK;
+  if (isError)
+    flags |= MB_ICONERROR;
+  else
+    flags |= MB_ICONINFORMATION;
     
-    wchar_t wide_msg[2048];
-    MultiByteToWideChar(CP_ACP,
-			0,
-			msg,
-			-1,
-			wide_msg,
-			sizeof(wide_msg) / sizeof(wchar_t));
-    
-    MessageBoxW(NULL, wide_msg, L"XULRunner", flags);
-
-    PR_smprintf_free(msg);
-  }
+  MessageBoxW(NULL, msg, L"XULRunner", flags);
 #else
   vfprintf(stderr, fmt, ap);
 #endif
 
   va_end(ap);
 }
 
 /**
  * Return true if |arg| matches the given argument name.
  */
 static bool IsArg(const char* arg, const char* s)
 {
   if (*arg == '-')
   {
     if (*++arg == '-')
       ++arg;
-    return !PL_strcasecmp(arg, s);
+    return !strcasecmp(arg, s);
   }
 
 #if defined(XP_WIN) || defined(XP_OS2)
   if (*arg == '/')
-    return !PL_strcasecmp(++arg, s);
+    return !strcasecmp(++arg, s);
 #endif
 
   return false;
 }
 
 static nsresult
 GetGREVersion(const char *argv0,
               nsACString *aMilestone,
@@ -334,17 +323,17 @@ int main(int argc, char* argv[])
       rv = GetXULRunnerDir(argv[0], getter_AddRefs(regDir));
       if (NS_FAILED(rv))
         return 2;
 
       return InstallXULApp(regDir, appLocation, installTo, leafName);
     }
   }
 
-  const char *appDataFile = PR_GetEnv("XUL_APP_FILE");
+  const char *appDataFile = getenv("XUL_APP_FILE");
 
   if (!(appDataFile && *appDataFile)) {
     if (argc < 2) {
       Usage(argv[0]);
       return 1;
     }
 
     if (IsArg(argv[1], "app")) {
@@ -358,18 +347,18 @@ int main(int argc, char* argv[])
     }
 
     appDataFile = argv[1];
     argv[1] = argv[0];
     ++argv;
     --argc;
 
     static char kAppEnv[MAXPATHLEN];
-    PR_snprintf(kAppEnv, MAXPATHLEN, "XUL_APP_FILE=%s", appDataFile);
-    PR_SetEnv(kAppEnv);
+    snprintf(kAppEnv, MAXPATHLEN, "XUL_APP_FILE=%s", appDataFile);
+    putenv(kAppEnv);
   }
 
   nsCOMPtr<nsILocalFile> appDataLF;
   nsresult rv = XRE_GetFileFromPath(appDataFile, getter_AddRefs(appDataLF));
   if (NS_FAILED(rv)) {
     Output(true, "Error: unrecognized application.ini path.\n");
     return 2;
   }