[gjs/msvc-x64] text-encoding.cpp: Fix builds on 64-bit Windows
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/msvc-x64] text-encoding.cpp: Fix builds on 64-bit Windows
- Date: Thu, 12 Aug 2021 07:20:04 +0000 (UTC)
commit b2bb490dbf79be63e74c9447fb13b74710d2c133
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 are 8-bytes, not 4-bytes. So, append the appropriate suffix depending
on the value of GLIB_SIZEOF_SIZE_T.
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..28d557b3 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 == 8
+#define SIZE_T_CONST(x) x ## llu
+#else
+#define SIZE_T_CONST(x) x ## lu
+#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]