Bug 1391685 Copy missing WideToMBCPto minidump-analyzer standalone program for gcc build draft
authorTom Ritter <tom@mozilla.com>
Tue, 29 Aug 2017 12:15:02 -0500
changeset 655099 9e21ef6ccecc8588e98c0b70a005e0607b9719a9
parent 649188 771c5fa26218b6d83fd8828180b52052fd807948
child 655101 730e9c7fb6a0e806ef6028ce4f9b8acd64de98a7
child 660117 91cd6478fa6e9e66fb9e9c9714ce1e7d25714cc3
child 663204 b32015a07babdb199b5078bdbdc6168764396f66
child 665846 145b731521a2d970673ab85e275c5bc0d798b672
push id76776
push userbmo:tom@mozilla.com
push dateTue, 29 Aug 2017 17:17:15 +0000
bugs1391685
milestone57.0a1
Bug 1391685 Copy missing WideToMBCPto minidump-analyzer standalone program for gcc build MozReview-Commit-ID: 3S5poDINhH3
toolkit/crashreporter/minidump-analyzer/minidump-analyzer.cpp
--- a/toolkit/crashreporter/minidump-analyzer/minidump-analyzer.cpp
+++ b/toolkit/crashreporter/minidump-analyzer/minidump-analyzer.cpp
@@ -51,16 +51,49 @@ using google_breakpad::Minidump;
 using google_breakpad::MinidumpProcessor;
 using google_breakpad::PathnameStripper;
 using google_breakpad::ProcessResult;
 using google_breakpad::ProcessState;
 using google_breakpad::StackFrame;
 
 #ifdef XP_WIN
 
+#if !defined(_MSC_VER)
+static string WideToMBCP(const wstring& wide,
+                         unsigned int cp,
+                         bool* success = nullptr)
+{
+  char* buffer = nullptr;
+  int buffer_size = WideCharToMultiByte(cp, 0, wide.c_str(),
+                                        -1, nullptr, 0, nullptr, nullptr);
+  if(buffer_size == 0) {
+    if (success)
+      *success = false;
+    return "";
+  }
+
+  buffer = new char[buffer_size];
+  if(buffer == nullptr) {
+    if (success)
+      *success = false;
+    return "";
+  }
+
+  WideCharToMultiByte(cp, 0, wide.c_str(),
+                      -1, buffer, buffer_size, nullptr, nullptr);
+  string mb = buffer;
+  delete [] buffer;
+
+  if (success)
+    *success = true;
+
+  return mb;
+}
+#endif /* !defined(_MSC_VER) */
+
 static wstring UTF8ToWide(const string& aUtf8Str, bool *aSuccess = nullptr)
 {
   wchar_t* buffer = nullptr;
   int buffer_size = MultiByteToWideChar(CP_UTF8, 0, aUtf8Str.c_str(),
                                         -1, nullptr, 0);
   if (buffer_size == 0) {
     if (aSuccess) {
       *aSuccess = false;