Add a 'q' quit command to nvi.

--- /usr/src/contrib/nvi/ex/ex_cmd.c	1997/04/18 23:36:41	1.2
+++ /usr/src/contrib/nvi/ex/ex_cmd.c	2001/05/17 15:48:41
@@ -94,6 +94,11 @@
 	    "b",
 	    "@ [buffer]",
 	    "execute a buffer"},
+/* C_QQUIT */
+	{"QUIT",	ex_quit,	0,
+	    "!",
+	    "Q[UIT][!]",
+	    "exit ex/vi"},
 /* C_APPEND */
 	{"append",	ex_append,	E_ADDR1|E_ADDR_ZERO|E_ADDR_ZERODEF,
 	    "!",
--- /usr/src/contrib/nvi/include/ex_def.h	1997/04/18 23:36:47	1.2
+++ /usr/src/contrib/nvi/include/ex_def.h	2001/05/17 15:52:15
@@ -7,73 +7,74 @@
 #define C_EQUAL 6
 #define C_SHIFTR 7
 #define C_AT 8
-#define C_APPEND 9
-#define C_ABBR 10
-#define C_ARGS 11
-#define C_BG 12
-#define C_CHANGE 13
-#define C_CD 14
-#define C_CHDIR 15
-#define C_COPY 16
-#define C_CSCOPE 17
-#define C_DELETE 18
-#define C_DISPLAY 19
-#define C_EDIT 20
-#define C_EX 21
-#define C_EXUSAGE 22
-#define C_FILE 23
-#define C_FG 24
-#define C_GLOBAL 25
-#define C_HELP 26
-#define C_INSERT 27
-#define C_JOIN 28
-#define C_K 29
-#define C_LIST 30
-#define C_MOVE 31
-#define C_MARK 32
-#define C_MAP 33
-#define C_MKEXRC 34
-#define C_NEXT 35
-#define C_NUMBER 36
-#define C_OPEN 37
-#define C_PRINT 38
-#define C_PERLCMD 39
-#define C_PERLDOCMD 40
-#define C_PRESERVE 41
-#define C_PREVIOUS 42
-#define C_PUT 43
-#define C_QUIT 44
-#define C_READ 45
-#define C_RECOVER 46
-#define C_RESIZE 47
-#define C_REWIND 48
-#define C_RTAG 49
-#define C_SUBSTITUTE 50
-#define C_SCRIPT 51
-#define C_SET 52
-#define C_SHELL 53
-#define C_SOURCE 54
-#define C_STOP 55
-#define C_SUSPEND 56
-#define C_T 57
-#define C_TAG 58
-#define C_TAGNEXT 59
-#define C_TAGPOP 60
-#define C_TAGPREV 61
-#define C_TAGTOP 62
-#define C_TCLCMD 63
-#define C_UNDO 64
-#define C_UNABBREVIATE 65
-#define C_UNMAP 66
-#define C_V 67
-#define C_VERSION 68
-#define C_VISUAL_EX 69
-#define C_VISUAL_VI 70
-#define C_VIUSAGE 71
-#define C_WRITE 72
-#define C_WN 73
-#define C_WQ 74
-#define C_XIT 75
-#define C_YANK 76
-#define C_Z 77
-#define C_SUBTILDE 78
+#define C_QQUIT 9
+#define C_APPEND 10
+#define C_ABBR 11
+#define C_ARGS 12
+#define C_BG 13
+#define C_CHANGE 14
+#define C_CD 15
+#define C_CHDIR 16
+#define C_COPY 17
+#define C_CSCOPE 18
+#define C_DELETE 19
+#define C_DISPLAY 20
+#define C_EDIT 21
+#define C_EX 22
+#define C_EXUSAGE 23
+#define C_FILE 24
+#define C_FG 25
+#define C_GLOBAL 26
+#define C_HELP 27
+#define C_INSERT 28
+#define C_JOIN 29
+#define C_K 30
+#define C_LIST 31
+#define C_MOVE 32
+#define C_MARK 33
+#define C_MAP 34
+#define C_MKEXRC 35
+#define C_NEXT 36
+#define C_NUMBER 37
+#define C_OPEN 38
+#define C_PRINT 39
+#define C_PERLCMD 40
+#define C_PERLDOCMD 41
+#define C_PRESERVE 42
+#define C_PREVIOUS 43
+#define C_PUT 44
+#define C_QUIT 45
+#define C_READ 46
+#define C_RECOVER 47
+#define C_RESIZE 48
+#define C_REWIND 49
+#define C_RTAG 50
+#define C_SUBSTITUTE 51
+#define C_SCRIPT 52
+#define C_SET 53
+#define C_SHELL 54
+#define C_SOURCE 55
+#define C_STOP 56
+#define C_SUSPEND 57
+#define C_T 58
+#define C_TAG 59
+#define C_TAGNEXT 60
+#define C_TAGPOP 61
+#define C_TAGPREV 62
+#define C_TAGTOP 63
+#define C_TCLCMD 64
+#define C_UNDO 65
+#define C_UNABBREVIATE 66
+#define C_UNMAP 67
+#define C_V 68
+#define C_VERSION 69
+#define C_VISUAL_EX 70
+#define C_VISUAL_VI 71
+#define C_VIUSAGE 72
+#define C_WRITE 73
+#define C_WN 74
+#define C_WQ 75
+#define C_XIT 76
+#define C_YANK 77
+#define C_Z 78
+#define C_SUBTILDE 79
--- /usr/src/contrib/nvi/include/vi_extern.h	1996/11/01 06:45:31	1.1.1.1
+++ /usr/src/contrib/nvi/include/vi_extern.h	2001/05/17 15:19:22
@@ -108,6 +108,7 @@
 int v_z __P((SCR *, VICMD *));
 int vs_crel __P((SCR *, long));
 int v_zexit __P((SCR *, VICMD *));
+int v_quit __P((SCR *, VICMD *));
 int vi __P((SCR **));
 int vs_line __P((SCR *, SMAP *, size_t *, size_t *));
 int vs_number __P((SCR *));
--- /usr/src/contrib/nvi/vi/v_cmd.c	1996/11/01 06:45:33	1.1.1.1
+++ /usr/src/contrib/nvi/vi/v_cmd.c	2001/05/17 15:08:55
@@ -443,7 +443,9 @@
 	    "[buffer]p",
 	    " p insert after cursor from buffer"},
 /* 161   q */
-	{NULL},
+	{v_quit,	0,
+	    "q",
+	    " q quit"},
 /* 162   r */
 	{v_replace,	V_CNT|V_DOT|VM_RCM_SET,
 	    "[count]r character",
--- /usr/src/usr.bin/vi/Makefile	2001/04/25 11:29:43	1.27.2.2
+++ /usr/src/usr.bin/vi/Makefile	2001/05/17 15:17:49
@@ -136,9 +136,9 @@
 
 # Vi source.
 SRCS+=	getc.c v_at.c v_ch.c v_cmd.c v_delete.c v_ex.c v_increment.c v_init.c \
-	v_itxt.c v_left.c v_mark.c v_match.c v_paragraph.c v_put.c v_redraw.c \
-	v_replace.c v_right.c v_screen.c v_scroll.c v_search.c v_section.c \
-	v_sentence.c v_status.c v_txt.c v_ulcase.c v_undo.c \
+	v_itxt.c v_left.c v_mark.c v_match.c v_paragraph.c v_put.c v_quit.c \
+	v_redraw.c v_replace.c v_right.c v_screen.c v_scroll.c v_search.c \
+	v_section.c v_sentence.c v_status.c v_txt.c v_ulcase.c v_undo.c \
 	v_util.c v_word.c v_xchar.c v_yank.c v_z.c v_zexit.c vi.c
 
 # Vi screen source.
--- /usr/src/contrib/nvi/vi/v_quit.c	Wed Nov 21 17:52:21 2001
+++ /usr/src/contrib/nvi/vi/v_quit.c	Wed Nov 21 17:53:43 2001
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 1992, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1992, 1993, 1994, 1995, 1996
+ *	Keith Bostic.  All rights reserved.
+ *
+ * See the LICENSE file for redistribution information.
+ */
+
+#include "config.h"
+
+#ifndef lint
+static const char sccsid[] = "@(#)v_quit.c	10.1 (Berkeley) 4/27/96";
+#endif /* not lint */
+
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <sys/time.h>
+
+#include <bitstring.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "../common/common.h"
+#include "vi.h"
+
+/*
+ * v_quit -- q
+ *	Quit.
+ *
+ * PUBLIC: int v_quit __P((SCR *, VICMD *));
+ */
+int
+v_quit(sp, vp)
+	SCR *sp;
+	VICMD *vp;
+{
+	/* Check for file modifications, or more files to edit. */
+	if (file_m2(sp, 0) || ex_ncheck(sp, 0))
+		return (1);
+
+	F_SET(sp, SC_EXIT);
+	return (0);
+}
