]> git.armaanb.net Git - st.git/commitdiff
Do not mark as invalid UTF8 control codes
authorRoberto E. Vargas Caballero <k0ga@shike2.com>
Mon, 17 Aug 2015 09:25:38 +0000 (11:25 +0200)
committerRoberto E. Vargas Caballero <k0ga@shike2.com>
Tue, 18 Aug 2015 06:31:51 +0000 (08:31 +0200)
wcwidth() returns -1 for all the non visible characters, but it doesn't
necessarilly mean that they are incorrect. It only means that they are not
printable.

st.c

diff --git a/st.c b/st.c
index 1df4fde1cbd927be170fabfcfd9d6e48e2960eac..35a840b66ef906c50e718ecd2176c98d3dfa8964 100644 (file)
--- a/st.c
+++ b/st.c
@@ -2895,15 +2895,15 @@ tputc(Rune u)
        int width, len;
        Glyph *gp;
 
+       control = ISCONTROL(u);
        len = utf8encode(u, c);
-       if ((width = wcwidth(u)) == -1) {
+       if (!control && (width = wcwidth(u)) == -1) {
                memcpy(c, "\357\277\275", 4); /* UTF_INVALID */
                width = 1;
        }
 
        if (IS_SET(MODE_PRINT))
                tprinter(c, len);
-       control = ISCONTROL(u);
 
        /*
         * STR sequence must be checked before anything else