diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2022-02-20 19:45:52 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2022-02-20 19:45:52 +0000 |
commit | 2a4c9bf1b5e3d38e4f3187fbe32cfd8757795801 (patch) | |
tree | c50e156ff7e1a56b5f57ccd1b4a3c5640dcd6b55 /usr.bin/vi/common | |
parent | 9a15b4d73801c21ea2542a548ef4a4eb5931a623 (diff) |
Fix vi recovery mode.
From trondd, tested by various
ok afresh1
Diffstat (limited to 'usr.bin/vi/common')
-rw-r--r-- | usr.bin/vi/common/exf.h | 5 | ||||
-rw-r--r-- | usr.bin/vi/common/line.c | 10 | ||||
-rw-r--r-- | usr.bin/vi/common/recover.c | 4 |
3 files changed, 11 insertions, 8 deletions
diff --git a/usr.bin/vi/common/exf.h b/usr.bin/vi/common/exf.h index 3ae13e27440..c47be00e8e4 100644 --- a/usr.bin/vi/common/exf.h +++ b/usr.bin/vi/common/exf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exf.h,v 1.5 2015/04/24 21:48:31 brynet Exp $ */ +/* $OpenBSD: exf.h,v 1.6 2022/02/20 19:45:51 tb Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -58,7 +58,8 @@ struct _exf { #define F_RCV_NORM 0x020 /* Don't delete recovery files. */ #define F_RCV_ON 0x040 /* Recovery is possible. */ #define F_UNDO 0x080 /* No change since last undo. */ - u_int8_t flags; +#define F_RCV_SYNC 0x100 /* Recovery file sync needed. */ + u_int16_t flags; }; /* Flags to db_get(). */ diff --git a/usr.bin/vi/common/line.c b/usr.bin/vi/common/line.c index d66682231d3..7dfbdbf2756 100644 --- a/usr.bin/vi/common/line.c +++ b/usr.bin/vi/common/line.c @@ -1,4 +1,4 @@ -/* $OpenBSD: line.c,v 1.15 2016/01/06 22:28:52 millert Exp $ */ +/* $OpenBSD: line.c,v 1.16 2022/02/20 19:45:51 tb Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -218,7 +218,7 @@ db_delete(SCR *sp, recno_t lno) /* File now modified. */ if (F_ISSET(ep, F_FIRSTMODIFY)) (void)rcv_init(sp); - F_SET(ep, F_MODIFIED); + F_SET(ep, F_MODIFIED | F_RCV_SYNC); /* Update screen. */ return (scr_update(sp, lno, LINE_DELETE, 1)); @@ -266,7 +266,7 @@ db_append(SCR *sp, int update, recno_t lno, char *p, size_t len) /* File now dirty. */ if (F_ISSET(ep, F_FIRSTMODIFY)) (void)rcv_init(sp); - F_SET(ep, F_MODIFIED); + F_SET(ep, F_MODIFIED | F_RCV_SYNC); /* Log change. */ log_line(sp, lno + 1, LOG_LINE_APPEND); @@ -334,7 +334,7 @@ db_insert(SCR *sp, recno_t lno, char *p, size_t len) /* File now dirty. */ if (F_ISSET(ep, F_FIRSTMODIFY)) (void)rcv_init(sp); - F_SET(ep, F_MODIFIED); + F_SET(ep, F_MODIFIED | F_RCV_SYNC); /* Log change. */ log_line(sp, lno, LOG_LINE_INSERT); @@ -394,7 +394,7 @@ db_set(SCR *sp, recno_t lno, char *p, size_t len) /* File now dirty. */ if (F_ISSET(ep, F_FIRSTMODIFY)) (void)rcv_init(sp); - F_SET(ep, F_MODIFIED); + F_SET(ep, F_MODIFIED | F_RCV_SYNC); /* Log after change. */ log_line(sp, lno, LOG_LINE_RESET_F); diff --git a/usr.bin/vi/common/recover.c b/usr.bin/vi/common/recover.c index c49cfec2cd3..3c09b725a78 100644 --- a/usr.bin/vi/common/recover.c +++ b/usr.bin/vi/common/recover.c @@ -1,4 +1,4 @@ -/* $OpenBSD: recover.c,v 1.31 2021/10/24 21:24:17 deraadt Exp $ */ +/* $OpenBSD: recover.c,v 1.32 2022/02/20 19:45:51 tb Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -252,6 +252,8 @@ rcv_sync(SCR *sp, u_int flags) /* Sync the file if it's been modified. */ if (F_ISSET(ep, F_MODIFIED)) { + /* Clear recovery sync flag. */ + F_CLR(ep, F_RCV_SYNC); if (ep->db->sync(ep->db, R_RECNOSYNC)) { F_CLR(ep, F_RCV_ON | F_RCV_NORM); msgq_str(sp, M_SYSERR, |