2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
9 static char sccsid
[] = "$Id: ex_init.c,v 8.9 1993/12/09 19:42:41 bostic Exp $ (Berkeley) $Date: 1993/12/09 19:42:41 $";
12 #include <sys/types.h>
27 ex_screen_copy(orig
, sp
)
30 EX_PRIVATE
*oexp
, *nexp
;
32 /* Create the private ex structure. */
33 CALLOC_RET(orig
, nexp
, EX_PRIVATE
*, 1, sizeof(EX_PRIVATE
));
34 sp
->ex_private
= nexp
;
36 /* Initialize queues. */
37 TAILQ_INIT(&nexp
->tagq
);
38 TAILQ_INIT(&nexp
->tagfq
);
41 nexp
->at_lbuf_set
= 0;
45 nexp
->at_lbuf
= oexp
->at_lbuf
;
46 nexp
->at_lbuf_set
= oexp
->at_lbuf_set
;
48 if (oexp
->lastbcomm
!= NULL
&&
49 (nexp
->lastbcomm
= strdup(oexp
->lastbcomm
)) == NULL
) {
50 msgq(sp
, M_SYSERR
, NULL
);
54 if (ex_tagcopy(orig
, sp
))
58 nexp
->lastcmd
= &cmds
[C_PRINT
];
80 FREE(exp
->ibp
, exp
->ibp_len
);
82 if (exp
->lastbcomm
!= NULL
)
83 FREE(exp
->lastbcomm
, strlen(exp
->lastbcomm
) + 1);
85 FREE(exp
, sizeof(EX_PRIVATE
));
101 * The default address is the last line of the file. If the address
102 * set bit is on for this file, load the address, ensuring that it
105 if (F_ISSET(sp
->frp
, FR_CURSORSET
)) {
106 sp
->lno
= sp
->frp
->lno
;
107 sp
->cno
= sp
->frp
->cno
;
109 if (file_gline(sp
, ep
, sp
->lno
, &len
) == NULL
) {
110 if (file_lline(sp
, ep
, &sp
->lno
))
115 } else if (sp
->cno
>= len
)
118 if (file_lline(sp
, ep
, &sp
->lno
))
125 /* Display the status line. */
126 return (status(sp
, ep
, sp
->lno
, 0));
137 /* Save the cursor location. */
138 sp
->frp
->lno
= sp
->lno
;
139 sp
->frp
->cno
= sp
->cno
;
140 F_SET(sp
->frp
, FR_CURSORSET
);
147 * Handle change of options for vi.
150 ex_optchange(sp
, opt
)
156 return (ex_tagalloc(sp
, O_STR(sp
, O_TAGS
)));