xref: /openbsd-src/usr.bin/vi/ex/ex_put.c (revision 91f110e064cd7c194e59e019b83bb7496c1c84d4)
1 /*	$OpenBSD: ex_put.c,v 1.5 2009/10/27 23:59:47 deraadt Exp $	*/
2 
3 /*-
4  * Copyright (c) 1992, 1993, 1994
5  *	The Regents of the University of California.  All rights reserved.
6  * Copyright (c) 1992, 1993, 1994, 1995, 1996
7  *	Keith Bostic.  All rights reserved.
8  *
9  * See the LICENSE file for redistribution information.
10  */
11 
12 #include "config.h"
13 
14 #include <sys/types.h>
15 #include <sys/queue.h>
16 
17 #include <bitstring.h>
18 #include <ctype.h>
19 #include <limits.h>
20 #include <stdio.h>
21 #include <string.h>
22 
23 #include "../common/common.h"
24 
25 /*
26  * ex_put -- [line] pu[t] [buffer]
27  *	Append a cut buffer into the file.
28  *
29  * PUBLIC: int ex_put(SCR *, EXCMD *);
30  */
31 int
32 ex_put(sp, cmdp)
33 	SCR *sp;
34 	EXCMD *cmdp;
35 {
36 	MARK m;
37 
38 	NEEDFILE(sp, cmdp);
39 
40 	m.lno = sp->lno;
41 	m.cno = sp->cno;
42 	if (put(sp, NULL,
43 	    FL_ISSET(cmdp->iflags, E_C_BUFFER) ? &cmdp->buffer : NULL,
44 	    &cmdp->addr1, &m, 1))
45 		return (1);
46 	sp->lno = m.lno;
47 	sp->cno = m.cno;
48 	return (0);
49 }
50