xref: /titanic_51/usr/src/cmd/vi/port/ex_cmds.c (revision 23a1ccea6aac035f084a7a4cdc968687d1b02daf)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
568c92b9fScf46844  * Common Development and Distribution License (the "License").
668c92b9fScf46844  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21*23a1cceaSRoger A. Faulkner 
22ec427229Sceastha /*
23*23a1cceaSRoger A. Faulkner  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24ec427229Sceastha  */
25ec427229Sceastha 
267c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
277c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate /* Copyright (c) 1981 Regents of the University of California */
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include "ex.h"
337c478bd9Sstevel@tonic-gate #include "ex_argv.h"
347c478bd9Sstevel@tonic-gate #include "ex_temp.h"
357c478bd9Sstevel@tonic-gate #include "ex_tty.h"
367c478bd9Sstevel@tonic-gate #include "ex_vis.h"
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate bool	pflag, nflag;
397c478bd9Sstevel@tonic-gate int	poffset;
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #define	nochng()	lchng = chng
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
457c478bd9Sstevel@tonic-gate  * Main loop for command mode command decoding.
467c478bd9Sstevel@tonic-gate  * A few commands are executed here, but main function
477c478bd9Sstevel@tonic-gate  * is to strip command addresses, do a little address oriented
487c478bd9Sstevel@tonic-gate  * processing and call command routines to do the real work.
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate extern unsigned char *Version;
51f6db9f27Scf46844 void
527c478bd9Sstevel@tonic-gate commands(noprompt, exitoneof)
537c478bd9Sstevel@tonic-gate 	bool noprompt, exitoneof;
547c478bd9Sstevel@tonic-gate {
557c478bd9Sstevel@tonic-gate 	line *addr;
567c478bd9Sstevel@tonic-gate 	int c;
577c478bd9Sstevel@tonic-gate 	int lchng;
587c478bd9Sstevel@tonic-gate 	int given;
597c478bd9Sstevel@tonic-gate 	int seensemi;
607c478bd9Sstevel@tonic-gate 	int cnt;
617c478bd9Sstevel@tonic-gate 	bool hadpr;
627c478bd9Sstevel@tonic-gate 	bool gotfile;
637c478bd9Sstevel@tonic-gate #ifdef XPG4
647c478bd9Sstevel@tonic-gate 	int d;
657c478bd9Sstevel@tonic-gate #endif /* XPG4 */
667c478bd9Sstevel@tonic-gate 	unsigned char *vgetpass();
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate 	resetflav();
697c478bd9Sstevel@tonic-gate 	nochng();
707c478bd9Sstevel@tonic-gate 	for (;;) {
717c478bd9Sstevel@tonic-gate 		if (!firstpat)
727c478bd9Sstevel@tonic-gate 			laste = 0;
737c478bd9Sstevel@tonic-gate 		/*
747c478bd9Sstevel@tonic-gate 		 * If dot at last command
757c478bd9Sstevel@tonic-gate 		 * ended up at zero, advance to one if there is a such.
767c478bd9Sstevel@tonic-gate 		 */
777c478bd9Sstevel@tonic-gate 		if (dot <= zero) {
787c478bd9Sstevel@tonic-gate 			dot = zero;
797c478bd9Sstevel@tonic-gate 			if (dol > zero)
807c478bd9Sstevel@tonic-gate 				dot = one;
817c478bd9Sstevel@tonic-gate 		}
827c478bd9Sstevel@tonic-gate 		shudclob = 0;
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate 		/*
857c478bd9Sstevel@tonic-gate 		 * If autoprint or trailing print flags,
867c478bd9Sstevel@tonic-gate 		 * print the line at the specified offset
877c478bd9Sstevel@tonic-gate 		 * before the next command.
887c478bd9Sstevel@tonic-gate 		 */
897c478bd9Sstevel@tonic-gate 		if ((pflag || lchng != chng && value(vi_AUTOPRINT) &&
907c478bd9Sstevel@tonic-gate 		    !inglobal && !inopen && endline) || poffset != 0) {
917c478bd9Sstevel@tonic-gate 			pflag = 0;
927c478bd9Sstevel@tonic-gate 			nochng();
937c478bd9Sstevel@tonic-gate 			if (dol != zero) {
947c478bd9Sstevel@tonic-gate 				addr1 = addr2 = dot + poffset;
957c478bd9Sstevel@tonic-gate 				poffset = 0;
967c478bd9Sstevel@tonic-gate 				if (addr1 < one || addr1 > dol)
977c478bd9Sstevel@tonic-gate 					error(value(vi_TERSE) ?
987c478bd9Sstevel@tonic-gate 					    gettext("Offset out-of-bounds") :
997c478bd9Sstevel@tonic-gate 					    gettext("Offset after command "
1007c478bd9Sstevel@tonic-gate 						"too large"));
1017c478bd9Sstevel@tonic-gate 				dot = addr1;
1027c478bd9Sstevel@tonic-gate 				setdot1();
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate 				goto print;
1057c478bd9Sstevel@tonic-gate 			}
1067c478bd9Sstevel@tonic-gate 		}
1077c478bd9Sstevel@tonic-gate 		nochng();
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate 		/*
1107c478bd9Sstevel@tonic-gate 		 * Print prompt if appropriate.
1117c478bd9Sstevel@tonic-gate 		 * If not in global flush output first to prevent
1127c478bd9Sstevel@tonic-gate 		 * going into pfast mode unreasonably.
1137c478bd9Sstevel@tonic-gate 		 */
1147c478bd9Sstevel@tonic-gate 		if (inglobal == 0) {
1157c478bd9Sstevel@tonic-gate 			flush();
1167c478bd9Sstevel@tonic-gate 			if (!hush && value(vi_PROMPT) && !globp &&
1177c478bd9Sstevel@tonic-gate 			    !noprompt && endline) {
1187c478bd9Sstevel@tonic-gate 				putchar(':');
1197c478bd9Sstevel@tonic-gate 				hadpr = 1;
1207c478bd9Sstevel@tonic-gate 			}
1217c478bd9Sstevel@tonic-gate 			TSYNC();
1227c478bd9Sstevel@tonic-gate 		}
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate 		/*
1257c478bd9Sstevel@tonic-gate 		 * Gobble up the address.
1267c478bd9Sstevel@tonic-gate 		 * Degenerate addresses yield ".".
1277c478bd9Sstevel@tonic-gate 		 */
1287c478bd9Sstevel@tonic-gate 		addr2 = 0;
1297c478bd9Sstevel@tonic-gate 		given = seensemi = 0;
1307c478bd9Sstevel@tonic-gate 		do {
1317c478bd9Sstevel@tonic-gate 			addr1 = addr2;
1327c478bd9Sstevel@tonic-gate 			addr = address(0);
1337c478bd9Sstevel@tonic-gate 			c = getcd();
1347c478bd9Sstevel@tonic-gate 			if (addr == 0) {
1357c478bd9Sstevel@tonic-gate 				if (c == ',' || c == ';')
1367c478bd9Sstevel@tonic-gate 					addr = dot;
1377c478bd9Sstevel@tonic-gate 				else if (addr1 != 0) {
1387c478bd9Sstevel@tonic-gate 					addr2 = dot;
1397c478bd9Sstevel@tonic-gate 					break;
1407c478bd9Sstevel@tonic-gate 				} else
1417c478bd9Sstevel@tonic-gate 					break;
1427c478bd9Sstevel@tonic-gate 			}
1437c478bd9Sstevel@tonic-gate 			addr2 = addr;
1447c478bd9Sstevel@tonic-gate 			given++;
1457c478bd9Sstevel@tonic-gate 			if (c == ';') {
1467c478bd9Sstevel@tonic-gate 				c = ',';
1477c478bd9Sstevel@tonic-gate 				dot = addr;
1487c478bd9Sstevel@tonic-gate 				seensemi = 1;
1497c478bd9Sstevel@tonic-gate 			}
1507c478bd9Sstevel@tonic-gate 		} while (c == ',');
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate 		if (c == '%') {
1537c478bd9Sstevel@tonic-gate 			/* %: same as 1,$ */
1547c478bd9Sstevel@tonic-gate 			addr1 = one;
1557c478bd9Sstevel@tonic-gate 			addr2 = dol;
1567c478bd9Sstevel@tonic-gate 			given = 2;
1577c478bd9Sstevel@tonic-gate 			c = getchar();
1587c478bd9Sstevel@tonic-gate 		}
1597c478bd9Sstevel@tonic-gate 		if (addr1 == 0)
1607c478bd9Sstevel@tonic-gate 			addr1 = addr2;
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate 		/*
1637c478bd9Sstevel@tonic-gate 		 * eat multiple colons
1647c478bd9Sstevel@tonic-gate 		 */
1657c478bd9Sstevel@tonic-gate 		while (c == ':')
1667c478bd9Sstevel@tonic-gate 			c = getchar();
1677c478bd9Sstevel@tonic-gate 		/*
1687c478bd9Sstevel@tonic-gate 		 * Set command name for special character commands.
1697c478bd9Sstevel@tonic-gate 		 */
1707c478bd9Sstevel@tonic-gate 		tailspec(c);
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate 		/*
1737c478bd9Sstevel@tonic-gate 		 * If called via : escape from open or visual, limit
1747c478bd9Sstevel@tonic-gate 		 * the set of available commands here to save work below.
1757c478bd9Sstevel@tonic-gate 		 */
1767c478bd9Sstevel@tonic-gate 		if (inopen) {
1777c478bd9Sstevel@tonic-gate 			if (c == '\n' || c == '\r' ||
1787c478bd9Sstevel@tonic-gate 			    c == CTRL('d') || c == EOF) {
1797c478bd9Sstevel@tonic-gate 				if (addr2)
1807c478bd9Sstevel@tonic-gate 					dot = addr2;
1817c478bd9Sstevel@tonic-gate 				if (c == EOF)
1827c478bd9Sstevel@tonic-gate 					return;
1837c478bd9Sstevel@tonic-gate 				continue;
1847c478bd9Sstevel@tonic-gate 			}
1857c478bd9Sstevel@tonic-gate 			if (any(c, "o"))
1867c478bd9Sstevel@tonic-gate notinvis:
1877c478bd9Sstevel@tonic-gate 				tailprim(Command, 1, 1);
1887c478bd9Sstevel@tonic-gate 		}
1897c478bd9Sstevel@tonic-gate 		switch (c) {
1907c478bd9Sstevel@tonic-gate 
1917c478bd9Sstevel@tonic-gate 		case 'a':
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate 			switch (peekchar()) {
1947c478bd9Sstevel@tonic-gate 			case 'b':
1957c478bd9Sstevel@tonic-gate /* abbreviate */
1967c478bd9Sstevel@tonic-gate 				tail("abbreviate");
1977c478bd9Sstevel@tonic-gate 				setnoaddr();
1987c478bd9Sstevel@tonic-gate 				mapcmd(0, 1);
1997c478bd9Sstevel@tonic-gate 				anyabbrs = 1;
2007c478bd9Sstevel@tonic-gate 				continue;
2017c478bd9Sstevel@tonic-gate 			case 'r':
2027c478bd9Sstevel@tonic-gate /* args */
2037c478bd9Sstevel@tonic-gate 				tail("args");
2047c478bd9Sstevel@tonic-gate 				setnoaddr();
2057c478bd9Sstevel@tonic-gate 				eol();
2067c478bd9Sstevel@tonic-gate 				pargs();
2077c478bd9Sstevel@tonic-gate 				continue;
2087c478bd9Sstevel@tonic-gate 			}
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate /* append */
2117c478bd9Sstevel@tonic-gate 			if (inopen)
2127c478bd9Sstevel@tonic-gate 				goto notinvis;
2137c478bd9Sstevel@tonic-gate 			tail("append");
2147c478bd9Sstevel@tonic-gate 			setdot();
2157c478bd9Sstevel@tonic-gate 			aiflag = exclam();
2167c478bd9Sstevel@tonic-gate 			donewline();
2177c478bd9Sstevel@tonic-gate 			vmacchng(0);
2187c478bd9Sstevel@tonic-gate 			deletenone();
2197c478bd9Sstevel@tonic-gate 			setin(addr2);
2207c478bd9Sstevel@tonic-gate 			inappend = 1;
2217c478bd9Sstevel@tonic-gate 			(void) append(gettty, addr2);
2227c478bd9Sstevel@tonic-gate 			inappend = 0;
2237c478bd9Sstevel@tonic-gate 			nochng();
2247c478bd9Sstevel@tonic-gate 			continue;
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate 		case 'c':
2277c478bd9Sstevel@tonic-gate 			switch (peekchar()) {
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate /* copy */
2307c478bd9Sstevel@tonic-gate 			case 'o':
2317c478bd9Sstevel@tonic-gate 				tail("copy");
2327c478bd9Sstevel@tonic-gate 				vmacchng(0);
2337c478bd9Sstevel@tonic-gate 				vi_move();
2347c478bd9Sstevel@tonic-gate 				continue;
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate /* crypt */
2377c478bd9Sstevel@tonic-gate 			case 'r':
2387c478bd9Sstevel@tonic-gate 				tail("crypt");
2397c478bd9Sstevel@tonic-gate 				crflag = -1;
2407c478bd9Sstevel@tonic-gate 			ent_crypt:
2417c478bd9Sstevel@tonic-gate 				setnoaddr();
2427c478bd9Sstevel@tonic-gate 				xflag = 1;
2437c478bd9Sstevel@tonic-gate 				if (permflag)
2447c478bd9Sstevel@tonic-gate 					(void) crypt_close(perm);
2457c478bd9Sstevel@tonic-gate 				permflag = 1;
2467c478bd9Sstevel@tonic-gate 				if ((kflag = run_setkey(perm,
2477c478bd9Sstevel@tonic-gate 				    (key = vgetpass(
2487c478bd9Sstevel@tonic-gate 					gettext("Enter key:"))))) == -1) {
2497c478bd9Sstevel@tonic-gate 					xflag = 0;
2507c478bd9Sstevel@tonic-gate 					kflag = 0;
2517c478bd9Sstevel@tonic-gate 					crflag = 0;
2527c478bd9Sstevel@tonic-gate 					smerror(gettext("Encryption facility "
2537c478bd9Sstevel@tonic-gate 						    "not available\n"));
2547c478bd9Sstevel@tonic-gate 				}
2557c478bd9Sstevel@tonic-gate 				if (kflag == 0)
2567c478bd9Sstevel@tonic-gate 					crflag = 0;
2577c478bd9Sstevel@tonic-gate 				continue;
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate /* cd */
2607c478bd9Sstevel@tonic-gate 			case 'd':
2617c478bd9Sstevel@tonic-gate 				tail("cd");
2627c478bd9Sstevel@tonic-gate 				goto changdir;
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate /* chdir */
2657c478bd9Sstevel@tonic-gate 			case 'h':
2667c478bd9Sstevel@tonic-gate 				ignchar();
2677c478bd9Sstevel@tonic-gate 				if (peekchar() == 'd') {
268f6db9f27Scf46844 					unsigned char *p;
2697c478bd9Sstevel@tonic-gate 					tail2of("chdir");
2707c478bd9Sstevel@tonic-gate changdir:
2717c478bd9Sstevel@tonic-gate 					if (savedfile[0] == '/' ||
2727c478bd9Sstevel@tonic-gate 					    !value(vi_WARN))
2737c478bd9Sstevel@tonic-gate 						(void) exclam();
2747c478bd9Sstevel@tonic-gate 					else
2757c478bd9Sstevel@tonic-gate 						(void) quickly();
2767c478bd9Sstevel@tonic-gate 					if (skipend()) {
2777c478bd9Sstevel@tonic-gate 						p = (unsigned char *)
2787c478bd9Sstevel@tonic-gate 						    getenv("HOME");
2797c478bd9Sstevel@tonic-gate 						if (p == NULL)
2807c478bd9Sstevel@tonic-gate 							error(gettext(
2817c478bd9Sstevel@tonic-gate 								"Home directory"
2827c478bd9Sstevel@tonic-gate 								    /*CSTYLED*/
2837c478bd9Sstevel@tonic-gate 								    " unknown"));
2847c478bd9Sstevel@tonic-gate 					} else
2857c478bd9Sstevel@tonic-gate 						getone(), p = file;
2867c478bd9Sstevel@tonic-gate 					eol();
287f6db9f27Scf46844 					if (chdir((char *)p) < 0)
2887c478bd9Sstevel@tonic-gate 						filioerr(p);
2897c478bd9Sstevel@tonic-gate 					if (savedfile[0] != '/')
2907c478bd9Sstevel@tonic-gate 						edited = 0;
2917c478bd9Sstevel@tonic-gate 					continue;
2927c478bd9Sstevel@tonic-gate 				}
2937c478bd9Sstevel@tonic-gate 				if (inopen)
294f6db9f27Scf46844 					tailprim((unsigned char *)"change",
295f6db9f27Scf46844 					    2, 1);
2967c478bd9Sstevel@tonic-gate 				tail2of("change");
2977c478bd9Sstevel@tonic-gate 				break;
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate 			default:
3007c478bd9Sstevel@tonic-gate 				if (inopen)
3017c478bd9Sstevel@tonic-gate 					goto notinvis;
3027c478bd9Sstevel@tonic-gate 				tail("change");
3037c478bd9Sstevel@tonic-gate 				break;
3047c478bd9Sstevel@tonic-gate 			}
3057c478bd9Sstevel@tonic-gate /* change */
3067c478bd9Sstevel@tonic-gate 			aiflag = exclam();
3077c478bd9Sstevel@tonic-gate #ifdef XPG4ONLY
3087c478bd9Sstevel@tonic-gate 			setcount2();
3097c478bd9Sstevel@tonic-gate 			donewline();
3107c478bd9Sstevel@tonic-gate #else /* XPG6 and Solaris */
3117c478bd9Sstevel@tonic-gate 			setCNL();
3127c478bd9Sstevel@tonic-gate #endif /* XPG4ONLY */
3137c478bd9Sstevel@tonic-gate 			vmacchng(0);
3147c478bd9Sstevel@tonic-gate 			setin(addr1);
315f6db9f27Scf46844 			(void) delete(0);
3167c478bd9Sstevel@tonic-gate 			inappend = 1;
3177c478bd9Sstevel@tonic-gate 			if (append(gettty, addr1 - 1) == 0) {
3187c478bd9Sstevel@tonic-gate #ifdef XPG4
3197c478bd9Sstevel@tonic-gate 				/*
3207c478bd9Sstevel@tonic-gate 				 * P2003.2/D9:5.10.7.2.4, p. 646,
3217c478bd9Sstevel@tonic-gate 				 * assertion 214(A). If nothing changed,
3227c478bd9Sstevel@tonic-gate 				 * set dot to the line preceding the lines
3237c478bd9Sstevel@tonic-gate 				 * to be changed.
3247c478bd9Sstevel@tonic-gate 				 */
3257c478bd9Sstevel@tonic-gate 				dot = addr1 - 1;
3267c478bd9Sstevel@tonic-gate #else /* XPG4 */
3277c478bd9Sstevel@tonic-gate 				dot = addr1;
3287c478bd9Sstevel@tonic-gate #endif /* XPG4 */
3297c478bd9Sstevel@tonic-gate 				if (dot > dol)
3307c478bd9Sstevel@tonic-gate 					dot = dol;
3317c478bd9Sstevel@tonic-gate 			}
3327c478bd9Sstevel@tonic-gate 			inappend = 0;
3337c478bd9Sstevel@tonic-gate 			nochng();
3347c478bd9Sstevel@tonic-gate 			continue;
3357c478bd9Sstevel@tonic-gate 
3367c478bd9Sstevel@tonic-gate /* delete */
3377c478bd9Sstevel@tonic-gate 		case 'd':
3387c478bd9Sstevel@tonic-gate 			/*
3397c478bd9Sstevel@tonic-gate 			 * Caution: dp and dl have special meaning already.
3407c478bd9Sstevel@tonic-gate 			 */
3417c478bd9Sstevel@tonic-gate 			tail("delete");
3427c478bd9Sstevel@tonic-gate 			c = cmdreg();
3437c478bd9Sstevel@tonic-gate #ifdef XPG4ONLY
3447c478bd9Sstevel@tonic-gate 			setcount2();
3457c478bd9Sstevel@tonic-gate 			donewline();
3467c478bd9Sstevel@tonic-gate #else /* XPG6 and Solaris */
3477c478bd9Sstevel@tonic-gate 			setCNL();
3487c478bd9Sstevel@tonic-gate #endif /* XPG4ONLY */
3497c478bd9Sstevel@tonic-gate 			vmacchng(0);
3507c478bd9Sstevel@tonic-gate 			if (c)
351f6db9f27Scf46844 				(void) YANKreg(c);
352f6db9f27Scf46844 			(void) delete(0);
3537c478bd9Sstevel@tonic-gate 			appendnone();
3547c478bd9Sstevel@tonic-gate 			continue;
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate /* edit */
3577c478bd9Sstevel@tonic-gate /* ex */
3587c478bd9Sstevel@tonic-gate 		case 'e':
3597c478bd9Sstevel@tonic-gate 			if (crflag == 2 || crflag == -2)
3607c478bd9Sstevel@tonic-gate 				crflag = -1;
3617c478bd9Sstevel@tonic-gate 			tail(peekchar() == 'x' ? "ex" : "edit");
3627c478bd9Sstevel@tonic-gate editcmd:
3637c478bd9Sstevel@tonic-gate 			if (!exclam() && chng)
3647c478bd9Sstevel@tonic-gate 				c = 'E';
3657c478bd9Sstevel@tonic-gate 			gotfile = 0;
3667c478bd9Sstevel@tonic-gate 			if (c == 'E') {
3677c478bd9Sstevel@tonic-gate 				if (inopen && !value(vi_AUTOWRITE)) {
3687c478bd9Sstevel@tonic-gate 					filename(c);
3697c478bd9Sstevel@tonic-gate 					gotfile = 1;
3707c478bd9Sstevel@tonic-gate 				}
3717c478bd9Sstevel@tonic-gate 				ungetchar(lastchar());
3727c478bd9Sstevel@tonic-gate 				if (!exclam()) {
3737c478bd9Sstevel@tonic-gate 					ckaw();
3747c478bd9Sstevel@tonic-gate 					if (chng && dol > zero) {
3757c478bd9Sstevel@tonic-gate 						xchng = 0;
3767c478bd9Sstevel@tonic-gate 						error(value(vi_TERSE) ?
3777c478bd9Sstevel@tonic-gate 						    gettext("No write") :
3787c478bd9Sstevel@tonic-gate 						    gettext("No write since "
3797c478bd9Sstevel@tonic-gate 							"last change (:%s! "
3807c478bd9Sstevel@tonic-gate 							"overrides)"),
3817c478bd9Sstevel@tonic-gate 						    Command);
3827c478bd9Sstevel@tonic-gate 					}
3837c478bd9Sstevel@tonic-gate 				}
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate 			}
3867c478bd9Sstevel@tonic-gate 			if (gotfile == 0)
3877c478bd9Sstevel@tonic-gate 				filename(c);
3887c478bd9Sstevel@tonic-gate 			setnoaddr();
3897c478bd9Sstevel@tonic-gate doecmd:
3907c478bd9Sstevel@tonic-gate 			init();
3917c478bd9Sstevel@tonic-gate 			addr2 = zero;
3927c478bd9Sstevel@tonic-gate 			laste++;
3937c478bd9Sstevel@tonic-gate 			sync();
3947c478bd9Sstevel@tonic-gate 			rop(c);
3957c478bd9Sstevel@tonic-gate 			nochng();
3967c478bd9Sstevel@tonic-gate 			continue;
3977c478bd9Sstevel@tonic-gate 
3987c478bd9Sstevel@tonic-gate /* file */
3997c478bd9Sstevel@tonic-gate 		case 'f':
4007c478bd9Sstevel@tonic-gate 			tail("file");
4017c478bd9Sstevel@tonic-gate 			setnoaddr();
4027c478bd9Sstevel@tonic-gate 			filename(c);
4037c478bd9Sstevel@tonic-gate 			noonl();
4047c478bd9Sstevel@tonic-gate /*
4057c478bd9Sstevel@tonic-gate  *			synctmp();
4067c478bd9Sstevel@tonic-gate  */
4077c478bd9Sstevel@tonic-gate 			continue;
4087c478bd9Sstevel@tonic-gate 
4097c478bd9Sstevel@tonic-gate /* global */
4107c478bd9Sstevel@tonic-gate 		case 'g':
4117c478bd9Sstevel@tonic-gate 			tail("global");
4127c478bd9Sstevel@tonic-gate 			global(!exclam());
4137c478bd9Sstevel@tonic-gate 			nochng();
4147c478bd9Sstevel@tonic-gate 			continue;
4157c478bd9Sstevel@tonic-gate 
4167c478bd9Sstevel@tonic-gate /* insert */
4177c478bd9Sstevel@tonic-gate 		case 'i':
4187c478bd9Sstevel@tonic-gate 			if (inopen)
4197c478bd9Sstevel@tonic-gate 				goto notinvis;
4207c478bd9Sstevel@tonic-gate 			tail("insert");
4217c478bd9Sstevel@tonic-gate 			setdot();
4227c478bd9Sstevel@tonic-gate 			nonzero();
4237c478bd9Sstevel@tonic-gate 			aiflag = exclam();
4247c478bd9Sstevel@tonic-gate 			donewline();
4257c478bd9Sstevel@tonic-gate 			vmacchng(0);
4267c478bd9Sstevel@tonic-gate 			deletenone();
4277c478bd9Sstevel@tonic-gate 			setin(addr2);
4287c478bd9Sstevel@tonic-gate 			inappend = 1;
4297c478bd9Sstevel@tonic-gate 			(void) append(gettty, addr2 - 1);
4307c478bd9Sstevel@tonic-gate 			inappend = 0;
4317c478bd9Sstevel@tonic-gate 			if (dot == zero && dol > zero)
4327c478bd9Sstevel@tonic-gate 				dot = one;
4337c478bd9Sstevel@tonic-gate 			nochng();
4347c478bd9Sstevel@tonic-gate 			continue;
4357c478bd9Sstevel@tonic-gate 
4367c478bd9Sstevel@tonic-gate /* join */
4377c478bd9Sstevel@tonic-gate 		case 'j':
4387c478bd9Sstevel@tonic-gate 			tail("join");
4397c478bd9Sstevel@tonic-gate 			c = exclam();
4407c478bd9Sstevel@tonic-gate 			setcount();
4417c478bd9Sstevel@tonic-gate 			nonzero();
4427c478bd9Sstevel@tonic-gate 			donewline();
4437c478bd9Sstevel@tonic-gate 			vmacchng(0);
4447c478bd9Sstevel@tonic-gate #ifdef XPG4ONLY
4457c478bd9Sstevel@tonic-gate 			/*
4467c478bd9Sstevel@tonic-gate 			 * if no count was specified, addr1 == addr2. if only
4477c478bd9Sstevel@tonic-gate 			 * 1 range arg was specified, inc addr2 to allow
4487c478bd9Sstevel@tonic-gate 			 * joining of the next line.
4497c478bd9Sstevel@tonic-gate 			 */
4507c478bd9Sstevel@tonic-gate 			if (given < 2 && (addr1 == addr2) && (addr2 != dol))
4517c478bd9Sstevel@tonic-gate 				addr2++;
4527c478bd9Sstevel@tonic-gate 
4537c478bd9Sstevel@tonic-gate #else /* XPG6 and Solaris */
4547c478bd9Sstevel@tonic-gate 			if (given < 2 && addr2 != dol)
4557c478bd9Sstevel@tonic-gate 				addr2++;
4567c478bd9Sstevel@tonic-gate #endif /* XPG4ONLY */
457f6db9f27Scf46844 			(void) join(c);
4587c478bd9Sstevel@tonic-gate 			continue;
4597c478bd9Sstevel@tonic-gate 
4607c478bd9Sstevel@tonic-gate /* k */
4617c478bd9Sstevel@tonic-gate 		case 'k':
4627c478bd9Sstevel@tonic-gate casek:
4637c478bd9Sstevel@tonic-gate 			pastwh();
4647c478bd9Sstevel@tonic-gate 			c = getchar();
4657c478bd9Sstevel@tonic-gate 			if (endcmd(c))
466f6db9f27Scf46844 				serror((vi_TERSE) ?
467f6db9f27Scf46844 				    (unsigned char *)gettext("Mark what?") :
468f6db9f27Scf46844 				    (unsigned char *)
4697c478bd9Sstevel@tonic-gate 				    gettext("%s requires following "
4707c478bd9Sstevel@tonic-gate 				    "letter"), Command);
4717c478bd9Sstevel@tonic-gate 			donewline();
4727c478bd9Sstevel@tonic-gate 			if (!islower(c))
4737c478bd9Sstevel@tonic-gate 				error((vi_TERSE) ? gettext("Bad mark") :
4747c478bd9Sstevel@tonic-gate 					gettext("Mark must specify a letter"));
4757c478bd9Sstevel@tonic-gate 			setdot();
4767c478bd9Sstevel@tonic-gate 			nonzero();
4777c478bd9Sstevel@tonic-gate 			names[c - 'a'] = *addr2 &~ 01;
4787c478bd9Sstevel@tonic-gate 			anymarks = 1;
4797c478bd9Sstevel@tonic-gate 			continue;
4807c478bd9Sstevel@tonic-gate 
4817c478bd9Sstevel@tonic-gate /* list */
4827c478bd9Sstevel@tonic-gate 		case 'l':
4837c478bd9Sstevel@tonic-gate 			tail("list");
4847c478bd9Sstevel@tonic-gate #ifdef XPG4ONLY
4857c478bd9Sstevel@tonic-gate 			setcount2();
4867c478bd9Sstevel@tonic-gate 			donewline();
4877c478bd9Sstevel@tonic-gate #else /* XPG6 and Solaris */
4887c478bd9Sstevel@tonic-gate 			setCNL();
4897c478bd9Sstevel@tonic-gate #endif /* XPG4ONLY */
4907c478bd9Sstevel@tonic-gate 			(void) setlist(1);
4917c478bd9Sstevel@tonic-gate 			pflag = 0;
4927c478bd9Sstevel@tonic-gate 			goto print;
4937c478bd9Sstevel@tonic-gate 
4947c478bd9Sstevel@tonic-gate 		case 'm':
4957c478bd9Sstevel@tonic-gate 			if (peekchar() == 'a') {
4967c478bd9Sstevel@tonic-gate 				ignchar();
4977c478bd9Sstevel@tonic-gate 				if (peekchar() == 'p') {
4987c478bd9Sstevel@tonic-gate /* map */
4997c478bd9Sstevel@tonic-gate 					tail2of("map");
5007c478bd9Sstevel@tonic-gate 					setnoaddr();
5017c478bd9Sstevel@tonic-gate 					mapcmd(0, 0);
5027c478bd9Sstevel@tonic-gate 					continue;
5037c478bd9Sstevel@tonic-gate 				}
5047c478bd9Sstevel@tonic-gate /* mark */
5057c478bd9Sstevel@tonic-gate 				tail2of("mark");
5067c478bd9Sstevel@tonic-gate 				goto casek;
5077c478bd9Sstevel@tonic-gate 			}
5087c478bd9Sstevel@tonic-gate /* move */
5097c478bd9Sstevel@tonic-gate 			tail("move");
5107c478bd9Sstevel@tonic-gate 			vmacchng(0);
5117c478bd9Sstevel@tonic-gate 			vi_move();
5127c478bd9Sstevel@tonic-gate 			continue;
5137c478bd9Sstevel@tonic-gate 
5147c478bd9Sstevel@tonic-gate 		case 'n':
5157c478bd9Sstevel@tonic-gate 			if (peekchar() == 'u') {
5167c478bd9Sstevel@tonic-gate 				tail("number");
5177c478bd9Sstevel@tonic-gate 				goto numberit;
5187c478bd9Sstevel@tonic-gate 			}
5197c478bd9Sstevel@tonic-gate /* next */
5207c478bd9Sstevel@tonic-gate 			tail("next");
5217c478bd9Sstevel@tonic-gate 			setnoaddr();
5227c478bd9Sstevel@tonic-gate 			if (!exclam()) {
5237c478bd9Sstevel@tonic-gate 				ckaw();
5247c478bd9Sstevel@tonic-gate 				if (chng && dol > zero) {
5257c478bd9Sstevel@tonic-gate 					xchng = 0;
5267c478bd9Sstevel@tonic-gate 					error(value(vi_TERSE) ?
5277c478bd9Sstevel@tonic-gate 					    gettext("No write") :
5287c478bd9Sstevel@tonic-gate 					    gettext("No write since last "
5297c478bd9Sstevel@tonic-gate 						"change (:%s! overrides)"),
5307c478bd9Sstevel@tonic-gate 					    Command);
5317c478bd9Sstevel@tonic-gate 				}
5327c478bd9Sstevel@tonic-gate 			}
5337c478bd9Sstevel@tonic-gate 
5347c478bd9Sstevel@tonic-gate 			if (getargs())
5357c478bd9Sstevel@tonic-gate 				makargs();
5367c478bd9Sstevel@tonic-gate 			next();
5377c478bd9Sstevel@tonic-gate 			c = 'e';
5387c478bd9Sstevel@tonic-gate 			filename(c);
5397c478bd9Sstevel@tonic-gate 			goto doecmd;
5407c478bd9Sstevel@tonic-gate 
5417c478bd9Sstevel@tonic-gate /* open */
5427c478bd9Sstevel@tonic-gate 		case 'o':
5437c478bd9Sstevel@tonic-gate 			tail("open");
5447c478bd9Sstevel@tonic-gate 			oop();
5457c478bd9Sstevel@tonic-gate 			pflag = 0;
5467c478bd9Sstevel@tonic-gate 			nochng();
5477c478bd9Sstevel@tonic-gate 			continue;
5487c478bd9Sstevel@tonic-gate 
5497c478bd9Sstevel@tonic-gate 		case 'p':
5507c478bd9Sstevel@tonic-gate 		case 'P':
5517c478bd9Sstevel@tonic-gate 			switch (peekchar()) {
5527c478bd9Sstevel@tonic-gate #ifdef TAG_STACK
5537c478bd9Sstevel@tonic-gate /* pop */
5547c478bd9Sstevel@tonic-gate 			case 'o':
5557c478bd9Sstevel@tonic-gate 				tail("pop");
5567c478bd9Sstevel@tonic-gate 				poptag(exclam());
5577c478bd9Sstevel@tonic-gate 				if (!inopen)
5587c478bd9Sstevel@tonic-gate 					lchng = chng - 1;
5597c478bd9Sstevel@tonic-gate 				else
5607c478bd9Sstevel@tonic-gate 					nochng();
5617c478bd9Sstevel@tonic-gate 				continue;
5627c478bd9Sstevel@tonic-gate #endif
5637c478bd9Sstevel@tonic-gate 
5647c478bd9Sstevel@tonic-gate /* put */
5657c478bd9Sstevel@tonic-gate 			case 'u':
5667c478bd9Sstevel@tonic-gate 				tail("put");
5677c478bd9Sstevel@tonic-gate 				setdot();
5687c478bd9Sstevel@tonic-gate 				c = cmdreg();
5697c478bd9Sstevel@tonic-gate 				eol();
5707c478bd9Sstevel@tonic-gate 				vmacchng(0);
5717c478bd9Sstevel@tonic-gate 				if (c)
572f6db9f27Scf46844 					(void) putreg(c);
5737c478bd9Sstevel@tonic-gate 				else
574f6db9f27Scf46844 					(void) put();
5757c478bd9Sstevel@tonic-gate 				continue;
5767c478bd9Sstevel@tonic-gate 
5777c478bd9Sstevel@tonic-gate 			case 'r':
5787c478bd9Sstevel@tonic-gate 				ignchar();
5797c478bd9Sstevel@tonic-gate 				if (peekchar() == 'e') {
5807c478bd9Sstevel@tonic-gate /* preserve */
5817c478bd9Sstevel@tonic-gate 					tail2of("preserve");
5827c478bd9Sstevel@tonic-gate 					eol();
5837c478bd9Sstevel@tonic-gate 					if (preserve() == 0)
5847c478bd9Sstevel@tonic-gate 						error(gettext(
5857c478bd9Sstevel@tonic-gate 						    "Preserve failed!"));
5867c478bd9Sstevel@tonic-gate 					else {
5877c478bd9Sstevel@tonic-gate #ifdef XPG4
5887c478bd9Sstevel@tonic-gate 						/*
5897c478bd9Sstevel@tonic-gate 						 * error() incs errcnt. this is
5907c478bd9Sstevel@tonic-gate 						 * misleading here; and a
5917c478bd9Sstevel@tonic-gate 						 * violation of POSIX. so call
5927c478bd9Sstevel@tonic-gate 						 * noerror() instead.
5937c478bd9Sstevel@tonic-gate 						 * this is for assertion ex:222.
5947c478bd9Sstevel@tonic-gate 						 */
5957c478bd9Sstevel@tonic-gate 						noerror(
5967c478bd9Sstevel@tonic-gate 						    gettext("File preserved."));
5977c478bd9Sstevel@tonic-gate 
5987c478bd9Sstevel@tonic-gate #else /* XPG4 */
5997c478bd9Sstevel@tonic-gate 						error(
6007c478bd9Sstevel@tonic-gate 						    gettext("File preserved."));
6017c478bd9Sstevel@tonic-gate #endif /* XPG4 */
6027c478bd9Sstevel@tonic-gate 					}
6037c478bd9Sstevel@tonic-gate 				}
6047c478bd9Sstevel@tonic-gate 				tail2of("print");
6057c478bd9Sstevel@tonic-gate 				break;
6067c478bd9Sstevel@tonic-gate 
6077c478bd9Sstevel@tonic-gate 			default:
6087c478bd9Sstevel@tonic-gate 				tail("print");
6097c478bd9Sstevel@tonic-gate 				break;
6107c478bd9Sstevel@tonic-gate 			}
6117c478bd9Sstevel@tonic-gate /* print */
6127c478bd9Sstevel@tonic-gate 			setCNL();
6137c478bd9Sstevel@tonic-gate 			pflag = 0;
6147c478bd9Sstevel@tonic-gate print:
6157c478bd9Sstevel@tonic-gate 			nonzero();
6167c478bd9Sstevel@tonic-gate 			if (clear_screen && span() > lines) {
6177c478bd9Sstevel@tonic-gate 				flush1();
6187c478bd9Sstevel@tonic-gate 				vclear();
6197c478bd9Sstevel@tonic-gate 			}
6207c478bd9Sstevel@tonic-gate 			/*
6217c478bd9Sstevel@tonic-gate 			 * poffset is nonzero if trailing + or - flags
6227c478bd9Sstevel@tonic-gate 			 * were given, and in that case we need to
6237c478bd9Sstevel@tonic-gate 			 * adjust dot before printing a line.
6247c478bd9Sstevel@tonic-gate 			 */
6257c478bd9Sstevel@tonic-gate 			if (poffset == 0)
6267c478bd9Sstevel@tonic-gate 				plines(addr1, addr2, 1);
6277c478bd9Sstevel@tonic-gate 			else
6287c478bd9Sstevel@tonic-gate 				dot = addr2;
6297c478bd9Sstevel@tonic-gate 			continue;
6307c478bd9Sstevel@tonic-gate 
6317c478bd9Sstevel@tonic-gate /* quit */
6327c478bd9Sstevel@tonic-gate 		case 'q':
6337c478bd9Sstevel@tonic-gate 			tail("quit");
6347c478bd9Sstevel@tonic-gate 			setnoaddr();
6357c478bd9Sstevel@tonic-gate 			c = quickly();
6367c478bd9Sstevel@tonic-gate 			eol();
6377c478bd9Sstevel@tonic-gate 			if (!c)
6387c478bd9Sstevel@tonic-gate quit:
6397c478bd9Sstevel@tonic-gate 				if (nomore())
6407c478bd9Sstevel@tonic-gate 					continue;
6417c478bd9Sstevel@tonic-gate 			if (inopen) {
6427c478bd9Sstevel@tonic-gate 				vgoto(WECHO, 0);
6437c478bd9Sstevel@tonic-gate 				if (!ateopr())
6447c478bd9Sstevel@tonic-gate 					vnfl();
6457c478bd9Sstevel@tonic-gate 				else {
6467c478bd9Sstevel@tonic-gate 					tostop();
6477c478bd9Sstevel@tonic-gate 				}
6487c478bd9Sstevel@tonic-gate 				flush();
6497c478bd9Sstevel@tonic-gate 				setty(normf);
6507c478bd9Sstevel@tonic-gate 				ixlatctl(1);
6517c478bd9Sstevel@tonic-gate 			}
6527c478bd9Sstevel@tonic-gate 			cleanup(1);
6537c478bd9Sstevel@tonic-gate 			exit(errcnt);
6547c478bd9Sstevel@tonic-gate 
6557c478bd9Sstevel@tonic-gate 		case 'r':
6567c478bd9Sstevel@tonic-gate 			if (peekchar() == 'e') {
6577c478bd9Sstevel@tonic-gate 				ignchar();
6587c478bd9Sstevel@tonic-gate 				switch (peekchar()) {
6597c478bd9Sstevel@tonic-gate 
6607c478bd9Sstevel@tonic-gate /* rewind */
6617c478bd9Sstevel@tonic-gate 				case 'w':
6627c478bd9Sstevel@tonic-gate 					tail2of("rewind");
6637c478bd9Sstevel@tonic-gate 					setnoaddr();
6647c478bd9Sstevel@tonic-gate 					if (!exclam()) {
6657c478bd9Sstevel@tonic-gate 						ckaw();
6667c478bd9Sstevel@tonic-gate 						if (chng && dol > zero)
6677c478bd9Sstevel@tonic-gate 							error((vi_TERSE) ?
6687c478bd9Sstevel@tonic-gate 							    /*CSTYLED*/
6697c478bd9Sstevel@tonic-gate 							    gettext("No write") :
6707c478bd9Sstevel@tonic-gate 							    gettext("No write "
6717c478bd9Sstevel@tonic-gate 								"since last "
6727c478bd9Sstevel@tonic-gate 								"change (:rewi"
6737c478bd9Sstevel@tonic-gate 								/*CSTYLED*/
6747c478bd9Sstevel@tonic-gate 								"nd! overrides)"));
6757c478bd9Sstevel@tonic-gate 					}
6767c478bd9Sstevel@tonic-gate 					eol();
6777c478bd9Sstevel@tonic-gate 					erewind();
6787c478bd9Sstevel@tonic-gate 					next();
6797c478bd9Sstevel@tonic-gate 					c = 'e';
6807c478bd9Sstevel@tonic-gate 					ungetchar(lastchar());
6817c478bd9Sstevel@tonic-gate 					filename(c);
6827c478bd9Sstevel@tonic-gate 					goto doecmd;
6837c478bd9Sstevel@tonic-gate 
6847c478bd9Sstevel@tonic-gate /* recover */
6857c478bd9Sstevel@tonic-gate 				case 'c':
6867c478bd9Sstevel@tonic-gate 					tail2of("recover");
6877c478bd9Sstevel@tonic-gate 					setnoaddr();
6887c478bd9Sstevel@tonic-gate 					c = 'e';
6897c478bd9Sstevel@tonic-gate 					if (!exclam() && chng)
6907c478bd9Sstevel@tonic-gate 						c = 'E';
6917c478bd9Sstevel@tonic-gate 					filename(c);
6927c478bd9Sstevel@tonic-gate 					if (c == 'E') {
6937c478bd9Sstevel@tonic-gate 						ungetchar(lastchar());
6947c478bd9Sstevel@tonic-gate 						(void) quickly();
6957c478bd9Sstevel@tonic-gate 					}
6967c478bd9Sstevel@tonic-gate 					init();
6977c478bd9Sstevel@tonic-gate 					addr2 = zero;
6987c478bd9Sstevel@tonic-gate 					laste++;
6997c478bd9Sstevel@tonic-gate 					sync();
7007c478bd9Sstevel@tonic-gate 					recover();
7017c478bd9Sstevel@tonic-gate 					rop2();
7027c478bd9Sstevel@tonic-gate 					revocer();
7037c478bd9Sstevel@tonic-gate 					if (status == 0)
7047c478bd9Sstevel@tonic-gate 						rop3(c);
7057c478bd9Sstevel@tonic-gate 					if (dol != zero)
7067c478bd9Sstevel@tonic-gate 						change();
7077c478bd9Sstevel@tonic-gate 					nochng();
7087c478bd9Sstevel@tonic-gate 					continue;
7097c478bd9Sstevel@tonic-gate 				}
7107c478bd9Sstevel@tonic-gate 				tail2of("read");
7117c478bd9Sstevel@tonic-gate 			} else
7127c478bd9Sstevel@tonic-gate 				tail("read");
7137c478bd9Sstevel@tonic-gate /* read */
7147c478bd9Sstevel@tonic-gate 			if (crflag == 2 || crflag == -2)
7157c478bd9Sstevel@tonic-gate 			/* restore crflag for new input text */
7167c478bd9Sstevel@tonic-gate 				crflag = -1;
7177c478bd9Sstevel@tonic-gate 			if (savedfile[0] == 0 && dol == zero)
7187c478bd9Sstevel@tonic-gate 				c = 'e';
7197c478bd9Sstevel@tonic-gate 			pastwh();
7207c478bd9Sstevel@tonic-gate 			vmacchng(0);
7217c478bd9Sstevel@tonic-gate 			if (peekchar() == '!') {
7227c478bd9Sstevel@tonic-gate 				setdot();
7237c478bd9Sstevel@tonic-gate 				ignchar();
724ec427229Sceastha 				unix0(0, 1);
725f6db9f27Scf46844 				(void) vi_filter(0);
7267c478bd9Sstevel@tonic-gate 				continue;
7277c478bd9Sstevel@tonic-gate 			}
7287c478bd9Sstevel@tonic-gate 			filename(c);
7297c478bd9Sstevel@tonic-gate 			rop(c);
7307c478bd9Sstevel@tonic-gate 			nochng();
7317c478bd9Sstevel@tonic-gate 			if (inopen && endline && addr1 > zero && addr1 < dol)
7327c478bd9Sstevel@tonic-gate 				dot = addr1 + 1;
7337c478bd9Sstevel@tonic-gate 			continue;
7347c478bd9Sstevel@tonic-gate 
7357c478bd9Sstevel@tonic-gate 		case 's':
7367c478bd9Sstevel@tonic-gate 			switch (peekchar()) {
7377c478bd9Sstevel@tonic-gate 			/*
7387c478bd9Sstevel@tonic-gate 			 * Caution: 2nd char cannot be c, g, or r
7397c478bd9Sstevel@tonic-gate 			 * because these have meaning to substitute.
7407c478bd9Sstevel@tonic-gate 			 */
7417c478bd9Sstevel@tonic-gate 
7427c478bd9Sstevel@tonic-gate /* set */
7437c478bd9Sstevel@tonic-gate 			case 'e':
7447c478bd9Sstevel@tonic-gate 				tail("set");
7457c478bd9Sstevel@tonic-gate 				setnoaddr();
7467c478bd9Sstevel@tonic-gate 				set();
7477c478bd9Sstevel@tonic-gate 				continue;
7487c478bd9Sstevel@tonic-gate 
7497c478bd9Sstevel@tonic-gate /* shell */
7507c478bd9Sstevel@tonic-gate 			case 'h':
7517c478bd9Sstevel@tonic-gate 				tail("shell");
7527c478bd9Sstevel@tonic-gate 				setNAEOL();
7537c478bd9Sstevel@tonic-gate 				vnfl();
754f6db9f27Scf46844 				putpad((unsigned char *)exit_ca_mode);
7557c478bd9Sstevel@tonic-gate 				flush();
7567c478bd9Sstevel@tonic-gate 				resetterm();
7577c478bd9Sstevel@tonic-gate 				unixwt(1, unixex("-i", (char *)0, 0, 0));
7587c478bd9Sstevel@tonic-gate 				vcontin(0);
7597c478bd9Sstevel@tonic-gate 				continue;
7607c478bd9Sstevel@tonic-gate 
7617c478bd9Sstevel@tonic-gate /* source */
7627c478bd9Sstevel@tonic-gate 			case 'o':
7637c478bd9Sstevel@tonic-gate #ifdef notdef
7647c478bd9Sstevel@tonic-gate 				if (inopen)
7657c478bd9Sstevel@tonic-gate 					goto notinvis;
7667c478bd9Sstevel@tonic-gate #endif
7677c478bd9Sstevel@tonic-gate 				tail("source");
7687c478bd9Sstevel@tonic-gate 				setnoaddr();
7697c478bd9Sstevel@tonic-gate 				getone();
7707c478bd9Sstevel@tonic-gate 				eol();
7717c478bd9Sstevel@tonic-gate 				source(file, 0);
7727c478bd9Sstevel@tonic-gate 				continue;
7737c478bd9Sstevel@tonic-gate #ifdef SIGTSTP
7747c478bd9Sstevel@tonic-gate /* stop, suspend */
7757c478bd9Sstevel@tonic-gate 			case 't':
7767c478bd9Sstevel@tonic-gate 				tail("stop");
7777c478bd9Sstevel@tonic-gate 				goto suspend;
7787c478bd9Sstevel@tonic-gate 			case 'u':
7797c478bd9Sstevel@tonic-gate #ifdef XPG4
7807c478bd9Sstevel@tonic-gate 				/*
7817c478bd9Sstevel@tonic-gate 				 * for POSIX, "su" with no other distinguishing
7827c478bd9Sstevel@tonic-gate 				 * characteristics, maps to "s". Re. P1003.D11,
7837c478bd9Sstevel@tonic-gate 				 * 5.10.7.3.
7847c478bd9Sstevel@tonic-gate 				 *
7857c478bd9Sstevel@tonic-gate 				 * so, unless the "su" is followed by a "s" or
7867c478bd9Sstevel@tonic-gate 				 * a "!", we assume that the user means "s".
7877c478bd9Sstevel@tonic-gate 				 */
7887c478bd9Sstevel@tonic-gate 				switch (d = peekchar()) {
7897c478bd9Sstevel@tonic-gate 				case 's':
7907c478bd9Sstevel@tonic-gate 				case '!':
7917c478bd9Sstevel@tonic-gate #endif /* XPG4 */
7927c478bd9Sstevel@tonic-gate 					tail("suspend");
7937c478bd9Sstevel@tonic-gate suspend:
7947c478bd9Sstevel@tonic-gate 					c = exclam();
7957c478bd9Sstevel@tonic-gate 					eol();
7967c478bd9Sstevel@tonic-gate 					if (!c)
7977c478bd9Sstevel@tonic-gate 						ckaw();
7987c478bd9Sstevel@tonic-gate 					onsusp(0);
7997c478bd9Sstevel@tonic-gate 					continue;
8007c478bd9Sstevel@tonic-gate #ifdef XPG4
8017c478bd9Sstevel@tonic-gate 				}
8027c478bd9Sstevel@tonic-gate #endif /* XPG4 */
8037c478bd9Sstevel@tonic-gate #endif
8047c478bd9Sstevel@tonic-gate 
8057c478bd9Sstevel@tonic-gate 			}
8067c478bd9Sstevel@tonic-gate 			/* fall into ... */
8077c478bd9Sstevel@tonic-gate 
8087c478bd9Sstevel@tonic-gate /* & */
8097c478bd9Sstevel@tonic-gate /* ~ */
8107c478bd9Sstevel@tonic-gate /* substitute */
8117c478bd9Sstevel@tonic-gate 		case '&':
8127c478bd9Sstevel@tonic-gate 		case '~':
8137c478bd9Sstevel@tonic-gate 			Command = (unsigned char *)"substitute";
8147c478bd9Sstevel@tonic-gate 			if (c == 's')
8157c478bd9Sstevel@tonic-gate 				tail(Command);
8167c478bd9Sstevel@tonic-gate 			vmacchng(0);
8177c478bd9Sstevel@tonic-gate 			if (!substitute(c))
8187c478bd9Sstevel@tonic-gate 				pflag = 0;
8197c478bd9Sstevel@tonic-gate 			continue;
8207c478bd9Sstevel@tonic-gate 
8217c478bd9Sstevel@tonic-gate /* t */
8227c478bd9Sstevel@tonic-gate 		case 't':
8237c478bd9Sstevel@tonic-gate 			if (peekchar() == 'a') {
82468c92b9fScf46844 				tagflg = 1; /* :tag command */
8257c478bd9Sstevel@tonic-gate 				tail("tag");
8267c478bd9Sstevel@tonic-gate 				tagfind(exclam());
82768c92b9fScf46844 				tagflg = 0;
8287c478bd9Sstevel@tonic-gate 				if (!inopen)
8297c478bd9Sstevel@tonic-gate 					lchng = chng - 1;
8307c478bd9Sstevel@tonic-gate 				else
8317c478bd9Sstevel@tonic-gate 					nochng();
8327c478bd9Sstevel@tonic-gate 				continue;
8337c478bd9Sstevel@tonic-gate 			}
8347c478bd9Sstevel@tonic-gate 			tail("t");
8357c478bd9Sstevel@tonic-gate 			vmacchng(0);
8367c478bd9Sstevel@tonic-gate 			vi_move();
8377c478bd9Sstevel@tonic-gate 			continue;
8387c478bd9Sstevel@tonic-gate 
8397c478bd9Sstevel@tonic-gate 		case 'u':
8407c478bd9Sstevel@tonic-gate 			if (peekchar() == 'n') {
8417c478bd9Sstevel@tonic-gate 				ignchar();
8427c478bd9Sstevel@tonic-gate 				switch (peekchar()) {
8437c478bd9Sstevel@tonic-gate /* unmap */
8447c478bd9Sstevel@tonic-gate 				case 'm':
8457c478bd9Sstevel@tonic-gate 					tail2of("unmap");
8467c478bd9Sstevel@tonic-gate 					setnoaddr();
8477c478bd9Sstevel@tonic-gate 					mapcmd(1, 0);
8487c478bd9Sstevel@tonic-gate 					continue;
8497c478bd9Sstevel@tonic-gate /* unabbreviate */
8507c478bd9Sstevel@tonic-gate 				case 'a':
8517c478bd9Sstevel@tonic-gate 					tail2of("unabbreviate");
8527c478bd9Sstevel@tonic-gate 					setnoaddr();
8537c478bd9Sstevel@tonic-gate 					mapcmd(1, 1);
8547c478bd9Sstevel@tonic-gate 					anyabbrs = 1;
8557c478bd9Sstevel@tonic-gate 					continue;
8567c478bd9Sstevel@tonic-gate 				}
8577c478bd9Sstevel@tonic-gate /* undo */
8587c478bd9Sstevel@tonic-gate 				tail2of("undo");
8597c478bd9Sstevel@tonic-gate 			} else
8607c478bd9Sstevel@tonic-gate 				tail("undo");
8617c478bd9Sstevel@tonic-gate 			setnoaddr();
8627c478bd9Sstevel@tonic-gate 			markDOT();
8637c478bd9Sstevel@tonic-gate 			c = exclam();
8647c478bd9Sstevel@tonic-gate 			donewline();
8657c478bd9Sstevel@tonic-gate 			undo(c);
8667c478bd9Sstevel@tonic-gate 			continue;
8677c478bd9Sstevel@tonic-gate 
8687c478bd9Sstevel@tonic-gate 		case 'v':
8697c478bd9Sstevel@tonic-gate 			switch (peekchar()) {
8707c478bd9Sstevel@tonic-gate 
8717c478bd9Sstevel@tonic-gate 			case 'e':
8727c478bd9Sstevel@tonic-gate /* version */
8737c478bd9Sstevel@tonic-gate 				tail("version");
8747c478bd9Sstevel@tonic-gate 				setNAEOL();
875f6db9f27Scf46844 				viprintf("%s", Version);
8767c478bd9Sstevel@tonic-gate 				noonl();
8777c478bd9Sstevel@tonic-gate 				continue;
8787c478bd9Sstevel@tonic-gate 
8797c478bd9Sstevel@tonic-gate /* visual */
8807c478bd9Sstevel@tonic-gate 			case 'i':
8817c478bd9Sstevel@tonic-gate 				tail("visual");
8827c478bd9Sstevel@tonic-gate 				if (inopen) {
8837c478bd9Sstevel@tonic-gate 					c = 'e';
8847c478bd9Sstevel@tonic-gate 					goto editcmd;
8857c478bd9Sstevel@tonic-gate 				}
8867c478bd9Sstevel@tonic-gate 				vop();
8877c478bd9Sstevel@tonic-gate 				pflag = 0;
8887c478bd9Sstevel@tonic-gate 				nochng();
8897c478bd9Sstevel@tonic-gate 				continue;
8907c478bd9Sstevel@tonic-gate 			}
8917c478bd9Sstevel@tonic-gate /* v */
8927c478bd9Sstevel@tonic-gate 			tail("v");
8937c478bd9Sstevel@tonic-gate 			global(0);
8947c478bd9Sstevel@tonic-gate 			nochng();
8957c478bd9Sstevel@tonic-gate 			continue;
8967c478bd9Sstevel@tonic-gate 
8977c478bd9Sstevel@tonic-gate /* write */
8987c478bd9Sstevel@tonic-gate 		case 'w':
8997c478bd9Sstevel@tonic-gate 			c = peekchar();
9007c478bd9Sstevel@tonic-gate 			tail(c == 'q' ? "wq" : "write");
9017c478bd9Sstevel@tonic-gate wq:
9027c478bd9Sstevel@tonic-gate 			if (skipwh() && peekchar() == '!') {
9037c478bd9Sstevel@tonic-gate 				pofix();
9047c478bd9Sstevel@tonic-gate 				ignchar();
9057c478bd9Sstevel@tonic-gate 				setall();
906ec427229Sceastha 				unix0(0, 1);
907f6db9f27Scf46844 				(void) vi_filter(1);
9087c478bd9Sstevel@tonic-gate 			} else {
9097c478bd9Sstevel@tonic-gate 				setall();
9107c478bd9Sstevel@tonic-gate 				if (c == 'q')
9117c478bd9Sstevel@tonic-gate 					write_quit = 1;
9127c478bd9Sstevel@tonic-gate 				else
9137c478bd9Sstevel@tonic-gate 					write_quit = 0;
9147c478bd9Sstevel@tonic-gate 				wop(1);
9157c478bd9Sstevel@tonic-gate 				nochng();
9167c478bd9Sstevel@tonic-gate 			}
9177c478bd9Sstevel@tonic-gate 			if (c == 'q')
9187c478bd9Sstevel@tonic-gate 				goto quit;
9197c478bd9Sstevel@tonic-gate 			continue;
9207c478bd9Sstevel@tonic-gate /* X: crypt */
9217c478bd9Sstevel@tonic-gate 		case 'X':
9227c478bd9Sstevel@tonic-gate 			crflag = -1; /* determine if file is encrypted */
9237c478bd9Sstevel@tonic-gate 			goto ent_crypt;
9247c478bd9Sstevel@tonic-gate 
9257c478bd9Sstevel@tonic-gate 		case 'C':
9267c478bd9Sstevel@tonic-gate 			crflag = 1;  /* assume files read in are encrypted */
9277c478bd9Sstevel@tonic-gate 			goto ent_crypt;
9287c478bd9Sstevel@tonic-gate 
9297c478bd9Sstevel@tonic-gate /* xit */
9307c478bd9Sstevel@tonic-gate 		case 'x':
9317c478bd9Sstevel@tonic-gate 			tail("xit");
9327c478bd9Sstevel@tonic-gate 			if (!chng)
9337c478bd9Sstevel@tonic-gate 				goto quit;
9347c478bd9Sstevel@tonic-gate 			c = 'q';
9357c478bd9Sstevel@tonic-gate 			goto wq;
9367c478bd9Sstevel@tonic-gate 
9377c478bd9Sstevel@tonic-gate /* yank */
9387c478bd9Sstevel@tonic-gate 		case 'y':
9397c478bd9Sstevel@tonic-gate 			tail("yank");
9407c478bd9Sstevel@tonic-gate 			c = cmdreg();
9417c478bd9Sstevel@tonic-gate #ifdef XPG4ONLY
9427c478bd9Sstevel@tonic-gate 			setcount2();
9437c478bd9Sstevel@tonic-gate #else /* XPG6 and Solaris */
9447c478bd9Sstevel@tonic-gate 			setcount();
9457c478bd9Sstevel@tonic-gate #endif /* XPG4ONLY */
9467c478bd9Sstevel@tonic-gate 			eol();
9477c478bd9Sstevel@tonic-gate 			vmacchng(0);
9487c478bd9Sstevel@tonic-gate 			if (c)
949f6db9f27Scf46844 				(void) YANKreg(c);
9507c478bd9Sstevel@tonic-gate 			else
951f6db9f27Scf46844 				(void) yank();
9527c478bd9Sstevel@tonic-gate 			continue;
9537c478bd9Sstevel@tonic-gate 
9547c478bd9Sstevel@tonic-gate /* z */
9557c478bd9Sstevel@tonic-gate 		case 'z':
9567c478bd9Sstevel@tonic-gate 			zop(0);
9577c478bd9Sstevel@tonic-gate 			pflag = 0;
9587c478bd9Sstevel@tonic-gate 			continue;
9597c478bd9Sstevel@tonic-gate 
9607c478bd9Sstevel@tonic-gate /* * */
9617c478bd9Sstevel@tonic-gate /* @ */
9627c478bd9Sstevel@tonic-gate 		case '*':
9637c478bd9Sstevel@tonic-gate 		case '@':
9647c478bd9Sstevel@tonic-gate 			c = getchar();
9657c478bd9Sstevel@tonic-gate 			if (c == '\n' || c == '\r')
9667c478bd9Sstevel@tonic-gate 				ungetchar(c);
9677c478bd9Sstevel@tonic-gate 			if (any(c, "@*\n\r"))
9687c478bd9Sstevel@tonic-gate 				c = lastmac;
9697c478bd9Sstevel@tonic-gate 			if (isupper(c))
9707c478bd9Sstevel@tonic-gate 				c = tolower(c);
9717c478bd9Sstevel@tonic-gate 			if (!islower(c))
9727c478bd9Sstevel@tonic-gate 				error(gettext("Bad register"));
9737c478bd9Sstevel@tonic-gate 			donewline();
9747c478bd9Sstevel@tonic-gate 			setdot();
9757c478bd9Sstevel@tonic-gate 			cmdmac(c);
9767c478bd9Sstevel@tonic-gate 			continue;
9777c478bd9Sstevel@tonic-gate 
9787c478bd9Sstevel@tonic-gate /* | */
9797c478bd9Sstevel@tonic-gate 		case '|':
9807c478bd9Sstevel@tonic-gate 			endline = 0;
9817c478bd9Sstevel@tonic-gate 			goto caseline;
9827c478bd9Sstevel@tonic-gate 
9837c478bd9Sstevel@tonic-gate /* \n */
9847c478bd9Sstevel@tonic-gate 		case '\n':
9857c478bd9Sstevel@tonic-gate 			endline = 1;
9867c478bd9Sstevel@tonic-gate caseline:
9877c478bd9Sstevel@tonic-gate 			notempty();
9887c478bd9Sstevel@tonic-gate 			if (addr2 == 0) {
9897c478bd9Sstevel@tonic-gate 				if (cursor_up != NOSTR && c == '\n' &&
9907c478bd9Sstevel@tonic-gate 				    !inglobal)
9917c478bd9Sstevel@tonic-gate 					c = CTRL('k');
9927c478bd9Sstevel@tonic-gate 				if (inglobal)
9937c478bd9Sstevel@tonic-gate 					addr1 = addr2 = dot;
9947c478bd9Sstevel@tonic-gate 				else {
9957c478bd9Sstevel@tonic-gate 					if (dot == dol)
9967c478bd9Sstevel@tonic-gate 						error((vi_TERSE) ?
9977c478bd9Sstevel@tonic-gate 						    gettext("At EOF") :
9987c478bd9Sstevel@tonic-gate 						    gettext("At end-of-file"));
9997c478bd9Sstevel@tonic-gate 					addr1 = addr2 = dot + 1;
10007c478bd9Sstevel@tonic-gate 				}
10017c478bd9Sstevel@tonic-gate 			}
10027c478bd9Sstevel@tonic-gate 			setdot();
10037c478bd9Sstevel@tonic-gate 			nonzero();
10047c478bd9Sstevel@tonic-gate 			if (seensemi)
10057c478bd9Sstevel@tonic-gate 				addr1 = addr2;
1006*23a1cceaSRoger A. Faulkner 			getaline(*addr1);
10077c478bd9Sstevel@tonic-gate 			if (c == CTRL('k')) {
10087c478bd9Sstevel@tonic-gate 				flush1();
10097c478bd9Sstevel@tonic-gate 				destline--;
10107c478bd9Sstevel@tonic-gate 				if (hadpr)
10117c478bd9Sstevel@tonic-gate 					shudclob = 1;
10127c478bd9Sstevel@tonic-gate 			}
10137c478bd9Sstevel@tonic-gate 			plines(addr1, addr2, 1);
10147c478bd9Sstevel@tonic-gate 			continue;
10157c478bd9Sstevel@tonic-gate 
10167c478bd9Sstevel@tonic-gate /* " */
10177c478bd9Sstevel@tonic-gate 		case '"':
10187c478bd9Sstevel@tonic-gate 			comment();
10197c478bd9Sstevel@tonic-gate 			continue;
10207c478bd9Sstevel@tonic-gate 
10217c478bd9Sstevel@tonic-gate /* # */
10227c478bd9Sstevel@tonic-gate 		case '#':
10237c478bd9Sstevel@tonic-gate numberit:
10247c478bd9Sstevel@tonic-gate 			setCNL();
10257c478bd9Sstevel@tonic-gate 			(void) setnumb(1);
10267c478bd9Sstevel@tonic-gate 			pflag = 0;
10277c478bd9Sstevel@tonic-gate 			goto print;
10287c478bd9Sstevel@tonic-gate 
10297c478bd9Sstevel@tonic-gate /* = */
10307c478bd9Sstevel@tonic-gate 		case '=':
10317c478bd9Sstevel@tonic-gate 			donewline();
10327c478bd9Sstevel@tonic-gate 			setall();
10337c478bd9Sstevel@tonic-gate 			if (inglobal == 2)
10347c478bd9Sstevel@tonic-gate 				pofix();
1035f6db9f27Scf46844 			viprintf("%d", lineno(addr2));
10367c478bd9Sstevel@tonic-gate 			noonl();
10377c478bd9Sstevel@tonic-gate 			continue;
10387c478bd9Sstevel@tonic-gate 
10397c478bd9Sstevel@tonic-gate /* ! */
10407c478bd9Sstevel@tonic-gate 		case '!':
10417c478bd9Sstevel@tonic-gate 			if (addr2 != 0) {
10427c478bd9Sstevel@tonic-gate 				vmacchng(0);
1043ec427229Sceastha 				unix0(0, 1);
10447c478bd9Sstevel@tonic-gate 				setdot();
1045f6db9f27Scf46844 				(void) vi_filter(2);
10467c478bd9Sstevel@tonic-gate 			} else {
1047ec427229Sceastha 				unix0(1, 1);
10487c478bd9Sstevel@tonic-gate 				pofix();
1049f6db9f27Scf46844 				putpad((unsigned char *)exit_ca_mode);
10507c478bd9Sstevel@tonic-gate 				flush();
10517c478bd9Sstevel@tonic-gate 				resetterm();
105268c92b9fScf46844 				if (!tagflg) {
10537c478bd9Sstevel@tonic-gate 					unixwt(1, unixex("-c", uxb, 0, 0));
105468c92b9fScf46844 				} else {
105568c92b9fScf46844 					error(gettext("Invalid tags file:"
105668c92b9fScf46844 					    " contains shell escape"));
105768c92b9fScf46844 				}
10587c478bd9Sstevel@tonic-gate 				vclrech(1);	/* vcontin(0); */
10597c478bd9Sstevel@tonic-gate 				nochng();
10607c478bd9Sstevel@tonic-gate 			}
10617c478bd9Sstevel@tonic-gate 			continue;
10627c478bd9Sstevel@tonic-gate 
10637c478bd9Sstevel@tonic-gate /* < */
10647c478bd9Sstevel@tonic-gate /* > */
10657c478bd9Sstevel@tonic-gate 		case '<':
10667c478bd9Sstevel@tonic-gate 		case '>':
10677c478bd9Sstevel@tonic-gate 			for (cnt = 1; peekchar() == c; cnt++)
10687c478bd9Sstevel@tonic-gate 				ignchar();
10697c478bd9Sstevel@tonic-gate 			setCNL();
10707c478bd9Sstevel@tonic-gate 			vmacchng(0);
10717c478bd9Sstevel@tonic-gate 			shift(c, cnt);
10727c478bd9Sstevel@tonic-gate 			continue;
10737c478bd9Sstevel@tonic-gate 
10747c478bd9Sstevel@tonic-gate /* ^D */
10757c478bd9Sstevel@tonic-gate /* EOF */
10767c478bd9Sstevel@tonic-gate 		case CTRL('d'):
10777c478bd9Sstevel@tonic-gate 		case EOF:
10787c478bd9Sstevel@tonic-gate 			if (exitoneof) {
10797c478bd9Sstevel@tonic-gate 				if (addr2 != 0)
10807c478bd9Sstevel@tonic-gate 					dot = addr2;
10817c478bd9Sstevel@tonic-gate 				return;
10827c478bd9Sstevel@tonic-gate 			}
10837c478bd9Sstevel@tonic-gate 			if (!isatty(0)) {
10847c478bd9Sstevel@tonic-gate 				if (intty)
10857c478bd9Sstevel@tonic-gate 					/*
10867c478bd9Sstevel@tonic-gate 					 * Chtty sys call at UCB may cause a
10877c478bd9Sstevel@tonic-gate 					 * input which was a tty to suddenly be
10887c478bd9Sstevel@tonic-gate 					 * turned into /dev/null.
10897c478bd9Sstevel@tonic-gate 					 */
10907c478bd9Sstevel@tonic-gate 					onhup(0);
10917c478bd9Sstevel@tonic-gate 				return;
10927c478bd9Sstevel@tonic-gate 			}
10937c478bd9Sstevel@tonic-gate 			if (addr2 != 0) {
10947c478bd9Sstevel@tonic-gate 				setlastchar('\n');
10957c478bd9Sstevel@tonic-gate 				putnl();
10967c478bd9Sstevel@tonic-gate 			}
10977c478bd9Sstevel@tonic-gate 			if (dol == zero) {
10987c478bd9Sstevel@tonic-gate 				if (addr2 == 0)
10997c478bd9Sstevel@tonic-gate 					putnl();
11007c478bd9Sstevel@tonic-gate 				notempty();
11017c478bd9Sstevel@tonic-gate 			}
11027c478bd9Sstevel@tonic-gate 			ungetchar(EOF);
11037c478bd9Sstevel@tonic-gate 			zop(hadpr);
11047c478bd9Sstevel@tonic-gate 			continue;
11057c478bd9Sstevel@tonic-gate 		default:
11067c478bd9Sstevel@tonic-gate 			if (!isalpha(c) || !isascii(c))
11077c478bd9Sstevel@tonic-gate 				break;
11087c478bd9Sstevel@tonic-gate 			ungetchar(c);
1109f6db9f27Scf46844 			tailprim((unsigned char *)"", 0, 0);
11107c478bd9Sstevel@tonic-gate 		}
11117c478bd9Sstevel@tonic-gate 		ungetchar(c);
11127c478bd9Sstevel@tonic-gate 		{
11137c478bd9Sstevel@tonic-gate 			int length;
11147c478bd9Sstevel@tonic-gate 			char multic[MULTI_BYTE_MAX];
11157c478bd9Sstevel@tonic-gate 			wchar_t wchar;
11167c478bd9Sstevel@tonic-gate 			length = _mbftowc(multic, &wchar, getchar, &peekc);
11177c478bd9Sstevel@tonic-gate 			if (length < 0)
11187c478bd9Sstevel@tonic-gate 				length = -length;
11197c478bd9Sstevel@tonic-gate 			multic[length] = '\0';
11207c478bd9Sstevel@tonic-gate 			error((vi_TERSE) ? gettext("What?") :
11217c478bd9Sstevel@tonic-gate 				gettext("Unknown command character '%s'"),
11227c478bd9Sstevel@tonic-gate 			    multic);
11237c478bd9Sstevel@tonic-gate 		}
11247c478bd9Sstevel@tonic-gate 	}
11257c478bd9Sstevel@tonic-gate }
1126