From f3c4c7f1b9880684127aef570a8940fefc1f2a76 Mon Sep 17 00:00:00 2001 From: bostic Date: Sun, 9 Jan 1994 14:20:08 +0000 Subject: [PATCH] rework cut buffers to match historic practice --- common/cut.c | 172 +++++++++++++++++++++++++++++++++----------------------- common/cut.h | 25 ++------ common/gs.h | 4 +- ex/ex_at.c | 8 ++- ex/ex_delete.c | 11 ++-- ex/ex_display.c | 19 ++++--- ex/ex_move.c | 33 +++++++---- ex/ex_put.c | 5 +- ex/ex_yank.c | 8 +-- vi/v_delete.c | 17 ++++-- vi/v_itxt.c | 18 +++--- vi/v_put.c | 6 +- vi/v_xchar.c | 6 +- vi/v_yank.c | 11 ++-- 14 files changed, 196 insertions(+), 147 deletions(-) diff --git a/common/cut.c b/common/cut.c index c54b5a50..68244233 100644 --- a/common/cut.c +++ b/common/cut.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: cut.c,v 8.16 1993/12/29 10:48:43 bostic Exp $ (Berkeley) $Date: 1993/12/29 10:48:43 $"; +static char sccsid[] = "$Id: cut.c,v 8.17 1994/01/09 14:20:08 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:20:08 $"; #endif /* not lint */ #include @@ -25,65 +25,87 @@ static int cb_rotate __P((SCR *)); /* * cut -- * Put a range of lines/columns into a buffer. + * + * There are two buffer areas, both found in the global structure. The first + * is the linked list of all the buffers the user has named, the second is the + * default buffer storage. There is a pointer, too, which is the current + * default buffer, i.e. it may point to the default buffer or a named buffer + * depending on into what buffer the last text was cut. In delete operations, + * text is cut into either the buffer named by the user, or the buffer named + * '1'. In a yank, the text is cut into either the buffer named by the user, + * or the default buffer. In both cases, as stated above, the default buffer + * pointer is changed to reference the cut text, wherever that may be. Also, + * delete operations rotate the contents of the numbered buffers up one, and + * the contents of buffer '9' are discarded. + * + * In all cases, upper-case buffer names are the same as lower-case names, + * with the exception that they cause the buffer to be appended to instead + * of replaced. + * + * !!! + * The contents of the default buffer would disappear after most operations in + * historic vi. It's unclear that this is useful, so we don't bother. + * + * When users explicitly cut text into the numeric buffers, historic vi became + * genuinely strange. I've never been able to figure out what was supposed to + * happen. It behaved differently if you deleted text than if you yanked text, + * and, in the latter case, the text was appended to the buffer instead of + * replacing the contents. Hopefully it's not worth getting right. */ int -cut(sp, ep, name, fm, tm, lmode) +cut(sp, ep, cbp, namep, fm, tm, flags) SCR *sp; EXF *ep; - ARG_CHAR_T name; - int lmode; + CB *cbp; + CHAR_T *namep; + int flags; MARK *fm, *tm; { - CB *cbp; + CHAR_T name; TEXT *tp; recno_t lno; size_t len; - int append; + int append, namedbuffer; #if defined(DEBUG) && 0 TRACE(sp, "cut: from {%lu, %d}, to {%lu, %d}%s\n", - fm->lno, fm->cno, tm->lno, tm->cno, lmode ? " LINE MODE" : ""); + fm->lno, fm->cno, tm->lno, tm->cno, + LF_ISSET(CUT_LINEMODE) ? " LINE MODE" : ""); #endif - /* - * !!! - * The numeric buffers in historic vi offer us yet another opportunity - * for contemplation. First, the default buffer was the same as buffer - * '1'. Second, cutting into any numeric buffer caused buffers '1' to - * '8' to be rotated up one, and '9' to drop off the end. Finally, - * text cut into a numeric buffer other than '1' was always appended - * to the buffer (after the rotation), it was not a replacement. - */ - append = 0; - if (isdigit(name)) { + if (LF_ISSET(CUT_ROTATE)) (void)cb_rotate(sp); - if (name != '1') - append = 1; - } - /* - * Upper-case buffer names map into lower-case buffers, but with - * append mode set so the buffer is appended to, not overwritten. - */ - if (isupper(name)) - append = 1; - CBNAME(sp, cbp, name); + if (cbp == NULL) { + if (namep == NULL) { + cbp = sp->gp->dcb_store; + append = namedbuffer = 0; + } else { + name = *namep; + CBNAME(sp, cbp, name); + append = isupper(name); + namedbuffer = 1; + } + } else + append = namedbuffer = 0; /* - * If this is a new buffer, create it, and add it into the list. + * If this is a new buffer, create it and add it into the list. * Otherwise, if it's not an append, free its current contents. */ if (cbp == NULL) { CALLOC(sp, cbp, CB *, 1, sizeof(CB)); cbp->name = name; - LIST_INSERT_HEAD(&sp->gp->cutq, cbp, q); CIRCLEQ_INIT(&cbp->textq); + if (namedbuffer) + LIST_INSERT_HEAD(&sp->gp->cutq, cbp, q); } else if (!append) { text_lfree(&cbp->textq); cbp->len = 0; cbp->flags = 0; } - if (lmode) { + /* In line mode, it's pretty easy, just cut the lines. */ + if (LF_ISSET(CUT_LINEMODE)) { for (lno = fm->lno; lno <= tm->lno; ++lno) { if (cb_line(sp, ep, lno, 0, 0, &tp)) goto mem; @@ -91,38 +113,40 @@ cut(sp, ep, name, fm, tm, lmode) cbp->len += tp->len; } cbp->flags |= CB_LMODE; - return (0); - } - - /* Get the first line. */ - len = fm->lno < tm->lno ? 0 : tm->cno - fm->cno; - if (cb_line(sp, ep, fm->lno, fm->cno, len, &tp)) - goto mem; - - CIRCLEQ_INSERT_TAIL(&cbp->textq, tp, q); - cbp->len += tp->len; - - for (lno = fm->lno; ++lno < tm->lno;) { - if (cb_line(sp, ep, lno, 0, 0, &tp)) + } else { + /* Get the first line. */ + len = fm->lno < tm->lno ? 0 : tm->cno - fm->cno; + if (cb_line(sp, ep, fm->lno, fm->cno, len, &tp)) goto mem; CIRCLEQ_INSERT_TAIL(&cbp->textq, tp, q); cbp->len += tp->len; - } - if (tm->lno > fm->lno && tm->cno > 0) { - if (cb_line(sp, ep, lno, 0, tm->cno, &tp)) { -mem: if (append) - msgq(sp, M_ERR, - "Contents of %s buffer lost.", - charname(sp, name)); - text_lfree(&cbp->textq); - cbp->len = 0; - cbp->flags = 0; - return (1); + /* Get the intermediate lines. */ + for (lno = fm->lno; ++lno < tm->lno;) { + if (cb_line(sp, ep, lno, 0, 0, &tp)) + goto mem; + CIRCLEQ_INSERT_TAIL(&cbp->textq, tp, q); + cbp->len += tp->len; + } + + /* Get the last line. */ + if (tm->lno > fm->lno && tm->cno > 0) { + if (cb_line(sp, ep, lno, 0, tm->cno, &tp)) { +mem: if (append) + msgq(sp, M_ERR, + "Contents of %s buffer lost.", + charname(sp, name)); + text_lfree(&cbp->textq); + cbp->len = 0; + cbp->flags = 0; + return (1); + } + CIRCLEQ_INSERT_TAIL(&cbp->textq, tp, q); + cbp->len += tp->len; } - CIRCLEQ_INSERT_TAIL(&cbp->textq, tp, q); - cbp->len += tp->len; } + if (namedbuffer) + sp->gp->dcbp = cbp; /* Repoint default buffer. */ return (0); } @@ -288,24 +312,37 @@ text_free(tp) * blank line. */ int -put(sp, ep, name, cp, rp, append) +put(sp, ep, cbp, namep, cp, rp, append) SCR *sp; EXF *ep; - ARG_CHAR_T name; + CB *cbp; + CHAR_T *namep; MARK *cp, *rp; int append; { - CB *cbp; + CHAR_T name; TEXT *ltp, *tp; recno_t lno; size_t blen, clen, len; - int lmode; char *bp, *p, *t; - CBEMPTY(sp, cbp, name); - + if (cbp == NULL) + if (namep == NULL) { + cbp = sp->gp->dcbp; + if (cbp == NULL) { + msgq(sp, M_ERR, "The default buffer is empty."); + return (1); + } + } else { + name = *namep; + CBNAME(sp, cbp, name); + if (cbp == NULL) { + msgq(sp, M_ERR, + "Buffer %s is empty.", charname(sp, name)); + return (1); + } + } tp = cbp->textq.cqh_first; - lmode = F_ISSET(cbp, CB_LMODE); /* * It's possible to do a put into an empty file, meaning that the @@ -330,11 +367,8 @@ put(sp, ep, name, cp, rp, append) } } - /* - * If buffer was created in line mode, append each new line into the - * file. - */ - if (lmode) { + /* If a line mode buffer, append each new line into the file. */ + if (F_ISSET(cbp, CB_LMODE)) { lno = append ? cp->lno : cp->lno - 1; rp->lno = lno + 1; for (; tp != (void *)&cbp->textq; ++lno, tp = tp->q.cqe_next) diff --git a/common/cut.h b/common/cut.h index 0838bdd7..25850a00 100644 --- a/common/cut.h +++ b/common/cut.h @@ -4,7 +4,7 @@ * * %sccs.include.redist.c% * - * $Id: cut.h,v 8.8 1993/11/19 11:55:04 bostic Exp $ (Berkeley) $Date: 1993/11/19 11:55:04 $ + * $Id: cut.h,v 8.9 1994/01/09 14:20:10 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:20:10 $ */ typedef struct _texth TEXTH; /* TEXT list head structure. */ @@ -40,8 +40,6 @@ struct _text { /* Text: a linked list of lines. */ size_t wd_len; /* Width buffer length. */ }; -#define DEFCB '1' /* Buffer '1' is the default buffer. */ - /* * Get named buffer 'name'. * Translate upper-case buffer names to lower-case buffer names. @@ -54,23 +52,12 @@ struct _text { /* Text: a linked list of lines. */ break; \ } -/* Get a cut buffer, and check to see if it's empty. */ -#define CBEMPTY(sp, cbp, name) { \ - CBNAME(sp, cbp, name); \ - if (cbp == NULL) { \ - if ((name) == '1') \ - msgq(sp, M_ERR, \ - "The default buffer is empty."); \ - else \ - msgq(sp, M_ERR, \ - "Buffer %s is empty.", charname(sp, name)); \ - return (1); \ - } \ -} - -int cut __P((SCR *, EXF *, ARG_CHAR_T, MARK *, MARK *, int)); +#define CUT_LINEMODE 0x01 /* Cut in line mode. */ +#define CUT_ROTATE 0x02 /* Rotate numeric buffers (delete). */ +int cut __P((SCR *, EXF *, CB *, CHAR_T *, MARK *, MARK *, int)); int delete __P((SCR *, EXF *, MARK *, MARK *, int)); -int put __P((SCR *, EXF *, ARG_CHAR_T, MARK *, MARK *, int)); +int put __P((SCR *, EXF *, CB *, CHAR_T *, MARK *, MARK *, int)); + void text_free __P((TEXT *)); TEXT *text_init __P((SCR *, const char *, size_t, size_t)); void text_lfree __P((TEXTH *)); diff --git a/common/gs.h b/common/gs.h index 933c337d..9c333de6 100644 --- a/common/gs.h +++ b/common/gs.h @@ -4,7 +4,7 @@ * * %sccs.include.redist.c% * - * $Id: gs.h,v 8.25 1993/12/22 16:13:58 bostic Exp $ (Berkeley) $Date: 1993/12/22 16:13:58 $ + * $Id: gs.h,v 8.26 1994/01/09 14:20:11 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:20:11 $ */ struct _gs { @@ -29,6 +29,8 @@ struct _gs { /* INFORMATION SHARED BY ALL SCREENS. */ IBUF *tty; /* Key input buffer. */ + CB *dcbp; /* Default cut buffer pointer. */ + CB *dcb_store; /* Default cut buffer storage. */ LIST_HEAD(_cuth, _cb) cutq; /* Linked list of cut buffers. */ #define MAX_BIT_SEQ 128 /* Max + 1 fast check character. */ diff --git a/ex/ex_at.c b/ex/ex_at.c index 4abd22fc..5d85309a 100644 --- a/ex/ex_at.c +++ b/ex/ex_at.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: ex_at.c,v 8.15 1993/12/22 13:15:47 bostic Exp $ (Berkeley) $Date: 1993/12/22 13:15:47 $"; +static char sccsid[] = "$Id: ex_at.c,v 8.16 1994/01/09 14:20:53 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:20:53 $"; #endif /* not lint */ #include @@ -47,7 +47,11 @@ ex_at(sp, ep, cmdp) name = exp->at_lbuf; } - CBEMPTY(sp, cbp, name); + CBNAME(sp, cbp, name); + if (cbp == NULL) { + msgq(sp, M_ERR, "Buffer %s is empty.", charname(sp, name)); + return (1); + } /* Save for reuse. */ exp->at_lbuf = name; diff --git a/ex/ex_delete.c b/ex/ex_delete.c index 99391dd4..283e9622 100644 --- a/ex/ex_delete.c +++ b/ex/ex_delete.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: ex_delete.c,v 8.4 1993/12/29 09:50:49 bostic Exp $ (Berkeley) $Date: 1993/12/29 09:50:49 $"; +static char sccsid[] = "$Id: ex_delete.c,v 8.5 1994/01/09 14:20:54 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:20:54 $"; #endif /* not lint */ #include @@ -27,10 +27,11 @@ ex_delete(sp, ep, cmdp) { recno_t lno; - /* Yank the lines. */ - if (cut(sp, ep, - F_ISSET(cmdp, E_BUFFER) ? cmdp->buffer : DEFCB, - &cmdp->addr1, &cmdp->addr2, 1)) + /* Yank the lines; the default buffer for deletes is '1'. */ + if (!F_ISSET(cmdp, E_BUFFER)) + cmdp->buffer = '1'; + if (cut(sp, ep, NULL, &cmdp->buffer, + &cmdp->addr1, &cmdp->addr2, CUT_LINEMODE | CUT_ROTATE)) return (1); /* Delete the lines. */ diff --git a/ex/ex_display.c b/ex/ex_display.c index cad9e3b8..56bd9eb3 100644 --- a/ex/ex_display.c +++ b/ex/ex_display.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: ex_display.c,v 8.13 1993/12/28 11:47:50 bostic Exp $ (Berkeley) $Date: 1993/12/28 11:47:50 $"; +static char sccsid[] = "$Id: ex_display.c,v 8.14 1994/01/09 14:20:55 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:20:55 $"; #endif /* not lint */ #include @@ -19,7 +19,7 @@ static char sccsid[] = "$Id: ex_display.c,v 8.13 1993/12/28 11:47:50 bostic Exp #include "excmd.h" static int bdisplay __P((SCR *, EXF *)); -static void db __P((SCR *, CB *)); +static void db __P((SCR *, CB *, char *)); /* * ex_display -- :display b[uffers] | s[creens] | t[ags] @@ -58,7 +58,7 @@ bdisplay(sp, ep) { CB *cbp; - if (sp->gp->cutq.lh_first == NULL) { + if (sp->gp->cutq.lh_first == NULL && sp->gp->dcbp == NULL) { (void)ex_printf(EXCOOKIE, "No cut buffers to display."); return (0); } @@ -71,7 +71,7 @@ bdisplay(sp, ep) if (isdigit(cbp->name)) continue; if (cbp->textq.cqh_first != (void *)&cbp->textq) - db(sp, cbp); + db(sp, cbp, NULL); if (F_ISSET(sp, S_INTERRUPTED)) return (0); } @@ -80,10 +80,13 @@ bdisplay(sp, ep) if (!isdigit(cbp->name)) continue; if (cbp->textq.cqh_first != (void *)&cbp->textq) - db(sp, cbp); + db(sp, cbp, NULL); if (F_ISSET(sp, S_INTERRUPTED)) return (0); } + /* Display default buffer. */ + if ((cbp = sp->gp->dcbp) != NULL) + db(sp, cbp, "default buffer"); return (0); } @@ -92,15 +95,17 @@ bdisplay(sp, ep) * Display a buffer. */ static void -db(sp, cbp) +db(sp, cbp, name) SCR *sp; CB *cbp; + char *name; { TEXT *tp; size_t len; char *p; - (void)ex_printf(EXCOOKIE, "********** %s%s\n", charname(sp, cbp->name), + (void)ex_printf(EXCOOKIE, "********** %s%s\n", + name == NULL ? charname(sp, cbp->name) : name, F_ISSET(cbp, CB_LMODE) ? " (line mode)" : ""); for (tp = cbp->textq.cqh_first; tp != (void *)&cbp->textq; tp = tp->q.cqe_next) { diff --git a/ex/ex_move.c b/ex/ex_move.c index 8339cfb1..a892b7a8 100644 --- a/ex/ex_move.c +++ b/ex/ex_move.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: ex_move.c,v 8.4 1993/12/29 10:37:04 bostic Exp $ (Berkeley) $Date: 1993/12/29 10:37:04 $"; +static char sccsid[] = "$Id: ex_move.c,v 8.5 1994/01/09 14:20:55 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:20:55 $"; #endif /* not lint */ #include @@ -50,8 +50,10 @@ cm(sp, ep, cmdp, cmd) EXCMDARG *cmdp; enum which cmd; { + CB cb; MARK fm1, fm2, m, tm; recno_t diff; + int rval; fm1 = cmdp->addr1; fm2 = cmdp->addr2; @@ -60,37 +62,44 @@ cm(sp, ep, cmdp, cmd) /* Make sure the destination is valid. */ if (cmd == MOVE && tm.lno >= fm1.lno && tm.lno < fm2.lno) { - msgq(sp, M_ERR, - "Destination line is inside move range."); + msgq(sp, M_ERR, "Destination line is inside move range."); return (1); } /* Save the text to a cut buffer. */ - if (cut(sp, ep, DEFCB, &fm1, &fm2, 1)) + memset(&cb, 0, sizeof(cb)); + CIRCLEQ_INIT(&cb.textq); + if (cut(sp, ep, &cb, NULL, &fm1, &fm2, CUT_LINEMODE)) return (1); /* If we're not copying, delete the old text and adjust tm. */ if (cmd == MOVE) { - if (delete(sp, ep, &fm1, &fm2, 1)) - return (1); + if (delete(sp, ep, &fm1, &fm2, 1)) { + rval = 1; + goto err; + } if (tm.lno >= fm1.lno) tm.lno -= (fm2.lno - fm1.lno) + 1; } /* Add the new text. */ - if (put(sp, ep, DEFCB, &tm, &m, 1)) - return (1); + if (put(sp, ep, &cb, NULL, &tm, &m, 1)) { + rval = 1; + goto err; + } /* - * Move and copy move the cursor to the last line moved or copied. + * Move and copy put the cursor on the last line moved or copied. * The returned cursor from the put routine is the first line put, - * not the last, because that's the semantics that vi uses. + * not the last, because that's the semantics of vi. */ diff = (fm2.lno - fm1.lno) + 1; sp->lno = m.lno + (diff - 1); sp->cno = 0; - /* Reporting. */ sp->rptlines[cmd == COPY ? L_COPIED : L_MOVED] += diff; - return (0); + rval = 0; + +err: (void)text_lfree(&cb.textq); + return (rval); } diff --git a/ex/ex_put.c b/ex/ex_put.c index 4ba032cc..f7de6438 100644 --- a/ex/ex_put.c +++ b/ex/ex_put.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: ex_put.c,v 8.3 1993/12/29 09:50:52 bostic Exp $ (Berkeley) $Date: 1993/12/29 09:50:52 $"; +static char sccsid[] = "$Id: ex_put.c,v 8.4 1994/01/09 14:20:56 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:20:56 $"; #endif /* not lint */ #include @@ -32,8 +32,7 @@ ex_put(sp, ep, cmdp) m.lno = sp->lno; m.cno = sp->cno; - if (put(sp, ep, - F_ISSET(cmdp, E_BUFFER) ? DEFCB : cmdp->buffer, + if (put(sp, ep, NULL, F_ISSET(cmdp, E_BUFFER) ? &cmdp->buffer : NULL, &cmdp->addr1, &m, 1)) return (1); return (0); diff --git a/ex/ex_yank.c b/ex/ex_yank.c index 186c5f3d..155f78c7 100644 --- a/ex/ex_yank.c +++ b/ex/ex_yank.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: ex_yank.c,v 8.2 1993/11/04 16:16:55 bostic Exp $ (Berkeley) $Date: 1993/11/04 16:16:55 $"; +static char sccsid[] = "$Id: ex_yank.c,v 8.3 1994/01/09 14:20:57 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:20:57 $"; #endif /* not lint */ #include @@ -25,7 +25,7 @@ ex_yank(sp, ep, cmdp) EXF *ep; EXCMDARG *cmdp; { - return (cut(sp, ep, - F_ISSET(cmdp, E_BUFFER) ? cmdp->buffer : DEFCB, - &cmdp->addr1, &cmdp->addr2, 1)); + return (cut(sp, ep, NULL, + F_ISSET(cmdp, E_BUFFER) ? &cmdp->buffer : NULL, + &cmdp->addr1, &cmdp->addr2, CUT_LINEMODE)); } diff --git a/vi/v_delete.c b/vi/v_delete.c index cfed70d8..6f40d128 100644 --- a/vi/v_delete.c +++ b/vi/v_delete.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: v_delete.c,v 8.5 1993/11/04 16:17:23 bostic Exp $ (Berkeley) $Date: 1993/11/04 16:17:23 $"; +static char sccsid[] = "$Id: v_delete.c,v 8.6 1994/01/09 14:21:11 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:21:11 $"; #endif /* not lint */ #include @@ -43,8 +43,10 @@ v_Delete(sp, ep, vp, fm, tm, rp) tm->lno = fm->lno; tm->cno = len; - if (cut(sp, ep, - F_ISSET(vp, VC_BUFFER) ? vp->buffer : DEFCB, fm, tm, 0)) + /* The default buffer for deletes is '1'. */ + if (!F_ISSET(vp, VC_BUFFER)) + vp->buffer = '1'; + if (cut(sp, ep, NULL, &vp->buffer, fm, tm, CUT_ROTATE)) return (1); if (delete(sp, ep, fm, tm, 0)) return (1); @@ -69,9 +71,12 @@ v_delete(sp, ep, vp, fm, tm, rp) size_t len; int lmode; - lmode = F_ISSET(vp, VC_LMODE); - if (cut(sp, ep, - F_ISSET(vp, VC_BUFFER) ? vp->buffer : DEFCB, fm, tm, lmode)) + /* The default buffer for deletes is '1'. */ + if (!F_ISSET(vp, VC_BUFFER)) + vp->buffer = '1'; + + lmode = F_ISSET(vp, VC_LMODE) ? CUT_LINEMODE : 0; + if (cut(sp, ep, NULL, &vp->buffer, fm, tm, lmode | CUT_ROTATE)) return (1); if (delete(sp, ep, fm, tm, lmode)) return (1); diff --git a/vi/v_itxt.c b/vi/v_itxt.c index 2e34c4e1..59a9acd4 100644 --- a/vi/v_itxt.c +++ b/vi/v_itxt.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: v_itxt.c,v 8.21 1993/12/29 12:30:28 bostic Exp $ (Berkeley) $Date: 1993/12/29 12:30:28 $"; +static char sccsid[] = "$Id: v_itxt.c,v 8.22 1994/01/09 14:21:13 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:21:13 $"; #endif /* not lint */ #include @@ -489,7 +489,8 @@ v_CS(sp, ep, vp, fm, tm, rp, iflags) /* Cut the lines. */ if (cut(sp, ep, - F_ISSET(vp, VC_BUFFER) ? vp->buffer : DEFCB, fm, tm, 1)) + NULL, F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL, + fm, tm, CUT_LINEMODE)) return (1); /* Insert a line while we still can... */ @@ -524,8 +525,8 @@ v_CS(sp, ep, vp, fm, tm, rp, iflags) LF_SET(TXT_APPENDEOL); } else { if (cut(sp, ep, - F_ISSET(vp, VC_BUFFER) ? vp->buffer : DEFCB, - fm, tm, 1)) + NULL, F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL, + fm, tm, CUT_LINEMODE)) return (1); tm->cno = len; if (len == 0) @@ -567,7 +568,8 @@ v_change(sp, ep, vp, fm, tm, rp) * to make it just a bit more exciting, the initial space is handled * as auto-indent characters. */ - if (lmode = F_ISSET(vp, VC_LMODE)) { + lmode = F_ISSET(vp, VC_LMODE) ? CUT_LINEMODE : 0; + if (lmode) { fm->cno = 0; if (O_ISSET(sp, O_AUTOINDENT)) { if (nonblank(sp, ep, fm->lno, &fm->cno)) @@ -600,7 +602,7 @@ v_change(sp, ep, vp, fm, tm, rp) LF_SET(TXT_APPENDEOL); } else { if (cut(sp, ep, - F_ISSET(vp, VC_BUFFER) ? vp->buffer : DEFCB, + NULL, F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL, fm, tm, lmode)) return (1); if (len == 0) @@ -622,7 +624,7 @@ v_change(sp, ep, vp, fm, tm, rp) * Copy the text. */ if (cut(sp, ep, - F_ISSET(vp, VC_BUFFER) ? vp->buffer : DEFCB, fm, tm, lmode)) + NULL, F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL, fm, tm, lmode)) return (1); /* If replacing entire lines and there's leading text. */ @@ -791,7 +793,7 @@ v_subst(sp, ep, vp, fm, tm, rp) tm->cno = len; if (p != NULL && cut(sp, ep, - F_ISSET(vp, VC_BUFFER) ? vp->buffer : DEFCB, fm, tm, 0)) + NULL, F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL, fm, tm, 0)) return (1); return (v_ntext(sp, ep, diff --git a/vi/v_put.c b/vi/v_put.c index 43493b36..97187dd7 100644 --- a/vi/v_put.c +++ b/vi/v_put.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: v_put.c,v 8.5 1993/11/13 18:01:41 bostic Exp $ (Berkeley) $Date: 1993/11/13 18:01:41 $"; +static char sccsid[] = "$Id: v_put.c,v 8.6 1994/01/09 14:21:13 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:21:13 $"; #endif /* not lint */ #include @@ -30,7 +30,7 @@ v_Put(sp, ep, vp, fm, tm, rp) if (F_ISSET(vp, VC_ISDOT)) inc_buf(sp, vp); return (put(sp, ep, - F_ISSET(vp, VC_BUFFER) ? vp->buffer : DEFCB, fm, rp, 0)); + NULL, F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL, fm, rp, 0)); } /* @@ -48,7 +48,7 @@ v_put(sp, ep, vp, fm, tm, rp) inc_buf(sp, vp); return (put(sp, ep, - F_ISSET(vp, VC_BUFFER) ? vp->buffer : DEFCB, fm, rp, 1)); + NULL, F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL, fm, rp, 1)); } /* diff --git a/vi/v_xchar.c b/vi/v_xchar.c index f083d07d..e5db1c7a 100644 --- a/vi/v_xchar.c +++ b/vi/v_xchar.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: v_xchar.c,v 8.3 1993/11/04 16:17:27 bostic Exp $ (Berkeley) $Date: 1993/11/04 16:17:27 $"; +static char sccsid[] = "$Id: v_xchar.c,v 8.4 1994/01/09 14:21:16 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:21:16 $"; #endif /* not lint */ #include @@ -66,7 +66,7 @@ v_xchar(sp, ep, vp, fm, tm, rp) } if (cut(sp, ep, - F_ISSET(vp, VC_BUFFER) ? vp->buffer : DEFCB, fm, tm, 0)) + NULL, F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL, fm, tm, 0)) return (1); if (delete(sp, ep, fm, tm, 0)) return (1); @@ -99,7 +99,7 @@ v_Xchar(sp, ep, vp, fm, tm, rp) fm->cno = cnt >= tm->cno ? 0 : tm->cno - cnt; if (cut(sp, ep, - F_ISSET(vp, VC_BUFFER) ? vp->buffer : DEFCB, fm, tm, 0)) + NULL, F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL, fm, tm, 0)) return (1); if (delete(sp, ep, fm, tm, 0)) return (1); diff --git a/vi/v_yank.c b/vi/v_yank.c index c72bf91a..b555d0da 100644 --- a/vi/v_yank.c +++ b/vi/v_yank.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: v_yank.c,v 8.10 1994/01/08 16:40:31 bostic Exp $ (Berkeley) $Date: 1994/01/08 16:40:31 $"; +static char sccsid[] = "$Id: v_yank.c,v 8.11 1994/01/09 14:21:17 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:21:17 $"; #endif /* not lint */ #include @@ -29,8 +29,8 @@ v_Yank(sp, ep, vp, fm, tm, rp) v_eof(sp, ep, fm); return (1); } - if (cut(sp, ep, - F_ISSET(vp, VC_BUFFER) ? vp->buffer : DEFCB, fm, tm, 1)) + if (cut(sp, ep, NULL, F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL, + fm, tm, CUT_LINEMODE)) return (1); sp->rptlines[L_YANKED] += (tm->lno - fm->lno) + 1; @@ -54,10 +54,11 @@ v_yank(sp, ep, vp, fm, tm, rp) return (1); } if (cut(sp, ep, - F_ISSET(vp, VC_BUFFER) ? vp->buffer : DEFCB, fm, tm, 1)) + NULL, F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL, + fm, tm, CUT_LINEMODE)) return (1); } else if (cut(sp, ep, - F_ISSET(vp, VC_BUFFER) ? vp->buffer : DEFCB, fm, tm, 0)) + NULL, F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL, fm, tm, 0)) return (1); /* -- 2.11.4.GIT