From d7a0750d3762965e0f56321a084d4fa31f51e970 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Wed, 10 Feb 2016 18:41:01 +0100 Subject: [PATCH] Fix build on Windows --- libhpcs.c | 5 ++--- libhpcs_p.h | 32 +++++++++++++++++--------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/libhpcs.c b/libhpcs.c index 1d733c2..13a353a 100644 --- a/libhpcs.c +++ b/libhpcs.c @@ -1272,8 +1272,7 @@ static enum HPCS_ParseCode __win32_latin1_to_utf8(char** target, const char *s) if (intermediate == NULL) return PARSE_E_NO_MEM; - size_t w_size = MultiByteToWideChar(28591, MB_ERR_INVALID_CHARS, s, -1, intermediate, 0); - if (w_size == 0) { + if (MultiByteToWideChar(28591, MB_ERR_INVALID_CHARS, s, -1, intermediate, 0) == 0) { PR_DEBUGF("Convert MultiByteToWideChar() error 0x%x\n", GetLastError()); return PARSE_E_INTERNAL; } @@ -1296,7 +1295,7 @@ static enum HPCS_ParseCode __win32_latin1_to_utf8(char** target, const char *s) return PARSE_E_INTERNAL; } - free(intermediate) + free(intermediate); return PARSE_OK; } diff --git a/libhpcs_p.h b/libhpcs_p.h index 3705712..1e53636 100644 --- a/libhpcs_p.h +++ b/libhpcs_p.h @@ -196,12 +196,28 @@ static void remove_trailing_newline(HPCS_NChar* s); static enum HPCS_ParseCode __read_string_at_offset_v1(FILE* datafile, const HPCS_offset offset, char** const result); static enum HPCS_ParseCode __read_string_at_offset_v2(FILE* datafile, const HPCS_offset offset, char** const result); +static char* __DEFAULT_CS_REV(); +static char* __DEFAULT_CS_VER(); + +static bool OLD_FORMAT(const enum HPCS_GenType gentype) +{ + switch (gentype) { + case GENTYPE_ADC_LC2: + return false; + default: + return true; + } +} + +#define DEFAULT_CS_REV __DEFAULT_CS_REV() +#define DEFAULT_CS_VER __DEFAULT_CS_VER() + /** Platform-specific functions */ #ifdef _WIN32 static enum HPCS_ParseCode __win32_next_native_line(FILE* fh, WCHAR* line, int32_t length); static HPCS_UFH __win32_open_data_file(const char* filename); static enum HPCS_ParseCode __win32_parse_native_method_info_line(char** name, char** value, WCHAR* line); -static enum HPCS_ParseCode __win32_latin1_to_utf8(char** target, const char *s) +static enum HPCS_ParseCode __win32_latin1_to_utf8(char** target, const char *s); static bool __win32_utf8_to_wchar(wchar_t** target, const char* s); static enum HPCS_ParseCode __win32_wchar_to_utf8(char** target, const WCHAR* s); #else @@ -213,20 +229,6 @@ static enum HPCS_ParseCode __unix_next_native_line(UFILE* fh, UChar* line, int32 static enum HPCS_ParseCode __unix_parse_native_method_info_line(char** name, char** value, UChar* line); static enum HPCS_ParseCode __unix_data_to_utf8(char** target, const char* bytes, const char* encoding, const size_t bytes_count); -static char* __DEFAULT_CS_REV(); -static char* __DEFAULT_CS_VER(); -#define DEFAULT_CS_REV __DEFAULT_CS_REV() -#define DEFAULT_CS_VER __DEFAULT_CS_VER() - -static bool OLD_FORMAT(const enum HPCS_GenType gentype) -{ - switch (gentype) { - case GENTYPE_ADC_LC2: - return false; - default: - return true; - } -} #define __ICU_INIT_STRING(dst, s) do { \ UChar temp[64]; \ -- 2.43.5