1*e0b8e63eSJohn Marino /*-
2*e0b8e63eSJohn Marino * Copyright (c) 1992, 1993, 1994
3*e0b8e63eSJohn Marino * The Regents of the University of California. All rights reserved.
4*e0b8e63eSJohn Marino * Copyright (c) 1992, 1993, 1994, 1995, 1996
5*e0b8e63eSJohn Marino * Keith Bostic. All rights reserved.
6*e0b8e63eSJohn Marino *
7*e0b8e63eSJohn Marino * See the LICENSE file for redistribution information.
8*e0b8e63eSJohn Marino */
9*e0b8e63eSJohn Marino
10*e0b8e63eSJohn Marino #include "config.h"
11*e0b8e63eSJohn Marino
12*e0b8e63eSJohn Marino #include <sys/types.h>
13*e0b8e63eSJohn Marino #include <sys/queue.h>
14*e0b8e63eSJohn Marino #include <sys/time.h>
15*e0b8e63eSJohn Marino
16*e0b8e63eSJohn Marino #include <bitstring.h>
17*e0b8e63eSJohn Marino #include <limits.h>
18*e0b8e63eSJohn Marino #include <stdio.h>
19*e0b8e63eSJohn Marino #include <string.h>
20*e0b8e63eSJohn Marino
21*e0b8e63eSJohn Marino #include "../common/common.h"
22*e0b8e63eSJohn Marino #include "vi.h"
23*e0b8e63eSJohn Marino
24*e0b8e63eSJohn Marino /*
25*e0b8e63eSJohn Marino * v_zexit -- ZZ
26*e0b8e63eSJohn Marino * Save the file and exit.
27*e0b8e63eSJohn Marino *
28*e0b8e63eSJohn Marino * PUBLIC: int v_zexit(SCR *, VICMD *);
29*e0b8e63eSJohn Marino */
30*e0b8e63eSJohn Marino int
v_zexit(SCR * sp,VICMD * vp)31*e0b8e63eSJohn Marino v_zexit(SCR *sp, VICMD *vp)
32*e0b8e63eSJohn Marino {
33*e0b8e63eSJohn Marino /* Write back any modifications. */
34*e0b8e63eSJohn Marino if (F_ISSET(sp->ep, F_MODIFIED) &&
35*e0b8e63eSJohn Marino file_write(sp, NULL, NULL, NULL, FS_ALL))
36*e0b8e63eSJohn Marino return (1);
37*e0b8e63eSJohn Marino
38*e0b8e63eSJohn Marino /* Check to make sure it's not a temporary file. */
39*e0b8e63eSJohn Marino if (file_m3(sp, 0))
40*e0b8e63eSJohn Marino return (1);
41*e0b8e63eSJohn Marino
42*e0b8e63eSJohn Marino /* Check for more files to edit. */
43*e0b8e63eSJohn Marino if (ex_ncheck(sp, 0))
44*e0b8e63eSJohn Marino return (1);
45*e0b8e63eSJohn Marino
46*e0b8e63eSJohn Marino F_SET(sp, SC_EXIT);
47*e0b8e63eSJohn Marino return (0);
48*e0b8e63eSJohn Marino }
49