diff options
Diffstat (limited to 'usr.bin/vi/log.c')
| -rw-r--r-- | usr.bin/vi/log.c | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/usr.bin/vi/log.c b/usr.bin/vi/log.c index fdf959f4d8a9..07d617ef92b1 100644 --- a/usr.bin/vi/log.c +++ b/usr.bin/vi/log.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1992, 1993 + * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,16 +32,26 @@ */ #ifndef lint -static char sccsid[] = "@(#)log.c 8.9 (Berkeley) 12/28/93"; +static char sccsid[] = "@(#)log.c 8.14 (Berkeley) 3/14/94"; #endif /* not lint */ #include <sys/types.h> +#include <queue.h> #include <sys/stat.h> +#include <sys/time.h> +#include <bitstring.h> #include <errno.h> #include <fcntl.h> +#include <limits.h> +#include <signal.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <termios.h> + +#include <db.h> +#include <regex.h> #include "vi.h" @@ -56,7 +66,7 @@ static char sccsid[] = "@(#)log.c 8.9 (Berkeley) 12/28/93"; * LOG_LINE_INSERT recno_t char * * LOG_LINE_RESET_F recno_t char * * LOG_LINE_RESET_B recno_t char * - * LOG_MARK MARK + * LOG_MARK LMARK * * We do before image physical logging. This means that the editor layer * MAY NOT modify records in place, even if simply deleting or overwriting @@ -149,7 +159,7 @@ log_end(sp, ep) ep->l_high = ep->l_cur = 1; return (0); } - + /* * log_cursor -- * Log the current cursor position, starting an event. @@ -239,7 +249,7 @@ log_line(sp, ep, lno, action) return (1); ep->l_cursor.lno = OOBLNO; } - + /* * Put out the changes. If it's a LOG_LINE_RESET_B call, it's a * special case, avoid the caches. Also, if it fails and it's @@ -311,10 +321,10 @@ log_line(sp, ep, lno, action) * cause any other change. */ int -log_mark(sp, ep, mp) +log_mark(sp, ep, lmp) SCR *sp; EXF *ep; - MARK *mp; + LMARK *lmp; { DBT data, key; @@ -329,17 +339,21 @@ log_mark(sp, ep, mp) } BINC_RET(sp, ep->l_lp, - ep->l_len, sizeof(u_char) + sizeof(MARK)); + ep->l_len, sizeof(u_char) + sizeof(LMARK)); ep->l_lp[0] = LOG_MARK; - memmove(ep->l_lp + sizeof(u_char), mp, sizeof(MARK)); + memmove(ep->l_lp + sizeof(u_char), lmp, sizeof(LMARK)); key.data = &ep->l_cur; key.size = sizeof(recno_t); data.data = ep->l_lp; - data.size = sizeof(u_char) + sizeof(MARK); + data.size = sizeof(u_char) + sizeof(LMARK); if (ep->log->put(ep->log, &key, &data, 0) == -1) LOG_ERR; +#if defined(DEBUG) && 0 + TRACE(sp, "%lu: mark %c: %lu/%u\n", + ep->l_cur, lmp->name, lmp->lno, lmp->cno); +#endif /* Reset high water mark. */ ep->l_high = ++ep->l_cur; return (0); @@ -356,6 +370,7 @@ log_backward(sp, ep, rp) MARK *rp; { DBT key, data; + LMARK lm; MARK m; recno_t lno; int didop; @@ -423,8 +438,10 @@ log_backward(sp, ep, rp) break; case LOG_MARK: didop = 1; - memmove(&m, p + sizeof(u_char), sizeof(MARK)); - if (mark_set(sp, ep, m.name, &m, 0)) + memmove(&lm, p + sizeof(u_char), sizeof(LMARK)); + m.lno = lm.lno; + m.cno = lm.cno; + if (mark_set(sp, ep, lm.name, &m, 0)) goto err; break; default: @@ -452,6 +469,7 @@ log_setline(sp, ep) EXF *ep; { DBT key, data; + LMARK lm; MARK m; recno_t lno; u_char *p; @@ -507,8 +525,10 @@ log_setline(sp, ep) goto err; ++sp->rptlines[L_CHANGED]; case LOG_MARK: - memmove(&m, p + sizeof(u_char), sizeof(MARK)); - if (mark_set(sp, ep, m.name, &m, 0)) + memmove(&lm, p + sizeof(u_char), sizeof(LMARK)); + m.lno = lm.lno; + m.cno = lm.cno; + if (mark_set(sp, ep, lm.name, &m, 0)) goto err; break; default: @@ -531,6 +551,7 @@ log_forward(sp, ep, rp) MARK *rp; { DBT key, data; + LMARK lm; MARK m; recno_t lno; int didop; @@ -599,8 +620,10 @@ log_forward(sp, ep, rp) break; case LOG_MARK: didop = 1; - memmove(&m, p + sizeof(u_char), sizeof(MARK)); - if (mark_set(sp, ep, m.name, &m, 0)) + memmove(&lm, p + sizeof(u_char), sizeof(LMARK)); + m.lno = lm.lno; + m.cno = lm.cno; + if (mark_set(sp, ep, lm.name, &m, 0)) goto err; break; default: @@ -620,6 +643,7 @@ log_trace(sp, msg, rno, p) recno_t rno; u_char *p; { + LMARK lm; MARK m; recno_t lno; @@ -653,8 +677,9 @@ log_trace(sp, msg, rno, p) TRACE(sp, "%lu: %s: RESET_B: %lu\n", rno, msg, lno); break; case LOG_MARK: - memmove(&m, p + sizeof(u_char), sizeof(MARK)); - TRACE(sp, "%lu: %s: MARK: %u/%u\n", rno, msg, m.lno, m.cno); + memmove(&lm, p + sizeof(u_char), sizeof(LMARK)); + TRACE(sp, + "%lu: %s: MARK: %u/%u\n", rno, msg, lm.lno, lm.cno); break; default: abort(); |
