minetest: Fix build on NetBSD 9.

This commit is contained in:
nia 2023-08-28 07:01:28 +00:00
parent 1674b2e152
commit 2205ce73d5
2 changed files with 36 additions and 1 deletions

View file

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.9 2023/08/13 19:07:10 pin Exp $
$NetBSD: distinfo,v 1.10 2023/08/28 07:01:28 nia Exp $
BLAKE2s (minetest-5.7.0/irrlicht.tar.gz) = e68f98b5b1e24e21919eab7fed281cac3a5b935c6b4c93db7cdcd428ddc7f15a
SHA512 (minetest-5.7.0/irrlicht.tar.gz) = 216221b5073d2b234b2d19658b30517c3abb2677c16e3a9b7fd31c15431bd2ffc047a68851c5bebf94aeb178d6b761a80c2f5744a7498cdac1d7b65fed139cc0
@ -11,3 +11,4 @@ SHA512 (minetest-5.7.0/minetest.tar.gz) = 6a934db5fd2c7c14fcfa87fb306662fa1ccf20
Size (minetest-5.7.0/minetest.tar.gz) = 10115973 bytes
SHA1 (patch-lib_irrlichtmt_source_Irrlicht_CIrrDeviceLinux.cpp) = 22099c0803dcdb74055d69bb810e54b9832f2d3e
SHA1 (patch-lib_irrlichtmt_source_Irrlicht_os.cpp) = c7f2c8529874f76029641f0281d7cda0f3797971
SHA1 (patch-src_util_string.cpp) = f240efd440fa540c1f767735892b9177089a8f30

View file

@ -0,0 +1,34 @@
$NetBSD: patch-src_util_string.cpp,v 1.6 2023/08/28 07:01:29 nia Exp $
Support non-POSIX iconv on NetBSD before 10 and SunOS.
--- src/util/string.cpp.orig 2023-04-08 16:04:52.000000000 +0000
+++ src/util/string.cpp
@@ -39,6 +39,15 @@ with this program; if not, write to the
#include <windows.h>
#endif
+#if defined(__NetBSD__)
+#include <sys/param.h>
+#if __NetBSD_Prereq__(9,99,17)
+#define NETBSD_POSIX_ICONV 1
+#else
+#define NETBSD_POSIX_ICONV 0
+#endif
+#endif
+
#ifndef _WIN32
static bool convert(const char *to, const char *from, char *outbuf,
@@ -54,7 +63,11 @@ static bool convert(const char *to, cons
const size_t old_outbuf_size = *outbuf_size;
size_t old_size = inbuf_size;
while (inbuf_size > 0) {
+#if (defined(__NetBSD__) && !NETBSD_POSIX_ICONV) || defined(__sun)
+ iconv(cd, (const char **)&inbuf_ptr, inbuf_left_ptr, &outbuf_ptr, outbuf_size);
+#else
iconv(cd, &inbuf_ptr, inbuf_left_ptr, &outbuf_ptr, outbuf_size);
+#endif
if (inbuf_size == old_size) {
iconv_close(cd);
return false;