summaryrefslogtreecommitdiff
path: root/usr.bin/mg/util.c
diff options
context:
space:
mode:
authorVincent Labrecque <vincent@cvs.openbsd.org>2003-05-16 19:29:00 +0000
committerVincent Labrecque <vincent@cvs.openbsd.org>2003-05-16 19:29:00 +0000
commitf958a17870b6fd2242cc21b9809cd9a08220b94f (patch)
tree239a74769069f17698d606c72e45ce531332dd04 /usr.bin/mg/util.c
parentebe960fcfd0e900a7978568337d808f3b4b657cc (diff)
fix the goal calculation routine so moving up and down moves to the right
column. ok jason
Diffstat (limited to 'usr.bin/mg/util.c')
-rw-r--r--usr.bin/mg/util.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/usr.bin/mg/util.c b/usr.bin/mg/util.c
index c4f5fdfdc03..ee5a872d0b1 100644
--- a/usr.bin/mg/util.c
+++ b/usr.bin/mg/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.8 2002/05/30 16:07:57 vincent Exp $ */
+/* $OpenBSD: util.c,v 1.9 2003/05/16 19:28:59 vincent Exp $ */
/*
* Assorted commands.
@@ -8,6 +8,7 @@
*/
#include "def.h"
+#include <ctype.h>
/*
* Display a bunch of useful information about the current location of dot.
@@ -71,12 +72,12 @@ showcpos(f, n)
}
int
-getcolpos()
+getcolpos(void)
{
int col, i, c;
/* determine column */
- col = 1;
+ col = 0;
for (i = 0; i < curwp->w_doto; ++i) {
c = lgetc(curwp->w_dotp, i);
@@ -86,10 +87,17 @@ getcolpos()
#endif /* NOTAB */
) {
col |= 0x07;
- ++col;
+ col++;
} else if (ISCTRL(c) != FALSE)
- ++col;
- ++col;
+ col += 2;
+ else if (isprint(c))
+ col++;
+ else {
+ char tmp[5];
+ snprintf(tmp, sizeof tmp, "\\%o", c);
+ col += strlen(tmp);
+ }
+
}
return col;
}