summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMark Lumsden <lum@cvs.openbsd.org>2014-10-17 13:25:14 +0000
committerMark Lumsden <lum@cvs.openbsd.org>2014-10-17 13:25:14 +0000
commitde3fd5e01fd22dad1c793e4427585652d5ad0391 (patch)
treeaf8ebf2e51ffed18169d0991372afa90c7d536ef /usr.bin
parentcb04035070df4c341180b19544e22297dd319159 (diff)
If gotoeop() is called requiring more than one iteration, it behaves
oddly if it reaches the end of buffer before completing all iterations. This diff makes the kill-paragraph and forward-paragraph commands stop once they can go no further. ok florian@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/paragraph.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/usr.bin/mg/paragraph.c b/usr.bin/mg/paragraph.c
index 00920d0dff0..58db0326c7f 100644
--- a/usr.bin/mg/paragraph.c
+++ b/usr.bin/mg/paragraph.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: paragraph.c,v 1.33 2014/10/13 21:01:05 lum Exp $ */
+/* $OpenBSD: paragraph.c,v 1.34 2014/10/17 13:25:13 lum Exp $ */
/* This file is in the public domain. */
@@ -90,11 +90,15 @@ gotoeop(int f, int n)
curwp->w_dotp = lforw(curwp->w_dotp);
curwp->w_dotline++;
+
+ /* do not continue after end of buffer */
+ if (lforw(curwp->w_dotp) == curbp->b_headp) {
+ gotoeol(FFRAND, 1);
+ curwp->w_rflag |= WFMOVE;
+ return (FALSE);
+ }
}
}
- /* covers corner case of no '\n' at end of buffer */
- if (lforw(curwp->w_dotp) == curbp->b_headp)
- gotoeol(FFRAND, 1);
/* force screen update */
curwp->w_rflag |= WFMOVE;
@@ -242,13 +246,14 @@ cleanup:
int
killpara(int f, int n)
{
- int status; /* returned status of functions */
+ int status, end = FALSE; /* returned status of functions */
/* for each paragraph to delete */
while (n--) {
/* mark out the end and beginning of the para to delete */
- (void)gotoeop(FFRAND, 1);
+ if (!gotoeop(FFRAND, 1))
+ end = TRUE;
/* set the mark here */
curwp->w_markp = curwp->w_dotp;
@@ -263,6 +268,9 @@ killpara(int f, int n)
/* and delete it */
if ((status = killregion(FFRAND, 1)) != TRUE)
return (status);
+
+ if (end)
+ return (TRUE);
}
return (TRUE);
}