瀏覽代碼

Do not mark as invalid UTF8 control codes

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.
Roberto E. Vargas Caballero 10 年之前
父節點
當前提交
7e61f5e4c5
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      st.c

+ 2 - 2
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