From c971cf439cec3d412e297199db2416523c1a889d Mon Sep 17 00:00:00 2001 From: "ted.mielczarek@gmail.com" Date: Mon, 3 Nov 2014 17:05:39 +0000 Subject: Fix Windows client compilation on mingw. A=Jacek Caban , R=ted at http://breakpad.appspot.com/548002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1399 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/client/windows/common/auto_critical_section.h | 2 +- src/client/windows/common/ipc_protocol.h | 4 ++-- src/client/windows/crash_generation/client_info.h | 4 ++-- src/client/windows/crash_generation/minidump_generator.cc | 9 +++++++-- src/client/windows/crash_generation/minidump_generator.h | 1 + src/client/windows/handler/exception_handler.cc | 2 +- src/client/windows/handler/exception_handler.h | 4 ++-- src/common/windows/guid_string.h | 2 +- src/common/windows/http_upload.cc | 14 ++++++++------ src/common/windows/http_upload.h | 13 +++++++++---- src/common/windows/string_utils.cc | 8 ++++---- src/google_breakpad/common/breakpad_types.h | 2 +- src/tools/windows/converter/ms_symbol_server_converter.cc | 4 ++-- src/tools/windows/converter/ms_symbol_server_converter.h | 2 +- src/tools/windows/symupload/symupload.cc | 6 +++--- 15 files changed, 45 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/client/windows/common/auto_critical_section.h b/src/client/windows/common/auto_critical_section.h index 40287427..3fd4b9b7 100644 --- a/src/client/windows/common/auto_critical_section.h +++ b/src/client/windows/common/auto_critical_section.h @@ -30,7 +30,7 @@ #ifndef CLIENT_WINDOWS_COMMON_AUTO_CRITICAL_SECTION_H__ #define CLIENT_WINDOWS_COMMON_AUTO_CRITICAL_SECTION_H__ -#include +#include namespace google_breakpad { diff --git a/src/client/windows/common/ipc_protocol.h b/src/client/windows/common/ipc_protocol.h index b03c032b..c7486819 100644 --- a/src/client/windows/common/ipc_protocol.h +++ b/src/client/windows/common/ipc_protocol.h @@ -30,8 +30,8 @@ #ifndef CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__ #define CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__ -#include -#include +#include +#include #include #include #include "common/windows/string_utils-inl.h" diff --git a/src/client/windows/crash_generation/client_info.h b/src/client/windows/crash_generation/client_info.h index 9f94bec8..6a8fba31 100644 --- a/src/client/windows/crash_generation/client_info.h +++ b/src/client/windows/crash_generation/client_info.h @@ -30,8 +30,8 @@ #ifndef CLIENT_WINDOWS_CRASH_GENERATION_CLIENT_INFO_H__ #define CLIENT_WINDOWS_CRASH_GENERATION_CLIENT_INFO_H__ -#include -#include +#include +#include #include "client/windows/common/ipc_protocol.h" #include "common/scoped_ptr.h" #include "google_breakpad/common/minidump_format.h" diff --git a/src/client/windows/crash_generation/minidump_generator.cc b/src/client/windows/crash_generation/minidump_generator.cc index 22e8d365..c3e91681 100644 --- a/src/client/windows/crash_generation/minidump_generator.cc +++ b/src/client/windows/crash_generation/minidump_generator.cc @@ -176,9 +176,14 @@ bool HandleTraceData::CollectHandleData( stream_data->Reserved = 0; std::copy(operations_.begin(), operations_.end(), +#ifdef _MSC_VER stdext::checked_array_iterator( reinterpret_cast(stream_data + 1), - operations_.size())); + operations_.size()) +#else + reinterpret_cast(stream_data + 1) +#endif + ); return true; } @@ -350,7 +355,7 @@ bool MinidumpGenerator::WriteMinidump() { user_streams.UserStreamArray = user_stream_array.get(); MDRawAssertionInfo* actual_assert_info = assert_info_; - MDRawAssertionInfo client_assert_info = {0}; + MDRawAssertionInfo client_assert_info = {{0}}; if (assert_info_) { // If the assertion info object lives in the client process, diff --git a/src/client/windows/crash_generation/minidump_generator.h b/src/client/windows/crash_generation/minidump_generator.h index b95e04eb..a3c12305 100644 --- a/src/client/windows/crash_generation/minidump_generator.h +++ b/src/client/windows/crash_generation/minidump_generator.h @@ -34,6 +34,7 @@ #include #include #include +#include #include "google_breakpad/common/minidump_format.h" namespace google_breakpad { diff --git a/src/client/windows/handler/exception_handler.cc b/src/client/windows/handler/exception_handler.cc index 3a2f824c..b4ebbdac 100644 --- a/src/client/windows/handler/exception_handler.cc +++ b/src/client/windows/handler/exception_handler.cc @@ -27,7 +27,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include +#include #include #include diff --git a/src/client/windows/handler/exception_handler.h b/src/client/windows/handler/exception_handler.h index 539c6662..3c935089 100644 --- a/src/client/windows/handler/exception_handler.h +++ b/src/client/windows/handler/exception_handler.h @@ -57,8 +57,8 @@ #define CLIENT_WINDOWS_HANDLER_EXCEPTION_HANDLER_H__ #include -#include -#include +#include +#include #include #pragma warning(push) diff --git a/src/common/windows/guid_string.h b/src/common/windows/guid_string.h index 6b92675b..48a5c1d3 100644 --- a/src/common/windows/guid_string.h +++ b/src/common/windows/guid_string.h @@ -32,7 +32,7 @@ #ifndef COMMON_WINDOWS_GUID_STRING_H_ #define COMMON_WINDOWS_GUID_STRING_H_ -#include +#include #include diff --git a/src/common/windows/http_upload.cc b/src/common/windows/http_upload.cc index 838185b7..ba04d7d0 100644 --- a/src/common/windows/http_upload.cc +++ b/src/common/windows/http_upload.cc @@ -327,11 +327,13 @@ bool HTTPUpload::GetFileContents(const wstring &filename, // wchar_t* filename, so use _wfopen directly in that case. For VC8 and // later, _wfopen has been deprecated in favor of _wfopen_s, which does // not exist in earlier versions, so let the ifstream open the file itself. -#if _MSC_VER >= 1400 // MSVC 2005/8 + // GCC doesn't support wide file name and opening on FILE* requires ugly + // hacks, so fallback to multi byte file. +#ifdef _MSC_VER ifstream file; file.open(filename.c_str(), ios::binary); -#else // _MSC_VER >= 1400 - ifstream file(_wfopen(filename.c_str(), L"rb")); +#else // GCC + ifstream file(WideToMBCP(filename, CP_ACP).c_str(), ios::binary); #endif // _MSC_VER >= 1400 if (file.is_open()) { file.seekg(0, ios::end); @@ -375,13 +377,13 @@ wstring HTTPUpload::UTF8ToWide(const string &utf8) { } // static -string HTTPUpload::WideToUTF8(const wstring &wide) { +string HTTPUpload::WideToMBCP(const wstring &wide, unsigned int cp) { if (wide.length() == 0) { return string(); } // compute the length of the buffer we'll need - int charcount = WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1, + int charcount = WideCharToMultiByte(cp, 0, wide.c_str(), -1, NULL, 0, NULL, NULL); if (charcount == 0) { return string(); @@ -389,7 +391,7 @@ string HTTPUpload::WideToUTF8(const wstring &wide) { // convert char *buf = new char[charcount]; - WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1, buf, charcount, + WideCharToMultiByte(cp, 0, wide.c_str(), -1, buf, charcount, NULL, NULL); string result(buf); diff --git a/src/common/windows/http_upload.h b/src/common/windows/http_upload.h index 0594cde3..e485b70e 100644 --- a/src/common/windows/http_upload.h +++ b/src/common/windows/http_upload.h @@ -38,8 +38,8 @@ // Disable exception handler warnings. #pragma warning(disable : 4530) -#include -#include +#include +#include #include #include @@ -80,7 +80,7 @@ class HTTPUpload { // this merely checks (via the return value) that we were successfully // able to retrieve exactly as many bytes of content in the response as // were specified in the Content-Length header. - static bool HTTPUpload::ReadResponse(HINTERNET request, wstring* response); + static bool ReadResponse(HINTERNET request, wstring* response); // Generates a new multipart boundary for a POST request static wstring GenerateMultipartBoundary(); @@ -104,7 +104,12 @@ class HTTPUpload { static wstring UTF8ToWide(const string &utf8); // Converts a UTF16 string to UTF8. - static string WideToUTF8(const wstring &wide); + static string WideToUTF8(const wstring &wide) { + return WideToMBCP(wide, CP_UTF8); + } + + // Converts a UTF16 string to specified code page. + static string WideToMBCP(const wstring &wide, unsigned int cp); // Checks that the given list of parameters has only printable // ASCII characters in the parameter name, and does not contain diff --git a/src/common/windows/string_utils.cc b/src/common/windows/string_utils.cc index e6ffa082..27280003 100644 --- a/src/common/windows/string_utils.cc +++ b/src/common/windows/string_utils.cc @@ -58,7 +58,7 @@ bool WindowsStringUtils::safe_mbstowcs(const string &mbs, wstring *wcs) { } assert(wcs_length > 0); #else // _MSC_VER >= 1400 - if ((wcs_length = mbstowcs(NULL, mbs.c_str(), mbs.length())) < 0) { + if ((wcs_length = mbstowcs(NULL, mbs.c_str(), mbs.length())) == (size_t)-1) { return false; } @@ -75,7 +75,7 @@ bool WindowsStringUtils::safe_mbstowcs(const string &mbs, wstring *wcs) { return false; } #else // _MSC_VER >= 1400 - if (mbstowcs(&wcs_v[0], mbs.c_str(), mbs.length()) < 0) { + if (mbstowcs(&wcs_v[0], mbs.c_str(), mbs.length()) == (size_t)-1) { return false; } @@ -101,7 +101,7 @@ bool WindowsStringUtils::safe_wcstombs(const wstring &wcs, string *mbs) { } assert(mbs_length > 0); #else // _MSC_VER >= 1400 - if ((mbs_length = wcstombs(NULL, wcs.c_str(), wcs.length())) < 0) { + if ((mbs_length = wcstombs(NULL, wcs.c_str(), wcs.length())) == (size_t)-1) { return false; } @@ -118,7 +118,7 @@ bool WindowsStringUtils::safe_wcstombs(const wstring &wcs, string *mbs) { return false; } #else // _MSC_VER >= 1400 - if (wcstombs(&mbs_v[0], wcs.c_str(), wcs.length()) < 0) { + if (wcstombs(&mbs_v[0], wcs.c_str(), wcs.length()) == (size_t)-1) { return false; } diff --git a/src/google_breakpad/common/breakpad_types.h b/src/google_breakpad/common/breakpad_types.h index a60c5f35..e92436ff 100644 --- a/src/google_breakpad/common/breakpad_types.h +++ b/src/google_breakpad/common/breakpad_types.h @@ -58,7 +58,7 @@ */ #include BREAKPAD_CUSTOM_STDINT_H #else -#include +#include typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; diff --git a/src/tools/windows/converter/ms_symbol_server_converter.cc b/src/tools/windows/converter/ms_symbol_server_converter.cc index fad35faf..dd3f770f 100644 --- a/src/tools/windows/converter/ms_symbol_server_converter.cc +++ b/src/tools/windows/converter/ms_symbol_server_converter.cc @@ -34,8 +34,8 @@ // // Author: Mark Mentovai -#include -#include +#include +#include #include #include diff --git a/src/tools/windows/converter/ms_symbol_server_converter.h b/src/tools/windows/converter/ms_symbol_server_converter.h index 3db84f47..d601b433 100644 --- a/src/tools/windows/converter/ms_symbol_server_converter.h +++ b/src/tools/windows/converter/ms_symbol_server_converter.h @@ -65,7 +65,7 @@ #ifndef TOOLS_WINDOWS_MS_SYMBOL_SERVER_CONVERTER_H_ #define TOOLS_WINDOWS_MS_SYMBOL_SERVER_CONVERTER_H_ -#include +#include #include #include diff --git a/src/tools/windows/symupload/symupload.cc b/src/tools/windows/symupload/symupload.cc index e0d78f4f..eafd9b47 100644 --- a/src/tools/windows/symupload/symupload.cc +++ b/src/tools/windows/symupload/symupload.cc @@ -42,9 +42,9 @@ // cpu: the CPU that the module was built for, typically "x86". // symbol_file: the contents of the breakpad-format symbol file -#include -#include -#include +#include +#include +#include #include #include -- cgit v1.2.1