Merge from vendor branch LIBSTDC++:
[dragonfly.git] / contrib / nvi / ex / ex_stop.c
1 /*-
2  * Copyright (c) 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 #ifndef lint
13 static const char sccsid[] = "@(#)ex_stop.c     10.10 (Berkeley) 3/6/96";
14 #endif /* not lint */
15
16 #include <sys/types.h>
17 #include <sys/queue.h>
18
19 #include <bitstring.h>
20 #include <errno.h>
21 #include <limits.h>
22 #include <stdio.h>
23 #include <string.h>
24 #include <unistd.h>
25
26 #include "../common/common.h"
27
28 /*
29  * ex_stop -- :stop[!]
30  *            :suspend[!]
31  *      Suspend execution.
32  *
33  * PUBLIC: int ex_stop __P((SCR *, EXCMD *));
34  */
35 int
36 ex_stop(sp, cmdp)
37         SCR *sp;
38         EXCMD *cmdp;
39 {
40         int allowed;
41
42         /* For some strange reason, the force flag turns off autowrite. */
43         if (!FL_ISSET(cmdp->iflags, E_C_FORCE) && file_aw(sp, FS_ALL))
44                 return (1);
45
46         if (sp->gp->scr_suspend(sp, &allowed))
47                 return (1);
48         if (!allowed)
49                 ex_emsg(sp, NULL, EXM_NOSUSPEND);
50         return (0);
51 }