summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/mg/file.c12
-rw-r--r--usr.bin/mg/undo.c8
2 files changed, 14 insertions, 6 deletions
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c
index 8cd19d3fd73..7310c71e6ca 100644
--- a/usr.bin/mg/file.c
+++ b/usr.bin/mg/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.22 2002/07/25 16:37:54 vincent Exp $ */
+/* $OpenBSD: file.c,v 1.23 2002/09/15 22:18:40 vincent Exp $ */
/*
* File commands.
@@ -196,9 +196,12 @@ insertfile(char *fname, char *newname, int needinfo)
LINE *lp1, *lp2;
LINE *olp; /* line we started at */
MGWIN *wp;
- int nbytes, s, nline, siz;
+ int nbytes, s, nline, siz, x = -1, x2;
int opos; /* offset we started at */
+ if (needinfo)
+ x = undo_enable(FALSE);
+
lp1 = NULL;
if (line == NULL) {
line = malloc(NLINE);
@@ -226,6 +229,7 @@ insertfile(char *fname, char *newname, int needinfo)
opos = curwp->w_doto;
/* open a new line, at point, and start inserting after it */
+ x2 = undo_enable(FALSE);
(void)lnewline();
olp = lback(curwp->w_dotp);
if (olp == curbp->b_linep) {
@@ -233,6 +237,7 @@ insertfile(char *fname, char *newname, int needinfo)
(void)lnewline();
curwp->w_dotp = lback(curwp->w_dotp);
}
+ undo_enable(x2);
/* don't count fake lines at the end */
nline = 0;
@@ -346,6 +351,9 @@ out: lp2 = NULL;
}
}
}
+ if (x != -1)
+ undo_enable(x);
+
/* return false if error */
return s != FIOERR;
}
diff --git a/usr.bin/mg/undo.c b/usr.bin/mg/undo.c
index 2087c85a524..769f40fd1a7 100644
--- a/usr.bin/mg/undo.c
+++ b/usr.bin/mg/undo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: undo.c,v 1.13 2002/08/22 23:28:19 deraadt Exp $ */
+/* $OpenBSD: undo.c,v 1.14 2002/09/15 22:18:39 vincent Exp $ */
/*
* Copyright (c) 2002 Vincent Labrecque
* All rights reserved.
@@ -182,9 +182,9 @@ last_was_boundary()
int
undo_enable(int on)
{
- undo_disable_flag = on ? 0 : 1;
-
- return (on);
+ int pon = undo_disable_flag;
+ undo_disable_flag = (on == TRUE) ? 0 : 1;
+ return (pon ? FALSE : TRUE);
}
int