1 /* $NetBSD: v_put.c,v 1.2 2013/11/22 15:52:06 christos Exp $ */
3 * Copyright (c) 1992, 1993, 1994
4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1992, 1993, 1994, 1995, 1996
6 * Keith Bostic. All rights reserved.
8 * See the LICENSE file for redistribution information.
14 static const char sccsid
[] = "Id: v_put.c,v 10.6 2001/06/25 15:19:34 skimo Exp (Berkeley) Date: 2001/06/25 15:19:34 ";
17 #include <sys/types.h>
18 #include <sys/queue.h>
21 #include <bitstring.h>
25 #include "../common/common.h"
28 static void inc_buf
__P((SCR
*, VICMD
*));
32 * Insert the contents of the buffer before the cursor.
34 * PUBLIC: int v_Put __P((SCR *, VICMD *));
37 v_Put(SCR
*sp
, VICMD
*vp
)
41 if (F_ISSET(vp
, VC_ISDOT
))
46 * Historic vi did not support a count with the 'p' and 'P'
47 * commands. It's useful, so we do.
49 for (cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1; cnt
--;) {
51 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
52 &vp
->m_start
, &vp
->m_final
, 0))
54 vp
->m_start
= vp
->m_final
;
63 * Insert the contents of the buffer after the cursor.
65 * PUBLIC: int v_put __P((SCR *, VICMD *));
68 v_put(SCR
*sp
, VICMD
*vp
)
72 if (F_ISSET(vp
, VC_ISDOT
))
77 * Historic vi did not support a count with the 'p' and 'P'
78 * commands. It's useful, so we do.
80 for (cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1; cnt
--;) {
82 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
83 &vp
->m_start
, &vp
->m_final
, 1))
85 vp
->m_start
= vp
->m_final
;
94 * Historical whackadoo. The dot command `puts' the numbered buffer
95 * after the last one put. For example, `"4p.' would put buffer #4
96 * and buffer #5. If the user continued to enter '.', the #9 buffer
97 * would be repeatedly output. This was not documented, and is a bit
98 * tricky to reconstruct. Historical versions of vi also dropped the
99 * contents of the default buffer after each put, so after `"4p' the
100 * default buffer would be empty. This makes no sense to me, so we
101 * don't bother. Don't assume sequential order of numeric characters.
103 * And, if that weren't exciting enough, failed commands don't normally
104 * set the dot command. Well, boys and girls, an exception is that
105 * the buffer increment gets done regardless of the success of the put.
108 inc_buf(SCR
*sp
, VICMD
*vp
)
112 switch (vp
->buffer
) {
140 VIP(sp
)->sdot
.buffer
= vp
->buffer
= v
;