From: schwarze Date: Thu, 6 Jul 2017 19:27:37 +0000 (+0000) Subject: Fix display of overlong lines containing non-ASCII bytes. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=15653d36ede621b282cfa3dba6b397b3f8fb84bf;p=openbsd Fix display of overlong lines containing non-ASCII bytes. Also fixes a crash reported by Hiltjo Posthuma , though in a different way than with the patch he sent. OK florian@ bcallah@ --- diff --git a/usr.bin/mg/display.c b/usr.bin/mg/display.c index 7af723ce268..c26f0935184 100644 --- a/usr.bin/mg/display.c +++ b/usr.bin/mg/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.47 2015/04/03 22:10:29 bcallah Exp $ */ +/* $OpenBSD: display.c,v 1.48 2017/07/06 19:27:37 schwarze Exp $ */ /* This file is in the public domain. */ @@ -366,10 +366,16 @@ vtpute(int c) } else if (ISCTRL(c) != FALSE) { vtpute('^'); vtpute(CCHR(c)); - } else { + } else if (isprint(c)) { if (vtcol >= 0) vp->v_text[vtcol] = c; ++vtcol; + } else { + char bf[5], *cp; + + snprintf(bf, sizeof(bf), "\\%o", c); + for (cp = bf; *cp != '\0'; cp++) + vtpute(*cp); } }