Backing out
bug 492225 on suspicion of causing Windows leak test fatal assertion.
--- a/toolkit/xre/nsWindowsWMain.cpp
+++ b/toolkit/xre/nsWindowsWMain.cpp
@@ -1,16 +1,18 @@
// This file is a .cpp file meant to be included in nsBrowserApp.cpp and other
// similar bootstrap code. It converts wide-character windows wmain into UTF-8
// narrow-character strings.
#ifndef XP_WIN
#error This file only makes sense on Windows.
#endif
+#include "nsUTF8Utils.h"
+
#ifdef __MINGW32__
/* MingW currently does not implement a wide version of the
startup routines. Workaround is to implement something like
it ourselves. See bug 411826 */
#include <shellapi.h>
@@ -25,31 +27,32 @@ int main(int argc, char **argv)
return 127;
int result = wmain(argcw, argvw);
LocalFree(argvw);
return result;
}
#endif /* __MINGW32__ */
-#include <windows.h>
#define main NS_internal_main
int main(int argc, char **argv);
static char*
AllocConvertUTF16toUTF8(const WCHAR *arg)
{
// be generous... UTF16 units can expand up to 3 UTF8 units
int len = wcslen(arg);
char *s = new char[len * 3 + 1];
if (!s)
return NULL;
- WideCharToMultiByte(CP_UTF8, 0, arg, len, s, len * 3 + 1, 0, 0);
+ ConvertUTF16toUTF8 convert(s);
+ convert.write(arg, len);
+ convert.write_terminator();
return s;
}
static void
FreeAllocStrings(int argc, char **argv)
{
while (argc) {
--argc;