summaryrefslogtreecommitdiff
path: root/usr.bin/mg/display.c
diff options
context:
space:
mode:
authorVincent Labrecque <vincent@cvs.openbsd.org>2002-08-29 22:45:23 +0000
committerVincent Labrecque <vincent@cvs.openbsd.org>2002-08-29 22:45:23 +0000
commit46d36efa23a6ebd50d223b24b28ff0e3f838b78e (patch)
tree53e0e17dff2f91d876602f2958b874f994d647cf /usr.bin/mg/display.c
parent578c3ed1fa8e06e1974de6ce71962a8b2e96ad8b (diff)
fix a little display bug when editing a file with binary characters, columns
weren't calculated correctly. ok deraadt@
Diffstat (limited to 'usr.bin/mg/display.c')
-rw-r--r--usr.bin/mg/display.c18
1 files changed, 13 insertions, 5 deletions
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 */