1 /* $NetBSD: v_put.c,v 1.3 2014/01/26 21:43:45 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.
13 #include <sys/cdefs.h>
16 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 ";
19 __RCSID("$NetBSD: v_put.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
22 #include <sys/types.h>
23 #include <sys/queue.h>
26 #include <bitstring.h>
30 #include "../common/common.h"
33 static void inc_buf
__P((SCR
*, VICMD
*));
37 * Insert the contents of the buffer before the cursor.
39 * PUBLIC: int v_Put __P((SCR *, VICMD *));
42 v_Put(SCR
*sp
, VICMD
*vp
)
46 if (F_ISSET(vp
, VC_ISDOT
))
51 * Historic vi did not support a count with the 'p' and 'P'
52 * commands. It's useful, so we do.
54 for (cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1; cnt
--;) {
56 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
57 &vp
->m_start
, &vp
->m_final
, 0))
59 vp
->m_start
= vp
->m_final
;
68 * Insert the contents of the buffer after the cursor.
70 * PUBLIC: int v_put __P((SCR *, VICMD *));
73 v_put(SCR
*sp
, VICMD
*vp
)
77 if (F_ISSET(vp
, VC_ISDOT
))
82 * Historic vi did not support a count with the 'p' and 'P'
83 * commands. It's useful, so we do.
85 for (cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1; cnt
--;) {
87 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
88 &vp
->m_start
, &vp
->m_final
, 1))
90 vp
->m_start
= vp
->m_final
;
99 * Historical whackadoo. The dot command `puts' the numbered buffer
100 * after the last one put. For example, `"4p.' would put buffer #4
101 * and buffer #5. If the user continued to enter '.', the #9 buffer
102 * would be repeatedly output. This was not documented, and is a bit
103 * tricky to reconstruct. Historical versions of vi also dropped the
104 * contents of the default buffer after each put, so after `"4p' the
105 * default buffer would be empty. This makes no sense to me, so we
106 * don't bother. Don't assume sequential order of numeric characters.
108 * And, if that weren't exciting enough, failed commands don't normally
109 * set the dot command. Well, boys and girls, an exception is that
110 * the buffer increment gets done regardless of the success of the put.
113 inc_buf(SCR
*sp
, VICMD
*vp
)
117 switch (vp
->buffer
) {
145 VIP(sp
)->sdot
.buffer
= vp
->buffer
= v
;