fix global code by turning it into two passes
[nvi.git] / vi / v_zexit.c
blob773c0f6c4f1af16375343fba2efe06262c35df00
1 /*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
6 */
8 #ifndef lint
9 static char sccsid[] = "$Id: v_zexit.c,v 8.5 1993/12/10 12:22:17 bostic Exp $ (Berkeley) $Date: 1993/12/10 12:22:17 $";
10 #endif /* not lint */
12 #include <sys/types.h>
14 #include <string.h>
16 #include "vi.h"
17 #include "excmd.h"
18 #include "vcmd.h"
21 * v_exit -- ZZ
22 * Save the file and exit.
24 int
25 v_exit(sp, ep, vp, fm, tm, rp)
26 SCR *sp;
27 EXF *ep;
28 VICMDARG *vp;
29 MARK *fm, *tm, *rp;
31 if (F_ISSET(ep, F_MODIFIED) &&
32 file_write(sp, ep, NULL, NULL, NULL, FS_ALL))
33 return (1);
36 * !!!
37 * Historic practice: quit! or two quit's done in succession
38 * (where ZZ counts as a quit) didn't check for other files.
40 * Also check for related screens; if they exist, quit, the
41 * user will get the message on the last screen.
43 if (sp->ccnt != sp->q_ccnt + 1 &&
44 ep->refcnt <= 1 && file_unedited(sp) != NULL) {
45 sp->q_ccnt = sp->ccnt;
46 msgq(sp, M_ERR,
47 "More files to edit; use \":n\" to go to the next file");
48 return (1);
51 F_SET(sp, S_EXIT);
52 return (0);