From 46d36efa23a6ebd50d223b24b28ff0e3f838b78e Mon Sep 17 00:00:00 2001 From: Vincent Labrecque Date: Thu, 29 Aug 2002 22:45:23 +0000 Subject: fix a little display bug when editing a file with binary characters, columns weren't calculated correctly. ok deraadt@ --- usr.bin/mg/display.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/mg/display.c b/usr.bin/mg/display.c index bbcd940d44b..f2a8acdc010 100644 --- a/usr.bin/mg/display.c +++ b/usr.bin/mg/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.17 2002/08/22 23:28:19 deraadt Exp $ */ +/* $OpenBSD: display.c,v 1.18 2002/08/29 22:45:22 vincent Exp $ */ /* * The functions in this file handle redisplay. The @@ -486,11 +486,19 @@ update(void) #ifdef NOTAB && !(curbp->b_flag & BFNOTAB) #endif - ) + ) { curcol |= 0x07; - else if (ISCTRL(c) != FALSE) - ++curcol; - ++curcol; + curcol++; + } else if (ISCTRL(c) != FALSE) + curcol += 2; + else if (isprint(c)) + curcol++; + else { + char bf[5]; + + snprintf(bf, sizeof bf, "\\%o", c); + curcol += strlen(bf); + } } if (curcol >= ncol - 1) { /* extended line. */ /* flag we are extended and changed */ -- cgit v1.2.3