shithub: neatroff

Download patch

ref: 79583a168cdf71c4435683fccad97630fa01e17d
parent: a52c92cde1e8dca510ae2fbaab40c585e19a1481
author: Ali Gholami Rudi <[email protected]>
date: Tue Sep 10 12:45:42 EDT 2013

char: handle multibyte characters in charnext_delim()

--- a/char.c
+++ b/char.c
@@ -99,11 +99,12 @@
 /* convert back the character read from nextchar() (e.g. xy -> \\(xy) */
 void charnext_str(char *d, char *c)
 {
-	if (c[0] == c_ec || c[0] == c_ni || !c[1] || utf8len(c[0]) == strlen(c)) {
+	int c0 = (unsigned char) c[0];
+	if (c0 == c_ec || c0 == c_ni || !c[1] || utf8len(c0) == strlen(c)) {
 		strcpy(d, c);
 		return;
 	}
-	if (!c[2] && utf8len(c[0]) == 1)
+	if (!c[2] && utf8len(c0) == 1)
 		sprintf(d, "%c(%s", c_ec, c);
 	else
 		sprintf(d, "%cC'%s'", c_ec, c);