diff --git a/rEFIt_UEFI/cpp_foundation/XStringW.h b/rEFIt_UEFI/cpp_foundation/XStringW.h index 298e52202..057d49d89 100755 --- a/rEFIt_UEFI/cpp_foundation/XStringW.h +++ b/rEFIt_UEFI/cpp_foundation/XStringW.h @@ -88,7 +88,12 @@ public: void vSPrintf(const char* format, VA_LIST va); - void SPrintf(const char* format, ...) __attribute__ ((__format__ (__printf__, 2, 3))); +#ifndef _MSC_VER + void SPrintf(const char* format, ...) __attribute__((__format__(__printf__, 2, 3))); +#else + void SPrintf(const char* format, ...); +#endif // !__MSC_VER + const XStringW &operator =(const XStringW &aString); const XStringW &operator =(const wchar_t* S); @@ -117,8 +122,8 @@ public: int Compare(const wchar_t* S) const { return (int)StrCmp(data(), S) ; } bool Equal(const wchar_t* S) const { return Compare(S) == 0; }; - bool BeginingEqual(const wchar_t* S) const { return StrnCmp(data(), S, StrLen(S)); } - bool SubStringEqual(UINTN Pos, const wchar_t* S) const { return StrCmp(data(Pos), S); } + bool BeginingEqual(const wchar_t* S) const { return (StrnCmp(data(), S, StrLen(S)) == 0); } + bool SubStringEqual(UINTN Pos, const wchar_t* S) const { return (StrCmp(data(Pos), S) == 0); } XStringW basename() const; XStringW dirname() const; @@ -171,8 +176,13 @@ public: }; //extern const XStringW NullXStringW; +#ifndef _MSC_VER +XStringW SPrintf(const char* format, ...) __attribute__((__format__(__printf__, 1, 2))); +#else +XStringW SPrintf(const char* format, ...); +#endif // !__MSC_VER + -XStringW SPrintf(const char* format, ...) __attribute__ ((__format__ (__printf__, 1, 2))); XStringW SubString(const wchar_t *S, UINTN pos, UINTN count); XStringW CleanCtrl(const XStringW &S); diff --git a/rEFIt_UEFI/cpp_foundation/printf_lite.cpp b/rEFIt_UEFI/cpp_foundation/printf_lite.cpp index ec3bbff0e..ffeaf3f98 100644 --- a/rEFIt_UEFI/cpp_foundation/printf_lite.cpp +++ b/rEFIt_UEFI/cpp_foundation/printf_lite.cpp @@ -202,7 +202,7 @@ static void print_string(const unsigned char* s, PrintfParams* printfParams) print_char(c, printfParams); #else if ( c <= 0xFFFF) { - print_char(c, printfParams); + print_char((wchar_t)c, printfParams); } else { c -= halfBase; print_char((wchar_t)((c >> halfShift) + UNI_SUR_HIGH_START), printfParams); @@ -692,8 +692,8 @@ static void printf_handle_format_char(char c, VALIST_PARAM_TYPE valist, PrintfPa case 'c': #if PRINTF_OUTPUT_FORMAT_UNICODE == 1 && PRINTF_UTF8_SUPPORT == 1 if ( printfParams->l_modifier == 0 ) { - char c = (char)va_arg(VALIST_ACCESS(valist), int); - print_char(c, printfParams); // 'char' is promoted to 'int' when passed through '...' + char c1 = (char)va_arg(VALIST_ACCESS(valist), int); + print_char((wchar_t)c1, printfParams); // 'char' is promoted to 'int' when passed through '...' printfParams->inDirective = 0; }else #endif diff --git a/rEFIt_UEFI/cpp_foundation/utf8Conversion.cpp b/rEFIt_UEFI/cpp_foundation/utf8Conversion.cpp index b3018d562..ea8904cbf 100755 --- a/rEFIt_UEFI/cpp_foundation/utf8Conversion.cpp +++ b/rEFIt_UEFI/cpp_foundation/utf8Conversion.cpp @@ -167,7 +167,7 @@ void utf8ToWChar(wchar_t* dst, size_t dst_max_len, const char *s, size_t src_le if ( dst_len == dst_max_len ) goto exit; #else if ( c <= 0xFFFF) { - dst[dst_len++] = c; + dst[dst_len++] = (wchar_t)c; if ( dst_len == dst_max_len ) goto exit; } else { c -= halfBase; diff --git a/rEFIt_UEFI/cpp_unit_test/XStringW_test.cpp b/rEFIt_UEFI/cpp_unit_test/XStringW_test.cpp index ba12a578f..6085643e4 100644 --- a/rEFIt_UEFI/cpp_unit_test/XStringW_test.cpp +++ b/rEFIt_UEFI/cpp_unit_test/XStringW_test.cpp @@ -41,7 +41,7 @@ int XStringW_tests() if ( str2 != L"a" ) return 20; str2.SPrintf("%ls", L"ab"); // UTF16(32) string containing ascii char if ( str2 != L"ab" ) return 21; - +#pragma warning(disable : 4066) str2.SPrintf("%lc", L'Ň'); // signe UTF16(32) char. (2 bytes in total if UTF16) if ( str2 != L"Ň" ) return 22; str2.SPrintf("%s", "Ň"); // this is a UTF8 string 2 bytes long diff --git a/rEFIt_UEFI/cpp_util/operatorNewDelete.cpp b/rEFIt_UEFI/cpp_util/operatorNewDelete.cpp index de9d47d83..eabc4529a 100755 --- a/rEFIt_UEFI/cpp_util/operatorNewDelete.cpp +++ b/rEFIt_UEFI/cpp_util/operatorNewDelete.cpp @@ -20,9 +20,15 @@ void* operator new (unsigned long count) return ptr; } +#pragma warning(disable : 4577) void operator delete ( void* ptr ) noexcept { return FreePool(ptr); } +void __cdecl operator delete(void * ptr, unsigned __int64 count) +{ + return FreePool(ptr); +} +