[gjs/msvc-x64] text-encoding.cpp: Fix builds on 64-bit Windows




commit a521d6728e30aded8c398147ca7cf686c2e7fc9b
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Thu Aug 12 15:15:09 2021 +0800

    text-encoding.cpp: Fix builds on 64-bit Windows
    
    The `lu` suffix for the second parameter breaks builds on 64-bit Windows since
    size_t's do not have the same size as a long.  So, append the appropriate suffix
    depending on whether GLIB_SIZEOF_SIZE_T == GLIB_SIZEOF_LONG.

 gjs/text-encoding.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gjs/text-encoding.cpp b/gjs/text-encoding.cpp
index 641f3ea7..02ab6ccd 100644
--- a/gjs/text-encoding.cpp
+++ b/gjs/text-encoding.cpp
@@ -62,6 +62,12 @@ static const char* UTF16_CODESET = "UTF-16LE";
 static const char* UTF16_CODESET = "UTF-16BE";
 #endif
 
+#if GLIB_SIZEOF_SIZE_T == GLIB_SIZEOF_LONG
+#define SIZE_T_CONST(x) x ## lu
+#else
+#define SIZE_T_CONST(x) x ## llu
+#endif
+
 GJS_JSAPI_RETURN_CONVENTION
 static JSString* gjs_lossy_decode_from_uint8array_slow(
     JSContext* cx, const uint8_t* bytes, size_t bytes_len,
@@ -101,7 +107,7 @@ static JSString* gjs_lossy_decode_from_uint8array_slow(
     // some dialectal characters are in the supplemental plane
     // Adding a padding of 12 prevents a few dialectal characters
     // from requiring a reallocation.
-    size_t buffer_size = std::max(bytes_len * 2 + 12, 256lu);
+    size_t buffer_size = std::max(bytes_len * 2 + 12, SIZE_T_CONST(256));
 
     // Cast data to correct input types
     const char* input = reinterpret_cast<const char*>(bytes);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]