summaryrefslogtreecommitdiff
path: root/usr.bin/vi
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2006-05-21 19:21:31 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2006-05-21 19:21:31 +0000
commit95fb9f8dbf17b99e4dc7025fe42e5888cb3a9fbc (patch)
tree7bc4b48d3ac128444d7d1e36bbfa07bb0de6a463 /usr.bin/vi
parent384b29cdc5436d7aedcb40e6c6da052ad9b08c70 (diff)
Backport fix from nvi 1.81.5: do not go into loop if :set number and
:set leftright and the cursor moves to an empty line; PR 3154; ok beck@
Diffstat (limited to 'usr.bin/vi')
-rw-r--r--usr.bin/vi/vi/vs_relative.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.bin/vi/vi/vs_relative.c b/usr.bin/vi/vi/vs_relative.c
index f92976d1669..40072a3f88a 100644
--- a/usr.bin/vi/vi/vs_relative.c
+++ b/usr.bin/vi/vi/vs_relative.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vs_relative.c,v 1.4 2006/01/08 21:05:40 miod Exp $ */
+/* $OpenBSD: vs_relative.c,v 1.5 2006/05/21 19:21:30 otto Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -113,6 +113,15 @@ vs_columns(sp, lp, lno, cnop, diffp)
int ch, leftright, listset;
char *p;
+ /*
+ * Initialize the screen offset.
+ */
+ scno = 0;
+
+ /* Leading number if O_NUMBER option set. */
+ if (O_ISSET(sp, O_NUMBER))
+ scno += O_NUMBER_LENGTH;
+
/* Need the line to go any further. */
if (lp == NULL) {
(void)db_get(sp, lno, 0, &lp, &len);
@@ -124,7 +133,7 @@ vs_columns(sp, lp, lno, cnop, diffp)
if (lp == NULL) {
done: if (diffp != NULL) /* XXX */
*diffp = 0;
- return (0);
+ return (scno);
}
/* Store away the values of the list and leftright edit options. */
@@ -136,7 +145,7 @@ done: if (diffp != NULL) /* XXX */
* offsets.
*/
p = lp;
- curoff = scno = 0;
+ curoff = 0;
/* Leading number if O_NUMBER option set. */
if (O_ISSET(sp, O_NUMBER))