NFS - Fix panic if the readdir base offset is beyond the directory EOF
[dragonfly.git] / contrib / nvi / vi / v_zexit.c
blob3e454caa5beab593f012d0f7fe954333418d7413
1 /*-
2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1992, 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
8 */
10 #include "config.h"
12 #ifndef lint
13 static const char sccsid[] = "@(#)v_zexit.c 10.6 (Berkeley) 4/27/96";
14 #endif /* not lint */
16 #include <sys/types.h>
17 #include <sys/queue.h>
18 #include <sys/time.h>
20 #include <bitstring.h>
21 #include <limits.h>
22 #include <stdio.h>
23 #include <string.h>
25 #include "../common/common.h"
26 #include "vi.h"
29 * v_zexit -- ZZ
30 * Save the file and exit.
32 * PUBLIC: int v_zexit __P((SCR *, VICMD *));
34 int
35 v_zexit(sp, vp)
36 SCR *sp;
37 VICMD *vp;
39 /* Write back any modifications. */
40 if (F_ISSET(sp->ep, F_MODIFIED) &&
41 file_write(sp, NULL, NULL, NULL, FS_ALL))
42 return (1);
44 /* Check to make sure it's not a temporary file. */
45 if (file_m3(sp, 0))
46 return (1);
48 /* Check for more files to edit. */
49 if (ex_ncheck(sp, 0))
50 return (1);
52 F_SET(sp, SC_EXIT);
53 return (0);