summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjell Wooding <kjell@cvs.openbsd.org>2009-06-04 23:31:49 +0000
committerKjell Wooding <kjell@cvs.openbsd.org>2009-06-04 23:31:49 +0000
commitdbce436884980b29fca62a5f3c58d0eb44e542ef (patch)
treec3f03cd0c191f7bdc9046341725b6fbab6d3e998
parentb6f8c7be5956cd40a2988741b422f00bed6fe202 (diff)
Fix problem where line numbers get out of sync on a region-kill (C-w).
Noticed and ok matthieu@
-rw-r--r--usr.bin/mg/def.h3
-rw-r--r--usr.bin/mg/region.c7
2 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h
index 39e1859f7e9..2de0ef407c7 100644
--- a/usr.bin/mg/def.h
+++ b/usr.bin/mg/def.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: def.h,v 1.109 2009/06/04 02:23:37 kjell Exp $ */
+/* $OpenBSD: def.h,v 1.110 2009/06/04 23:31:47 kjell Exp $ */
/* This file is in the public domain. */
@@ -117,6 +117,7 @@ typedef int (*PF)(int, int); /* generally useful type */
struct region {
struct line *r_linep; /* Origin line address. */
int r_offset; /* Origin line offset. */
+ int r_lineno; /* Origin line number */
RSIZE r_size; /* Length in characters. */
};
diff --git a/usr.bin/mg/region.c b/usr.bin/mg/region.c
index 78555084453..3a554a47002 100644
--- a/usr.bin/mg/region.c
+++ b/usr.bin/mg/region.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: region.c,v 1.27 2008/09/15 16:11:35 kjell Exp $ */
+/* $OpenBSD: region.c,v 1.28 2009/06/04 23:31:48 kjell Exp $ */
/* This file is in the public domain. */
@@ -33,6 +33,7 @@ killregion(int f, int n)
thisflag |= CFKILL;
curwp->w_dotp = region.r_linep;
curwp->w_doto = region.r_offset;
+ curwp->w_dotline = region.r_lineno;
s = ldelete(region.r_size, KFORW);
clearmark(FFARG, 0);
@@ -194,6 +195,7 @@ getregion(struct region *rp)
/* "r_size" always ok */
if (curwp->w_dotp == curwp->w_markp) {
rp->r_linep = curwp->w_dotp;
+ rp->r_lineno = curwp->w_dotline;
if (curwp->w_doto < curwp->w_marko) {
rp->r_offset = curwp->w_doto;
rp->r_size = (RSIZE)(curwp->w_marko - curwp->w_doto);
@@ -213,6 +215,7 @@ getregion(struct region *rp)
if (flp == curwp->w_markp) {
rp->r_linep = curwp->w_dotp;
rp->r_offset = curwp->w_doto;
+ rp->r_lineno = curwp->w_dotline;
return (setsize(rp,
(RSIZE)(fsize + curwp->w_marko)));
}
@@ -224,6 +227,7 @@ getregion(struct region *rp)
if (blp == curwp->w_markp) {
rp->r_linep = blp;
rp->r_offset = curwp->w_marko;
+ rp->r_lineno = curwp->w_markline;
return (setsize(rp,
(RSIZE)(bsize - curwp->w_marko)));
}
@@ -285,6 +289,7 @@ prefixregion(int f, int n)
/* move to beginning of region */
curwp->w_dotp = region.r_linep;
curwp->w_doto = region.r_offset;
+ curwp->w_dotline = region.r_lineno;
/* for each line, go to beginning and insert the prefix string */
while (nline--) {