xref: /onnv-gate/usr/src/cmd/vi/port/ex_set.c (revision 13093:48f2dbca79a2)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*13093SRoger.Faulkner@Oracle.COM  * Common Development and Distribution License (the "License").
6*13093SRoger.Faulkner@Oracle.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21*13093SRoger.Faulkner@Oracle.COM 
22802Scf46844 /*
23*13093SRoger.Faulkner@Oracle.COM  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24802Scf46844  */
25802Scf46844 
260Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
270Sstevel@tonic-gate /*	  All Rights Reserved  	*/
280Sstevel@tonic-gate 
290Sstevel@tonic-gate 
300Sstevel@tonic-gate /* Copyright (c) 1981 Regents of the University of California */
31802Scf46844 
320Sstevel@tonic-gate #include "ex.h"
330Sstevel@tonic-gate #include "ex_temp.h"
340Sstevel@tonic-gate #include "ex_tty.h"
350Sstevel@tonic-gate 
360Sstevel@tonic-gate /*
370Sstevel@tonic-gate  * Set command.
380Sstevel@tonic-gate  */
390Sstevel@tonic-gate unsigned char	optname[ONMSZ];
400Sstevel@tonic-gate 
41802Scf46844 void
set(void)42802Scf46844 set(void)
430Sstevel@tonic-gate {
44802Scf46844 	unsigned char *cp;
45802Scf46844 	struct option *op;
46802Scf46844 	int c;
470Sstevel@tonic-gate 	bool no;
480Sstevel@tonic-gate 	extern short ospeed;
490Sstevel@tonic-gate #ifdef TRACE
500Sstevel@tonic-gate 	int k, label;
510Sstevel@tonic-gate 	line *tmpadr;
520Sstevel@tonic-gate #endif
530Sstevel@tonic-gate 
540Sstevel@tonic-gate 	setnoaddr();
550Sstevel@tonic-gate 	if (skipend()) {
560Sstevel@tonic-gate 		if (peekchar() != EOF)
570Sstevel@tonic-gate 			ignchar();
580Sstevel@tonic-gate 		propts();
590Sstevel@tonic-gate 		return;
600Sstevel@tonic-gate 	}
610Sstevel@tonic-gate 	do {
620Sstevel@tonic-gate 		cp = optname;
630Sstevel@tonic-gate 		do {
640Sstevel@tonic-gate 			if (cp < &optname[ONMSZ - 2])
650Sstevel@tonic-gate 				*cp++ = getchar();
660Sstevel@tonic-gate 		} while (isalnum(peekchar()));
670Sstevel@tonic-gate 		*cp = 0;
680Sstevel@tonic-gate 		cp = optname;
690Sstevel@tonic-gate 		if (eq("all", cp)) {
700Sstevel@tonic-gate 			if (inopen)
710Sstevel@tonic-gate 				pofix();
720Sstevel@tonic-gate 			prall();
730Sstevel@tonic-gate 			goto next;
740Sstevel@tonic-gate 		}
750Sstevel@tonic-gate 		no = 0;
760Sstevel@tonic-gate #ifdef TRACE
770Sstevel@tonic-gate  		/*
780Sstevel@tonic-gate  		 * General purpose test code for looking at address of those
790Sstevel@tonic-gate  		 * invisible marks (as well as the visible ones).
800Sstevel@tonic-gate  		 */
81802Scf46844  		if (eq("marks", cp)) {
82802Scf46844 			viprintf("Marks   Address\n\r");
83802Scf46844 			viprintf("					\n");
84802Scf46844 			viprintf("\n");
85802Scf46844 			for (k = 0; k <= 25; k++)
86802Scf46844 				viprintf("Mark:%c\t%d\n", k+'a', names[k]);
870Sstevel@tonic-gate  		goto next;
880Sstevel@tonic-gate  		}
890Sstevel@tonic-gate 
900Sstevel@tonic-gate 		/*
910Sstevel@tonic-gate 		 * General purpose test code for looking at
920Sstevel@tonic-gate 		 * named registers.
930Sstevel@tonic-gate 		 */
940Sstevel@tonic-gate 
950Sstevel@tonic-gate 		if (eq("named",cp)) {
960Sstevel@tonic-gate 			if (inopen)
970Sstevel@tonic-gate 				pofix();
980Sstevel@tonic-gate 			shownam();
990Sstevel@tonic-gate 			goto next;
1000Sstevel@tonic-gate 		}
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate 		/*
1030Sstevel@tonic-gate 	   	 * General purpose test code for looking at
1040Sstevel@tonic-gate 		 * numbered registers.
1050Sstevel@tonic-gate 		 */
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate 		if (eq("nbrreg",cp)) {
1080Sstevel@tonic-gate 			if (inopen)
1090Sstevel@tonic-gate 				pofix();
1100Sstevel@tonic-gate 			shownbr();
1110Sstevel@tonic-gate 			goto next;
1120Sstevel@tonic-gate 		}
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate 		/*
1150Sstevel@tonic-gate  		 * General purpose test code for looking at addresses
1160Sstevel@tonic-gate 		 * in the edit and save areas of VI.
1170Sstevel@tonic-gate  		 */
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate  		if (eq("buffers",cp)) {
1200Sstevel@tonic-gate  			if (inopen)
1210Sstevel@tonic-gate 				pofix();
122802Scf46844 			viprintf("\nLabels   Address	Contents\n");
123802Scf46844  			viprintf("======   =======	========");
1240Sstevel@tonic-gate 			for (tmpadr = zero; tmpadr <= dol; tmpadr++) {
1250Sstevel@tonic-gate  				label =0;
126802Scf46844 				if (tmpadr == zero) {
127802Scf46844 					viprintf("ZERO:\t");
1280Sstevel@tonic-gate  					label = 2;
1290Sstevel@tonic-gate  				}
1300Sstevel@tonic-gate  				if (tmpadr == one) {
131802Scf46844 					if (label > 0)
132802Scf46844 						viprintf("\nONE:\t");
133802Scf46844 					else
134802Scf46844 						viprintf("ONE:\t");
1350Sstevel@tonic-gate  					label = 1;
1360Sstevel@tonic-gate  				}
1370Sstevel@tonic-gate  				if (tmpadr == dot) {
138802Scf46844 					if (label > 0)
139802Scf46844 						viprintf("\nDOT:\t");
140802Scf46844 					else
141802Scf46844 						viprintf("DOT:\t");
1420Sstevel@tonic-gate  					label = 1;
1430Sstevel@tonic-gate  				}
1440Sstevel@tonic-gate  				if (tmpadr == undap1) {
1450Sstevel@tonic-gate  					if (label > 0)
146802Scf46844 						viprintf("\nUNDAP1:\t");
1470Sstevel@tonic-gate  					else
148802Scf46844 						viprintf("UNDAP1:\t");
1490Sstevel@tonic-gate  					label = 1;
1500Sstevel@tonic-gate  				}
1510Sstevel@tonic-gate  				if (tmpadr == undap2) {
1520Sstevel@tonic-gate  					if (label > 0)
153802Scf46844 						viprintf("\nUNDAP2:\t");
1540Sstevel@tonic-gate  					else
155802Scf46844 						viprintf("UNDAP2:\t");
1560Sstevel@tonic-gate  					label = 1;
1570Sstevel@tonic-gate  				}
1580Sstevel@tonic-gate  				if (tmpadr == unddel) {
1590Sstevel@tonic-gate  					if (label > 0)
160802Scf46844 						viprintf("\nUNDDEL:\t");
1610Sstevel@tonic-gate  					else
162802Scf46844 						viprintf("UNDDEL:\t");
1630Sstevel@tonic-gate  					label = 1;
1640Sstevel@tonic-gate  				}
1650Sstevel@tonic-gate  				if (tmpadr == dol) {
1660Sstevel@tonic-gate  					if (label > 0)
167802Scf46844 						viprintf("\nDOL:\t");
1680Sstevel@tonic-gate  					else
169802Scf46844 						viprintf("DOL:\t");
1700Sstevel@tonic-gate  					label = 1;
1710Sstevel@tonic-gate  				}
1720Sstevel@tonic-gate  				for (k=0; k<=25; k++)
1730Sstevel@tonic-gate  					if (names[k] == (*tmpadr &~ 01)) {
1740Sstevel@tonic-gate  						if (label > 0)
175802Scf46844 							viprintf(
176802Scf46844 "\nMark:%c\t%d\t", k+'a', names[k]);
1770Sstevel@tonic-gate  						else
178802Scf46844 							viprintf(
179802Scf46844 "Mark:%c\t%d\t", k+'a', names[k]);
1800Sstevel@tonic-gate  						label=1;
1810Sstevel@tonic-gate  					}
1820Sstevel@tonic-gate  				if (label == 0)
1830Sstevel@tonic-gate  					continue;
1840Sstevel@tonic-gate 
1850Sstevel@tonic-gate  				if (label == 2)
186802Scf46844 					viprintf("%d\n", tmpadr);
1870Sstevel@tonic-gate  				else  {
188802Scf46844 					viprintf("%d\t", tmpadr);
189*13093SRoger.Faulkner@Oracle.COM  					getaline(*tmpadr);
1900Sstevel@tonic-gate  					pline(lineno(tmpadr));
1910Sstevel@tonic-gate  					putchar('\n');
1920Sstevel@tonic-gate  				}
1930Sstevel@tonic-gate  			}
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate  			for (tmpadr = dol+1; tmpadr <= unddol; tmpadr++) {
1960Sstevel@tonic-gate  				label =0;
1970Sstevel@tonic-gate  				if (tmpadr == dol+1) {
198802Scf46844 					viprintf("DOL+1:\t");
1990Sstevel@tonic-gate  					label = 1;
2000Sstevel@tonic-gate  				}
2010Sstevel@tonic-gate  				if (tmpadr == unddel) {
2020Sstevel@tonic-gate  					if (label > 0)
203802Scf46844 						viprintf("\nUNDDEL:\t");
2040Sstevel@tonic-gate  					else
205802Scf46844 						viprintf("UNDDEL:\t");
2060Sstevel@tonic-gate  					label = 1;
2070Sstevel@tonic-gate  				}
2080Sstevel@tonic-gate  				if (tmpadr == unddol) {
2090Sstevel@tonic-gate  					if (label > 0)
210802Scf46844 						viprintf("\nUNDDOL:\t");
2110Sstevel@tonic-gate  					else
212802Scf46844 						viprintf("UNDDOL:\t");
2130Sstevel@tonic-gate  					label = 1;
2140Sstevel@tonic-gate  				}
2150Sstevel@tonic-gate  				for (k=0; k<=25; k++)
2160Sstevel@tonic-gate  					if (names[k] == (*tmpadr &~ 01)) {
2170Sstevel@tonic-gate  						if (label > 0)
218802Scf46844 							viprintf(
219802Scf46844 "\nMark:%c\t%d\t", k+'a', names[k]);
2200Sstevel@tonic-gate  						else
221802Scf46844 							viprintf(
222802Scf46844 "Mark:%c\t%d\t", k+'a', names[k]);
2230Sstevel@tonic-gate  						label=1;
2240Sstevel@tonic-gate  					}
2250Sstevel@tonic-gate  				if (label == 0)
2260Sstevel@tonic-gate  					continue;
2270Sstevel@tonic-gate  				if (label == 2)
228802Scf46844 					viprintf("%d\n", tmpadr);
2290Sstevel@tonic-gate  				else  {
230802Scf46844 					viprintf("%d\t", tmpadr);
231*13093SRoger.Faulkner@Oracle.COM  					getaline(*tmpadr);
2320Sstevel@tonic-gate  					pline(lineno(tmpadr));
2330Sstevel@tonic-gate  					putchar('\n');
2340Sstevel@tonic-gate  				}
2350Sstevel@tonic-gate  			}
2360Sstevel@tonic-gate  			goto next;
2370Sstevel@tonic-gate  		}
2380Sstevel@tonic-gate #endif
2390Sstevel@tonic-gate 		if (cp[0] == 'n' && cp[1] == 'o' && cp[2] != 'v') {
2400Sstevel@tonic-gate 			cp += 2;
2410Sstevel@tonic-gate 			no++;
2420Sstevel@tonic-gate 		}
2430Sstevel@tonic-gate 		/* Implement w300, w1200, and w9600 specially */
2440Sstevel@tonic-gate 		if (eq(cp, "w300")) {
2450Sstevel@tonic-gate 			if (ospeed >= B1200) {
2460Sstevel@tonic-gate dontset:
2470Sstevel@tonic-gate 				(void)getchar();	/* = */
2480Sstevel@tonic-gate 				(void)getnum();	/* value */
2490Sstevel@tonic-gate 				continue;
2500Sstevel@tonic-gate 			}
2510Sstevel@tonic-gate 			cp = (unsigned char *)"window";
2520Sstevel@tonic-gate 		} else if (eq(cp, "w1200")) {
2530Sstevel@tonic-gate 			if (ospeed < B1200 || ospeed >= B2400)
2540Sstevel@tonic-gate 				goto dontset;
2550Sstevel@tonic-gate 			cp = (unsigned char *)"window";
2560Sstevel@tonic-gate 		} else if (eq(cp, "w9600")) {
2570Sstevel@tonic-gate 			if (ospeed < B2400)
2580Sstevel@tonic-gate 				goto dontset;
2590Sstevel@tonic-gate 			cp = (unsigned char *)"window";
2600Sstevel@tonic-gate 		}
2610Sstevel@tonic-gate 		for (op = options; op < &options[vi_NOPTS]; op++)
2620Sstevel@tonic-gate 			if (eq(op->oname, cp) || op->oabbrev && eq(op->oabbrev, cp))
2630Sstevel@tonic-gate 				break;
2640Sstevel@tonic-gate 		if (op->oname == 0)
265802Scf46844 			serror(value(vi_TERSE) ? (unsigned char *)
266802Scf46844 			    gettext("%s: No such option") :
267802Scf46844 			    (unsigned char *)
2680Sstevel@tonic-gate gettext("%s: No such option - 'set all' gives all option values"), cp);
2690Sstevel@tonic-gate 		c = skipwh();
2700Sstevel@tonic-gate 		if (peekchar() == '?') {
2710Sstevel@tonic-gate 			ignchar();
2720Sstevel@tonic-gate printone:
2730Sstevel@tonic-gate 			propt(op);
2740Sstevel@tonic-gate 			noonl();
2750Sstevel@tonic-gate 			goto next;
2760Sstevel@tonic-gate 		}
2770Sstevel@tonic-gate 		if (op->otype == ONOFF) {
2780Sstevel@tonic-gate 			op->ovalue = 1 - no;
2790Sstevel@tonic-gate 			if (op == &options[vi_PROMPT])
2800Sstevel@tonic-gate 				oprompt = 1 - no;
2810Sstevel@tonic-gate 			goto next;
2820Sstevel@tonic-gate 		}
2830Sstevel@tonic-gate 		if (no)
284802Scf46844 			serror((unsigned char *)
285802Scf46844 			    gettext("Option %s is not a toggle"), op->oname);
2860Sstevel@tonic-gate 		if (c != 0 || setend())
2870Sstevel@tonic-gate 			goto printone;
2880Sstevel@tonic-gate 		if (getchar() != '=')
289802Scf46844 			serror(value(vi_TERSE) ? (unsigned char *)
290802Scf46844 			    gettext("Missing =") :
291802Scf46844 			    (unsigned char *)
292802Scf46844 			    gettext("Missing = in assignment to option %s"),
293802Scf46844 			    op->oname);
2940Sstevel@tonic-gate 		switch (op->otype) {
2950Sstevel@tonic-gate 
2960Sstevel@tonic-gate 		case NUMERIC:
2970Sstevel@tonic-gate 			if (!isdigit(peekchar()))
2980Sstevel@tonic-gate 				error(value(vi_TERSE) ?
2990Sstevel@tonic-gate gettext("Digits required") : gettext("Digits required after ="));
3000Sstevel@tonic-gate 			op->ovalue = getnum();
3010Sstevel@tonic-gate 			if (value(vi_TABSTOP) <= 0)
3020Sstevel@tonic-gate 				value(vi_TABSTOP) = TABS;
3030Sstevel@tonic-gate 			if (op == &options[vi_WINDOW]) {
3040Sstevel@tonic-gate 				if (value(vi_WINDOW) >= lines)
3050Sstevel@tonic-gate 					value(vi_WINDOW) = lines-1;
3060Sstevel@tonic-gate 				vsetsiz(value(vi_WINDOW));
3070Sstevel@tonic-gate 			}
3080Sstevel@tonic-gate 			break;
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate 		case STRING:
3110Sstevel@tonic-gate 		case OTERM:
3120Sstevel@tonic-gate 			cp = optname;
3130Sstevel@tonic-gate 			while (!setend()) {
3140Sstevel@tonic-gate 				if (cp >= &optname[ONMSZ])
3150Sstevel@tonic-gate 					error(value(vi_TERSE) ?
3160Sstevel@tonic-gate gettext("String too long") : gettext("String too long in option assignment"));
3170Sstevel@tonic-gate 				/* adb change:  allow whitepace in strings */
3180Sstevel@tonic-gate 				if( (*cp = getchar()) == '\\')
3190Sstevel@tonic-gate 					if( peekchar() != EOF)
3200Sstevel@tonic-gate 						*cp = getchar();
3210Sstevel@tonic-gate 				cp++;
3220Sstevel@tonic-gate 			}
3230Sstevel@tonic-gate 			*cp = 0;
3240Sstevel@tonic-gate 			if (op->otype == OTERM) {
3250Sstevel@tonic-gate /*
3260Sstevel@tonic-gate  * At first glance it seems like we shouldn't care if the terminal type
3270Sstevel@tonic-gate  * is changed inside visual mode, as long as we assume the screen is
3280Sstevel@tonic-gate  * a mess and redraw it. However, it's a much harder problem than that.
3290Sstevel@tonic-gate  * If you happen to change from 1 crt to another that both have the same
3300Sstevel@tonic-gate  * size screen, it's OK. But if the screen size if different, the stuff
3310Sstevel@tonic-gate  * that gets initialized in vop() will be wrong. This could be overcome
3320Sstevel@tonic-gate  * by redoing the initialization, e.g. making the first 90% of vop into
3330Sstevel@tonic-gate  * a subroutine. However, the most useful case is where you forgot to do
3340Sstevel@tonic-gate  * a setenv before you went into the editor and it thinks you're on a dumb
3350Sstevel@tonic-gate  * terminal. Ex treats this like hardcopy and goes into HARDOPEN mode.
3360Sstevel@tonic-gate  * This loses because the first part of vop calls oop in this case.
3370Sstevel@tonic-gate  */
3380Sstevel@tonic-gate 				if (inopen)
3390Sstevel@tonic-gate error(gettext("Can't change type of terminal from within open/visual"));
3400Sstevel@tonic-gate 				unterm();
3410Sstevel@tonic-gate 				setterm(optname);
3420Sstevel@tonic-gate 			} else {
3430Sstevel@tonic-gate 				CP(op->osvalue, optname);
3440Sstevel@tonic-gate 				op->odefault = 1;
3450Sstevel@tonic-gate 			}
3460Sstevel@tonic-gate 			break;
3470Sstevel@tonic-gate 		}
3480Sstevel@tonic-gate next:
3490Sstevel@tonic-gate 		flush();
3500Sstevel@tonic-gate 	} while (!skipend());
3510Sstevel@tonic-gate 	eol();
3520Sstevel@tonic-gate }
3530Sstevel@tonic-gate 
354802Scf46844 void
unterm(void)355802Scf46844 unterm(void)
3560Sstevel@tonic-gate {
3570Sstevel@tonic-gate 	/*
3580Sstevel@tonic-gate 	 *  All terminal mapped statements must be deleted.
3590Sstevel@tonic-gate 	 *  All user-defined mapped statements, cap=descr,
3600Sstevel@tonic-gate 	 *  are left unchanged.
3610Sstevel@tonic-gate 	 */
3620Sstevel@tonic-gate 
3630Sstevel@tonic-gate 	int i;
3640Sstevel@tonic-gate 
3650Sstevel@tonic-gate 	for (i=0; i < MAXNOMACS; i++) {
3660Sstevel@tonic-gate 
3670Sstevel@tonic-gate 		/*
3680Sstevel@tonic-gate 		 * Unmap any terminal-defined arrow keys
3690Sstevel@tonic-gate 		 */
3700Sstevel@tonic-gate 
3710Sstevel@tonic-gate 		if (arrows[i].cap && arrows[i].descr &&
3720Sstevel@tonic-gate 		    strcmp(arrows[i].cap, arrows[i].descr))
3730Sstevel@tonic-gate 			addmac(arrows[i].cap, NOSTR, NOSTR, arrows);
3740Sstevel@tonic-gate 
3750Sstevel@tonic-gate 		/*
3760Sstevel@tonic-gate 		 * Unmap any terminal-defined function keys
3770Sstevel@tonic-gate 		 */
3780Sstevel@tonic-gate 
3790Sstevel@tonic-gate 		if (immacs[i].cap && immacs[i].descr && strcmp(immacs[i].cap, immacs[i].descr))
3800Sstevel@tonic-gate 			addmac(immacs[i].cap, NOSTR, NOSTR, immacs);
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate 	}
3830Sstevel@tonic-gate }
3840Sstevel@tonic-gate 
3850Sstevel@tonic-gate 
386802Scf46844 int
setend(void)387802Scf46844 setend(void)
3880Sstevel@tonic-gate {
3890Sstevel@tonic-gate 
3900Sstevel@tonic-gate 	return (iswhite(peekchar()) || endcmd(peekchar()));
3910Sstevel@tonic-gate }
3920Sstevel@tonic-gate 
393802Scf46844 void
prall(void)394802Scf46844 prall(void)
3950Sstevel@tonic-gate {
396802Scf46844 	int incr = (vi_NOPTS + 2) / 3;
397802Scf46844 	int rows = incr;
398802Scf46844 	struct option *op = options;
3990Sstevel@tonic-gate 
4000Sstevel@tonic-gate 	for (; rows; rows--, op++) {
4010Sstevel@tonic-gate 		propt(op);
4020Sstevel@tonic-gate 		gotab(24);
4030Sstevel@tonic-gate 		propt(&op[incr]);
4040Sstevel@tonic-gate 		if (&op[2*incr] < &options[vi_NOPTS]) {
4050Sstevel@tonic-gate 			gotab(56);
4060Sstevel@tonic-gate 			propt(&op[2 * incr]);
4070Sstevel@tonic-gate 		}
4080Sstevel@tonic-gate 		putNFL();
4090Sstevel@tonic-gate 	}
4100Sstevel@tonic-gate }
4110Sstevel@tonic-gate 
412802Scf46844 void
propts(void)413802Scf46844 propts(void)
4140Sstevel@tonic-gate {
415802Scf46844 	struct option *op;
4160Sstevel@tonic-gate 
4170Sstevel@tonic-gate 	for (op = options; op < &options[vi_NOPTS]; op++) {
4180Sstevel@tonic-gate 		if (op == &options[vi_TTYTYPE])
4190Sstevel@tonic-gate 			continue;
4200Sstevel@tonic-gate 		switch (op->otype) {
4210Sstevel@tonic-gate 
4220Sstevel@tonic-gate 		case ONOFF:
4230Sstevel@tonic-gate 		case NUMERIC:
4240Sstevel@tonic-gate 			if (op->ovalue == op->odefault)
4250Sstevel@tonic-gate 				continue;
4260Sstevel@tonic-gate 			break;
4270Sstevel@tonic-gate 
4280Sstevel@tonic-gate 		case STRING:
4290Sstevel@tonic-gate 			if (op->odefault == 0)
4300Sstevel@tonic-gate 				continue;
4310Sstevel@tonic-gate 			break;
4320Sstevel@tonic-gate 		}
4330Sstevel@tonic-gate 		propt(op);
4340Sstevel@tonic-gate 		putchar(' ');
4350Sstevel@tonic-gate 	}
4360Sstevel@tonic-gate 	noonl();
4370Sstevel@tonic-gate 	flush();
4380Sstevel@tonic-gate }
4390Sstevel@tonic-gate 
440802Scf46844 void
propt(struct option * op)441802Scf46844 propt(struct option *op)
4420Sstevel@tonic-gate {
443802Scf46844 	unsigned char *name;
4440Sstevel@tonic-gate 
4450Sstevel@tonic-gate 	name = (unsigned char *)op->oname;
4460Sstevel@tonic-gate 
4470Sstevel@tonic-gate 	switch (op->otype) {
4480Sstevel@tonic-gate 
4490Sstevel@tonic-gate 	case ONOFF:
450802Scf46844 		viprintf("%s%s", op->ovalue ? "" : "no", name);
4510Sstevel@tonic-gate 		break;
4520Sstevel@tonic-gate 
4530Sstevel@tonic-gate 	case NUMERIC:
454802Scf46844 		viprintf("%s=%d", name, op->ovalue);
4550Sstevel@tonic-gate 		break;
4560Sstevel@tonic-gate 
4570Sstevel@tonic-gate 	case STRING:
4580Sstevel@tonic-gate 	case OTERM:
459802Scf46844 		viprintf("%s=%s", name, op->osvalue);
4600Sstevel@tonic-gate 		break;
4610Sstevel@tonic-gate 	}
4620Sstevel@tonic-gate }
463