Skip to content

Commit 6ee74a9

Browse files
committed
i3: Fix iconv usage
1 parent a72292d commit 6ee74a9

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

wm/i3/distinfo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SHA1 (patch-etc_config) = d3f649e8d4dc7cae7eb3c1548fa8d81224e4dacb
77
SHA1 (patch-etc_config.keycodes) = 6adde0b3a56576805facd951fa9d32bfd6c88011
88
SHA1 (patch-i3-config-wizard_main.c) = 79e7b2f63f893357b808a6ce8ee28d3a501efed2
99
SHA1 (patch-libi3_get__process__filename.c) = 7de46b0f26aa46ed6864ffd1cc5850ec6315c7a8
10+
SHA1 (patch-libi3_ucs2__conversion.c) = 1e9360f959100061853d1913baa23d932f4a63a7
1011
SHA1 (patch-meson.build) = 89ec2c7f594f8f13c13b522c7635cb59626554af
1112
SHA1 (patch-src_config.c) = 7985366b892f240379daa19d9b7baeddb22f66ee
1213
SHA1 (patch-src_log.c) = 19b33b43d1716ead4bad36e2afd52ff30af017c1
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
$NetBSD$
2+
3+
Fix iconv usage on SunOS and older NetBSD.
4+
5+
--- libi3/ucs2_conversion.c.orig 2026-02-06 07:30:55.000000000 +0000
6+
+++ libi3/ucs2_conversion.c
7+
@@ -12,6 +12,15 @@
8+
#include <stdlib.h>
9+
#include <string.h>
10+
11+
+#if defined(__NetBSD__)
12+
+#include <sys/param.h>
13+
+#if __NetBSD_Prereq__(9,99,17)
14+
+#define NETBSD_POSIX_ICONV 1
15+
+#else
16+
+#define NETBSD_POSIX_ICONV 0
17+
+#endif
18+
+#endif
19+
+
20+
static iconv_t utf8_conversion_descriptor = (iconv_t)-1;
21+
static iconv_t ucs2_conversion_descriptor = (iconv_t)-1;
22+
23+
@@ -42,8 +51,13 @@ char *convert_ucs2_to_utf8(xcb_char2b_t
24+
25+
/* Do the conversion */
26+
size_t input_len = num_glyphs * sizeof(xcb_char2b_t);
27+
+#if (defined(__NetBSD__) && !NETBSD_POSIX_ICONV) || defined(__sun)
28+
+ size_t rc = iconv(utf8_conversion_descriptor, (const char **)&text,
29+
+ &input_len, &output, &output_size);
30+
+#else
31+
size_t rc = iconv(utf8_conversion_descriptor, (char **)&text,
32+
&input_len, &output, &output_size);
33+
+#endif
34+
if (rc == (size_t)-1) {
35+
perror("Converting to UTF-8 failed");
36+
free(buffer);
37+
@@ -89,8 +103,13 @@ xcb_char2b_t *convert_utf8_to_ucs2(char
38+
}
39+
40+
/* Do the conversion */
41+
+#if (defined(__NetBSD__) && !NETBSD_POSIX_ICONV) || defined(__sun)
42+
+ size_t rc = iconv(ucs2_conversion_descriptor, (const char *)&input, &input_size,
43+
+ (char **)&output, &output_bytes_left);
44+
+#else
45+
size_t rc = iconv(ucs2_conversion_descriptor, &input, &input_size,
46+
(char **)&output, &output_bytes_left);
47+
+#endif
48+
if (rc == (size_t)-1) {
49+
/* Conversion will only be partial. */
50+
perror("Converting to UCS-2 failed");

0 commit comments

Comments
 (0)