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: v_init.c,v 8.16 1993/12/09 19:43:13 bostic Exp $ (Berkeley) $Date: 1993/12/09 19:43:13 $";
12 #include <sys/types.h>
27 v_screen_copy(orig
, sp
)
30 VI_PRIVATE
*ovip
, *nvip
;
32 /* Create the private vi structure. */
33 CALLOC_RET(orig
, nvip
, VI_PRIVATE
*, 1, sizeof(VI_PRIVATE
));
34 sp
->vi_private
= nvip
;
37 nvip
->inc_lastch
= '+';
38 nvip
->inc_lastval
= 1;
42 /* User can replay the last input, but nothing else. */
43 if (ovip
->rep_len
!= 0) {
44 MALLOC(orig
, nvip
->rep
, char *, ovip
->rep_len
);
45 if (nvip
->rep
!= NULL
) {
46 memmove(nvip
->rep
, ovip
->rep
, ovip
->rep_len
);
47 nvip
->rep_len
= ovip
->rep_len
;
51 nvip
->inc_lastch
= ovip
->inc_lastch
;
52 nvip
->inc_lastval
= ovip
->inc_lastval
;
54 if (ovip
->paragraph
!= NULL
&&
55 (nvip
->paragraph
= strdup(ovip
->paragraph
)) == NULL
) {
56 msgq(sp
, M_SYSERR
, NULL
);
76 FREE(vip
->rep
, vip
->rep_len
);
78 if (vip
->paragraph
!= NULL
)
79 FREE(vip
->paragraph
, vip
->paragraph_len
);
81 FREE(vip
, sizeof(VI_PRIVATE
));
97 * The default address is line 1, column 0. If the address set
98 * bit is on for this file, load the address, ensuring that it
101 if (F_ISSET(sp
->frp
, FR_CURSORSET
)) {
102 sp
->lno
= sp
->frp
->lno
;
103 sp
->cno
= sp
->frp
->cno
;
105 if (file_gline(sp
, ep
, sp
->lno
, &len
) == NULL
) {
106 if (sp
->lno
!= 1 || sp
->cno
!= 0) {
107 if (file_lline(sp
, ep
, &sp
->lno
))
113 } else if (sp
->cno
>= len
)
120 if (O_ISSET(sp
, O_COMMENT
) && v_comment(sp
, ep
))
124 /* Reset strange attraction. */
128 /* Make ex display to a special function. */
129 if ((sp
->stdfp
= fwopen(sp
, sp
->s_ex_write
)) == NULL
) {
130 msgq(sp
, M_SYSERR
, "ex output");
133 #ifdef MAKE_EX_OUTPUT_LINE_BUFFERED
134 (void)setvbuf(sp
->stdfp
, NULL
, _IOLBF
, 0);
137 /* Display the status line. */
138 return (status(sp
, ep
, sp
->lno
, 0));
149 /* Close down ex output file descriptor. */
150 (void)fclose(sp
->stdfp
);
157 * Handle change of options for vi.
167 return (v_buildparagraph(sp
));