xref: /openbsd/usr.bin/vi/ex/ex_quit.c (revision 3d8817e4)
1 /*	$OpenBSD: ex_quit.c,v 1.4 2009/10/27 23:59:47 deraadt Exp $	*/
2 
3 /*-
4  * Copyright (c) 1992, 1993, 1994
5  *	The Regents of the University of California.  All rights reserved.
6  * Copyright (c) 1992, 1993, 1994, 1995, 1996
7  *	Keith Bostic.  All rights reserved.
8  *
9  * See the LICENSE file for redistribution information.
10  */
11 
12 #include "config.h"
13 
14 #include <sys/types.h>
15 #include <sys/queue.h>
16 
17 #include <bitstring.h>
18 #include <limits.h>
19 #include <stdio.h>
20 
21 #include "../common/common.h"
22 
23 /*
24  * ex_quit -- :quit[!]
25  *	Quit.
26  *
27  * PUBLIC: int ex_quit(SCR *, EXCMD *);
28  */
29 int
30 ex_quit(sp, cmdp)
31 	SCR *sp;
32 	EXCMD *cmdp;
33 {
34 	int force;
35 
36 	force = FL_ISSET(cmdp->iflags, E_C_FORCE);
37 
38 	/* Check for file modifications, or more files to edit. */
39 	if (file_m2(sp, force) || ex_ncheck(sp, force))
40 		return (1);
41 
42 	F_SET(sp, force ? SC_EXIT_FORCE : SC_EXIT);
43 	return (0);
44 }
45