do not print non-printable characters - irc - Unnamed repository; edit this file 'description' to name the repository.
(HTM) git clone git://vernunftzentrum.de/irc.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit f1a2b62b2f4d47de58152a1834fa5a8b971dd6d9
(DIR) parent 734cc4f0e72259a8be86115c71dce0f112d6ff0b
(HTM) Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Wed, 4 May 2016 22:41:22 -0400
do not print non-printable characters
Diffstat:
irc.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
---
(DIR) diff --git a/irc.c b/irc.c
@@ -279,11 +279,12 @@ chdel(char *name)
static char *
pushl(char *p, char *e)
{
- int x;
+ int x, cl;
char *w;
- Rune u;
+ Rune u[2];
cchar_t cc;
+ u[1] = 0;
if ((w = memchr(p, '\n', e - p)))
e = w + 1;
w = p;
@@ -299,15 +300,18 @@ pushl(char *p, char *e)
}
if (p >= e || *p == ' ' || p - w + INDENT >= scr.x - 1) {
while (w < p) {
- w += utf8decode(w, &u, UtfSz);
- setcchar(&cc, &u, 0, 0, 0);
- wadd_wch(scr.mw, &cc);
+ w += utf8decode(w, u, UtfSz);
+ if (wcwidth(*u) > 0 || *u == '\n') {
+ setcchar(&cc, u, 0, 0, 0);
+ wadd_wch(scr.mw, &cc);
+ }
}
if (p >= e)
return e;
}
- p += utf8decode(p, &u, UtfSz);
- x += wcwidth(u);
+ p += utf8decode(p, u, UtfSz);
+ if ((cl = wcwidth(*u)) >= 0)
+ x += cl;
}
}