commit bb8193242220ad28d191244e1dd6f6ae862b0cdf parent 5efb6836a8c8d8b6a93f320556391bd93ceabf7d Author: Benno Schulenberg <bensberg@telfort.nl> Date: Tue, 20 Apr 2021 11:10:52 +0200 chars: work around the wrong private-use-character widths on OpenBSD This fixes https://savannah.gnu.org/bugs/?60393. Diffstat:
M | src/chars.c | | | 11 | ++++++++++- |
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/chars.c b/src/chars.c @@ -250,6 +250,12 @@ bool is_zerowidth(const char *ch) if (mbtowide(&wc, ch) < 0) return FALSE; +#if defined(__OpenBSD__) + /* Work around an OpenBSD bug -- see https://sv.gnu.org/bugs/?60393. */ + if (wc >= 0xF0000) + return FALSE; +#endif + return (wcwidth(wc) == 0); } #endif /* ENABLE_UTF8 */ @@ -337,8 +343,11 @@ int advance_over(const char *string, size_t *column) int width = wcwidth(wc); +#if defined(__OpenBSD__) + *column += (width < 0 || wc >= 0xF0000) ? 1 : width; +#else *column += (width < 0) ? 1 : width; - +#endif return charlen; } }