xref: /freebsd/contrib/nvi/ex/ex_quit.c (revision 911f0260390e18cf85f3dbf2c719b593efdc1e3c)
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.
6  *
7  * See the LICENSE file for redistribution information.
8  */
9 
10 #include "config.h"
11 
12 #include <sys/types.h>
13 #include <sys/queue.h>
14 #include <sys/time.h>
15 
16 #include <bitstring.h>
17 #include <limits.h>
18 #include <stdio.h>
19 
20 #include "../common/common.h"
21 
22 /*
23  * ex_quit -- :quit[!]
24  *	Quit.
25  *
26  * PUBLIC: int ex_quit(SCR *, EXCMD *);
27  */
28 int
29 ex_quit(SCR *sp, EXCMD *cmdp)
30 {
31 	int force;
32 
33 	force = FL_ISSET(cmdp->iflags, E_C_FORCE);
34 
35 	/* Check for file modifications, or more files to edit. */
36 	if (file_m2(sp, force) || ex_ncheck(sp, force))
37 		return (1);
38 
39 	F_SET(sp, force ? SC_EXIT_FORCE : SC_EXIT);
40 	return (0);
41 }
42