From 15653d36ede621b282cfa3dba6b397b3f8fb84bf Mon Sep 17 00:00:00 2001 From: schwarze Date: Thu, 6 Jul 2017 19:27:37 +0000 Subject: [PATCH] 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@ --- usr.bin/mg/display.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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); } } -- 2.20.1