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.15 1993/11/13 18:01:36 bostic Exp $ (Berkeley) $Date: 1993/11/13 18:01:36 $";
12 #include <sys/types.h>
27 v_screen_copy(orig
, sp
)
30 VI_PRIVATE
*ovip
, *nvip
;
32 /* Create the private vi structure. */
33 if ((sp
->vi_private
= nvip
= malloc(sizeof(VI_PRIVATE
))) == NULL
)
35 memset(nvip
, 0, sizeof(VI_PRIVATE
));
38 nvip
->inc_lastch
= '+';
39 nvip
->inc_lastval
= 1;
43 /* User can replay the last input, but nothing else. */
44 if (ovip
->rep_len
!= 0)
45 if ((nvip
->rep
= malloc(ovip
->rep_len
)) == NULL
)
48 memmove(nvip
->rep
, ovip
->rep
, ovip
->rep_len
);
49 nvip
->rep_len
= ovip
->rep_len
;
52 nvip
->inc_lastch
= ovip
->inc_lastch
;
53 nvip
->inc_lastval
= ovip
->inc_lastval
;
55 if (ovip
->paragraph
!= NULL
&&
56 (nvip
->paragraph
= strdup(ovip
->paragraph
)) == NULL
) {
57 mem
: msgq(sp
, M_SYSERR
, NULL
);
77 FREE(vip
->rep
, vip
->rep_len
);
79 if (vip
->paragraph
!= NULL
)
80 FREE(vip
->paragraph
, vip
->paragraph_len
);
82 FREE(vip
, sizeof(VI_PRIVATE
));
98 * The default address is line 1, column 0. If the address set
99 * bit is on for this file, load the address, ensuring that it
102 if (F_ISSET(sp
->frp
, FR_CURSORSET
)) {
103 sp
->lno
= sp
->frp
->lno
;
104 sp
->cno
= sp
->frp
->cno
;
106 if (file_gline(sp
, ep
, sp
->lno
, &len
) == NULL
) {
107 if (sp
->lno
!= 1 || sp
->cno
!= 0) {
108 if (file_lline(sp
, ep
, &sp
->lno
))
114 } else if (sp
->cno
>= len
)
121 if (O_ISSET(sp
, O_COMMENT
) && v_comment(sp
, ep
))
125 /* Reset strange attraction. */
129 /* Make ex display to a special function. */
130 if ((sp
->stdfp
= fwopen(sp
, sp
->s_ex_write
)) == NULL
) {
131 msgq(sp
, M_SYSERR
, "ex output");
134 #ifdef MAKE_EX_OUTPUT_LINE_BUFFERED
135 (void)setvbuf(sp
->stdfp
, NULL
, _IOLBF
, 0);
138 /* Display the status line. */
139 return (status(sp
, ep
, sp
->lno
, 0));
150 /* Close down ex output file descriptor. */
151 (void)fclose(sp
->stdfp
);
158 * Handle change of options for vi.
168 return (v_buildparagraph(sp
));