From 810937df2c8a693deb26ac278c73f0147353079b Mon Sep 17 00:00:00 2001 From: dequis Date: Sat, 25 Oct 2014 23:07:38 -0300 Subject: [PATCH] Fix issues with wcwidth() returning -1 for unsupported unicode chars Unicode characters added since unicode 5.2 are not supported by the wcwidth() implementation of glibc, and as a result, they behave weirdly in st. The man page of wcwidth() specifies that -1 is returned for invalid unicode characters. This patch wraps the wcwidth() calls with abs() to ensure that a column size of 1 is used for unknown unicode characters. --- st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/st.c b/st.c index 23dd7f1..12af1ab 100644 --- a/st.c +++ b/st.c @@ -2576,7 +2576,7 @@ tputc(char *c, int len) { unicodep = ascii = *c; } else { utf8decode(c, &unicodep, UTF_SIZ); - width = wcwidth(unicodep); + width = abs(wcwidth(unicodep)); control = ISCONTROLC1(unicodep); ascii = unicodep; } @@ -3440,7 +3440,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { xp, winy + frc[i].font->ascent, (FcChar8 *)u8c, u8cblen); - xp += xw.cw * wcwidth(unicodep); + xp += xw.cw * abs(wcwidth(unicodep)); } /* -- 2.1.2