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.8 1993/11/18 08:17:43 bostic Exp $ (Berkeley) $Date: 1993/11/18 08:17:43 $";
12 #include <sys/types.h>
27 ex_screen_copy(orig
, sp
)
30 EX_PRIVATE
*oexp
, *nexp
;
32 /* Create the private ex structure. */
33 if ((sp
->ex_private
= nexp
= malloc(sizeof(EX_PRIVATE
))) == NULL
)
35 memset(nexp
, 0, sizeof(EX_PRIVATE
));
37 /* Initialize queues. */
38 TAILQ_INIT(&nexp
->tagq
);
39 TAILQ_INIT(&nexp
->tagfq
);
42 nexp
->at_lbuf_set
= 0;
46 nexp
->at_lbuf
= oexp
->at_lbuf
;
47 nexp
->at_lbuf_set
= oexp
->at_lbuf_set
;
49 if (oexp
->lastbcomm
!= NULL
&&
50 (nexp
->lastbcomm
= strdup(oexp
->lastbcomm
)) == NULL
) {
51 mem
: msgq(sp
, M_SYSERR
, NULL
);
55 if (ex_tagcopy(orig
, sp
))
59 nexp
->lastcmd
= &cmds
[C_PRINT
];
81 FREE(exp
->ibp
, exp
->ibp_len
);
83 if (exp
->lastbcomm
!= NULL
)
84 FREE(exp
->lastbcomm
, strlen(exp
->lastbcomm
) + 1);
86 FREE(exp
, sizeof(EX_PRIVATE
));
102 * The default address is the last line of the file. If the address
103 * set bit is on for this file, load the address, ensuring that it
106 if (F_ISSET(sp
->frp
, FR_CURSORSET
)) {
107 sp
->lno
= sp
->frp
->lno
;
108 sp
->cno
= sp
->frp
->cno
;
110 if (file_gline(sp
, ep
, sp
->lno
, &len
) == NULL
) {
111 if (file_lline(sp
, ep
, &sp
->lno
))
116 } else if (sp
->cno
>= len
)
119 if (file_lline(sp
, ep
, &sp
->lno
))
126 /* Display the status line. */
127 return (status(sp
, ep
, sp
->lno
, 0));
138 /* Save the cursor location. */
139 sp
->frp
->lno
= sp
->lno
;
140 sp
->frp
->cno
= sp
->cno
;
141 F_SET(sp
->frp
, FR_CURSORSET
);
148 * Handle change of options for vi.
151 ex_optchange(sp
, opt
)
157 return (ex_tagalloc(sp
, O_STR(sp
, O_TAGS
)));