xref: /onnv-gate/usr/src/cmd/vi/port/ex_set.c (revision 802:73b56fb6544b)
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
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
22*802Scf46844 /*
23*802Scf46844  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*802Scf46844  * Use is subject to license terms.
25*802Scf46844  */
26*802Scf46844 
270Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
280Sstevel@tonic-gate /*	  All Rights Reserved  	*/
290Sstevel@tonic-gate 
300Sstevel@tonic-gate 
310Sstevel@tonic-gate /* Copyright (c) 1981 Regents of the University of California */
32*802Scf46844 
33*802Scf46844 #pragma ident	"%Z%%M%	%I%	%E% SMI"
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #include "ex.h"
360Sstevel@tonic-gate #include "ex_temp.h"
370Sstevel@tonic-gate #include "ex_tty.h"
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /*
400Sstevel@tonic-gate  * Set command.
410Sstevel@tonic-gate  */
420Sstevel@tonic-gate unsigned char	optname[ONMSZ];
430Sstevel@tonic-gate 
44*802Scf46844 void
45*802Scf46844 set(void)
460Sstevel@tonic-gate {
47*802Scf46844 	unsigned char *cp;
48*802Scf46844 	struct option *op;
49*802Scf46844 	int c;
500Sstevel@tonic-gate 	bool no;
510Sstevel@tonic-gate 	extern short ospeed;
520Sstevel@tonic-gate #ifdef TRACE
530Sstevel@tonic-gate 	int k, label;
540Sstevel@tonic-gate 	line *tmpadr;
550Sstevel@tonic-gate #endif
560Sstevel@tonic-gate 
570Sstevel@tonic-gate 	setnoaddr();
580Sstevel@tonic-gate 	if (skipend()) {
590Sstevel@tonic-gate 		if (peekchar() != EOF)
600Sstevel@tonic-gate 			ignchar();
610Sstevel@tonic-gate 		propts();
620Sstevel@tonic-gate 		return;
630Sstevel@tonic-gate 	}
640Sstevel@tonic-gate 	do {
650Sstevel@tonic-gate 		cp = optname;
660Sstevel@tonic-gate 		do {
670Sstevel@tonic-gate 			if (cp < &optname[ONMSZ - 2])
680Sstevel@tonic-gate 				*cp++ = getchar();
690Sstevel@tonic-gate 		} while (isalnum(peekchar()));
700Sstevel@tonic-gate 		*cp = 0;
710Sstevel@tonic-gate 		cp = optname;
720Sstevel@tonic-gate 		if (eq("all", cp)) {
730Sstevel@tonic-gate 			if (inopen)
740Sstevel@tonic-gate 				pofix();
750Sstevel@tonic-gate 			prall();
760Sstevel@tonic-gate 			goto next;
770Sstevel@tonic-gate 		}
780Sstevel@tonic-gate 		no = 0;
790Sstevel@tonic-gate #ifdef TRACE
800Sstevel@tonic-gate  		/*
810Sstevel@tonic-gate  		 * General purpose test code for looking at address of those
820Sstevel@tonic-gate  		 * invisible marks (as well as the visible ones).
830Sstevel@tonic-gate  		 */
84*802Scf46844  		if (eq("marks", cp)) {
85*802Scf46844 			viprintf("Marks   Address\n\r");
86*802Scf46844 			viprintf("					\n");
87*802Scf46844 			viprintf("\n");
88*802Scf46844 			for (k = 0; k <= 25; k++)
89*802Scf46844 				viprintf("Mark:%c\t%d\n", k+'a', names[k]);
900Sstevel@tonic-gate  		goto next;
910Sstevel@tonic-gate  		}
920Sstevel@tonic-gate 
930Sstevel@tonic-gate 		/*
940Sstevel@tonic-gate 		 * General purpose test code for looking at
950Sstevel@tonic-gate 		 * named registers.
960Sstevel@tonic-gate 		 */
970Sstevel@tonic-gate 
980Sstevel@tonic-gate 		if (eq("named",cp)) {
990Sstevel@tonic-gate 			if (inopen)
1000Sstevel@tonic-gate 				pofix();
1010Sstevel@tonic-gate 			shownam();
1020Sstevel@tonic-gate 			goto next;
1030Sstevel@tonic-gate 		}
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate 		/*
1060Sstevel@tonic-gate 	   	 * General purpose test code for looking at
1070Sstevel@tonic-gate 		 * numbered registers.
1080Sstevel@tonic-gate 		 */
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate 		if (eq("nbrreg",cp)) {
1110Sstevel@tonic-gate 			if (inopen)
1120Sstevel@tonic-gate 				pofix();
1130Sstevel@tonic-gate 			shownbr();
1140Sstevel@tonic-gate 			goto next;
1150Sstevel@tonic-gate 		}
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate 		/*
1180Sstevel@tonic-gate  		 * General purpose test code for looking at addresses
1190Sstevel@tonic-gate 		 * in the edit and save areas of VI.
1200Sstevel@tonic-gate  		 */
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate  		if (eq("buffers",cp)) {
1230Sstevel@tonic-gate  			if (inopen)
1240Sstevel@tonic-gate 				pofix();
125*802Scf46844 			viprintf("\nLabels   Address	Contents\n");
126*802Scf46844  			viprintf("======   =======	========");
1270Sstevel@tonic-gate 			for (tmpadr = zero; tmpadr <= dol; tmpadr++) {
1280Sstevel@tonic-gate  				label =0;
129*802Scf46844 				if (tmpadr == zero) {
130*802Scf46844 					viprintf("ZERO:\t");
1310Sstevel@tonic-gate  					label = 2;
1320Sstevel@tonic-gate  				}
1330Sstevel@tonic-gate  				if (tmpadr == one) {
134*802Scf46844 					if (label > 0)
135*802Scf46844 						viprintf("\nONE:\t");
136*802Scf46844 					else
137*802Scf46844 						viprintf("ONE:\t");
1380Sstevel@tonic-gate  					label = 1;
1390Sstevel@tonic-gate  				}
1400Sstevel@tonic-gate  				if (tmpadr == dot) {
141*802Scf46844 					if (label > 0)
142*802Scf46844 						viprintf("\nDOT:\t");
143*802Scf46844 					else
144*802Scf46844 						viprintf("DOT:\t");
1450Sstevel@tonic-gate  					label = 1;
1460Sstevel@tonic-gate  				}
1470Sstevel@tonic-gate  				if (tmpadr == undap1) {
1480Sstevel@tonic-gate  					if (label > 0)
149*802Scf46844 						viprintf("\nUNDAP1:\t");
1500Sstevel@tonic-gate  					else
151*802Scf46844 						viprintf("UNDAP1:\t");
1520Sstevel@tonic-gate  					label = 1;
1530Sstevel@tonic-gate  				}
1540Sstevel@tonic-gate  				if (tmpadr == undap2) {
1550Sstevel@tonic-gate  					if (label > 0)
156*802Scf46844 						viprintf("\nUNDAP2:\t");
1570Sstevel@tonic-gate  					else
158*802Scf46844 						viprintf("UNDAP2:\t");
1590Sstevel@tonic-gate  					label = 1;
1600Sstevel@tonic-gate  				}
1610Sstevel@tonic-gate  				if (tmpadr == unddel) {
1620Sstevel@tonic-gate  					if (label > 0)
163*802Scf46844 						viprintf("\nUNDDEL:\t");
1640Sstevel@tonic-gate  					else
165*802Scf46844 						viprintf("UNDDEL:\t");
1660Sstevel@tonic-gate  					label = 1;
1670Sstevel@tonic-gate  				}
1680Sstevel@tonic-gate  				if (tmpadr == dol) {
1690Sstevel@tonic-gate  					if (label > 0)
170*802Scf46844 						viprintf("\nDOL:\t");
1710Sstevel@tonic-gate  					else
172*802Scf46844 						viprintf("DOL:\t");
1730Sstevel@tonic-gate  					label = 1;
1740Sstevel@tonic-gate  				}
1750Sstevel@tonic-gate  				for (k=0; k<=25; k++)
1760Sstevel@tonic-gate  					if (names[k] == (*tmpadr &~ 01)) {
1770Sstevel@tonic-gate  						if (label > 0)
178*802Scf46844 							viprintf(
179*802Scf46844 "\nMark:%c\t%d\t", k+'a', names[k]);
1800Sstevel@tonic-gate  						else
181*802Scf46844 							viprintf(
182*802Scf46844 "Mark:%c\t%d\t", k+'a', names[k]);
1830Sstevel@tonic-gate  						label=1;
1840Sstevel@tonic-gate  					}
1850Sstevel@tonic-gate  				if (label == 0)
1860Sstevel@tonic-gate  					continue;
1870Sstevel@tonic-gate 
1880Sstevel@tonic-gate  				if (label == 2)
189*802Scf46844 					viprintf("%d\n", tmpadr);
1900Sstevel@tonic-gate  				else  {
191*802Scf46844 					viprintf("%d\t", tmpadr);
1920Sstevel@tonic-gate  					getline(*tmpadr);
1930Sstevel@tonic-gate  					pline(lineno(tmpadr));
1940Sstevel@tonic-gate  					putchar('\n');
1950Sstevel@tonic-gate  				}
1960Sstevel@tonic-gate  			}
1970Sstevel@tonic-gate 
1980Sstevel@tonic-gate  			for (tmpadr = dol+1; tmpadr <= unddol; tmpadr++) {
1990Sstevel@tonic-gate  				label =0;
2000Sstevel@tonic-gate  				if (tmpadr == dol+1) {
201*802Scf46844 					viprintf("DOL+1:\t");
2020Sstevel@tonic-gate  					label = 1;
2030Sstevel@tonic-gate  				}
2040Sstevel@tonic-gate  				if (tmpadr == unddel) {
2050Sstevel@tonic-gate  					if (label > 0)
206*802Scf46844 						viprintf("\nUNDDEL:\t");
2070Sstevel@tonic-gate  					else
208*802Scf46844 						viprintf("UNDDEL:\t");
2090Sstevel@tonic-gate  					label = 1;
2100Sstevel@tonic-gate  				}
2110Sstevel@tonic-gate  				if (tmpadr == unddol) {
2120Sstevel@tonic-gate  					if (label > 0)
213*802Scf46844 						viprintf("\nUNDDOL:\t");
2140Sstevel@tonic-gate  					else
215*802Scf46844 						viprintf("UNDDOL:\t");
2160Sstevel@tonic-gate  					label = 1;
2170Sstevel@tonic-gate  				}
2180Sstevel@tonic-gate  				for (k=0; k<=25; k++)
2190Sstevel@tonic-gate  					if (names[k] == (*tmpadr &~ 01)) {
2200Sstevel@tonic-gate  						if (label > 0)
221*802Scf46844 							viprintf(
222*802Scf46844 "\nMark:%c\t%d\t", k+'a', names[k]);
2230Sstevel@tonic-gate  						else
224*802Scf46844 							viprintf(
225*802Scf46844 "Mark:%c\t%d\t", k+'a', names[k]);
2260Sstevel@tonic-gate  						label=1;
2270Sstevel@tonic-gate  					}
2280Sstevel@tonic-gate  				if (label == 0)
2290Sstevel@tonic-gate  					continue;
2300Sstevel@tonic-gate  				if (label == 2)
231*802Scf46844 					viprintf("%d\n", tmpadr);
2320Sstevel@tonic-gate  				else  {
233*802Scf46844 					viprintf("%d\t", tmpadr);
2340Sstevel@tonic-gate  					getline(*tmpadr);
2350Sstevel@tonic-gate  					pline(lineno(tmpadr));
2360Sstevel@tonic-gate  					putchar('\n');
2370Sstevel@tonic-gate  				}
2380Sstevel@tonic-gate  			}
2390Sstevel@tonic-gate  			goto next;
2400Sstevel@tonic-gate  		}
2410Sstevel@tonic-gate #endif
2420Sstevel@tonic-gate 		if (cp[0] == 'n' && cp[1] == 'o' && cp[2] != 'v') {
2430Sstevel@tonic-gate 			cp += 2;
2440Sstevel@tonic-gate 			no++;
2450Sstevel@tonic-gate 		}
2460Sstevel@tonic-gate 		/* Implement w300, w1200, and w9600 specially */
2470Sstevel@tonic-gate 		if (eq(cp, "w300")) {
2480Sstevel@tonic-gate 			if (ospeed >= B1200) {
2490Sstevel@tonic-gate dontset:
2500Sstevel@tonic-gate 				(void)getchar();	/* = */
2510Sstevel@tonic-gate 				(void)getnum();	/* value */
2520Sstevel@tonic-gate 				continue;
2530Sstevel@tonic-gate 			}
2540Sstevel@tonic-gate 			cp = (unsigned char *)"window";
2550Sstevel@tonic-gate 		} else if (eq(cp, "w1200")) {
2560Sstevel@tonic-gate 			if (ospeed < B1200 || ospeed >= B2400)
2570Sstevel@tonic-gate 				goto dontset;
2580Sstevel@tonic-gate 			cp = (unsigned char *)"window";
2590Sstevel@tonic-gate 		} else if (eq(cp, "w9600")) {
2600Sstevel@tonic-gate 			if (ospeed < B2400)
2610Sstevel@tonic-gate 				goto dontset;
2620Sstevel@tonic-gate 			cp = (unsigned char *)"window";
2630Sstevel@tonic-gate 		}
2640Sstevel@tonic-gate 		for (op = options; op < &options[vi_NOPTS]; op++)
2650Sstevel@tonic-gate 			if (eq(op->oname, cp) || op->oabbrev && eq(op->oabbrev, cp))
2660Sstevel@tonic-gate 				break;
2670Sstevel@tonic-gate 		if (op->oname == 0)
268*802Scf46844 			serror(value(vi_TERSE) ? (unsigned char *)
269*802Scf46844 			    gettext("%s: No such option") :
270*802Scf46844 			    (unsigned char *)
2710Sstevel@tonic-gate gettext("%s: No such option - 'set all' gives all option values"), cp);
2720Sstevel@tonic-gate 		c = skipwh();
2730Sstevel@tonic-gate 		if (peekchar() == '?') {
2740Sstevel@tonic-gate 			ignchar();
2750Sstevel@tonic-gate printone:
2760Sstevel@tonic-gate 			propt(op);
2770Sstevel@tonic-gate 			noonl();
2780Sstevel@tonic-gate 			goto next;
2790Sstevel@tonic-gate 		}
2800Sstevel@tonic-gate 		if (op->otype == ONOFF) {
2810Sstevel@tonic-gate 			op->ovalue = 1 - no;
2820Sstevel@tonic-gate 			if (op == &options[vi_PROMPT])
2830Sstevel@tonic-gate 				oprompt = 1 - no;
2840Sstevel@tonic-gate 			goto next;
2850Sstevel@tonic-gate 		}
2860Sstevel@tonic-gate 		if (no)
287*802Scf46844 			serror((unsigned char *)
288*802Scf46844 			    gettext("Option %s is not a toggle"), op->oname);
2890Sstevel@tonic-gate 		if (c != 0 || setend())
2900Sstevel@tonic-gate 			goto printone;
2910Sstevel@tonic-gate 		if (getchar() != '=')
292*802Scf46844 			serror(value(vi_TERSE) ? (unsigned char *)
293*802Scf46844 			    gettext("Missing =") :
294*802Scf46844 			    (unsigned char *)
295*802Scf46844 			    gettext("Missing = in assignment to option %s"),
296*802Scf46844 			    op->oname);
2970Sstevel@tonic-gate 		switch (op->otype) {
2980Sstevel@tonic-gate 
2990Sstevel@tonic-gate 		case NUMERIC:
3000Sstevel@tonic-gate 			if (!isdigit(peekchar()))
3010Sstevel@tonic-gate 				error(value(vi_TERSE) ?
3020Sstevel@tonic-gate gettext("Digits required") : gettext("Digits required after ="));
3030Sstevel@tonic-gate 			op->ovalue = getnum();
3040Sstevel@tonic-gate 			if (value(vi_TABSTOP) <= 0)
3050Sstevel@tonic-gate 				value(vi_TABSTOP) = TABS;
3060Sstevel@tonic-gate 			if (op == &options[vi_WINDOW]) {
3070Sstevel@tonic-gate 				if (value(vi_WINDOW) >= lines)
3080Sstevel@tonic-gate 					value(vi_WINDOW) = lines-1;
3090Sstevel@tonic-gate 				vsetsiz(value(vi_WINDOW));
3100Sstevel@tonic-gate 			}
3110Sstevel@tonic-gate 			break;
3120Sstevel@tonic-gate 
3130Sstevel@tonic-gate 		case STRING:
3140Sstevel@tonic-gate 		case OTERM:
3150Sstevel@tonic-gate 			cp = optname;
3160Sstevel@tonic-gate 			while (!setend()) {
3170Sstevel@tonic-gate 				if (cp >= &optname[ONMSZ])
3180Sstevel@tonic-gate 					error(value(vi_TERSE) ?
3190Sstevel@tonic-gate gettext("String too long") : gettext("String too long in option assignment"));
3200Sstevel@tonic-gate 				/* adb change:  allow whitepace in strings */
3210Sstevel@tonic-gate 				if( (*cp = getchar()) == '\\')
3220Sstevel@tonic-gate 					if( peekchar() != EOF)
3230Sstevel@tonic-gate 						*cp = getchar();
3240Sstevel@tonic-gate 				cp++;
3250Sstevel@tonic-gate 			}
3260Sstevel@tonic-gate 			*cp = 0;
3270Sstevel@tonic-gate 			if (op->otype == OTERM) {
3280Sstevel@tonic-gate /*
3290Sstevel@tonic-gate  * At first glance it seems like we shouldn't care if the terminal type
3300Sstevel@tonic-gate  * is changed inside visual mode, as long as we assume the screen is
3310Sstevel@tonic-gate  * a mess and redraw it. However, it's a much harder problem than that.
3320Sstevel@tonic-gate  * If you happen to change from 1 crt to another that both have the same
3330Sstevel@tonic-gate  * size screen, it's OK. But if the screen size if different, the stuff
3340Sstevel@tonic-gate  * that gets initialized in vop() will be wrong. This could be overcome
3350Sstevel@tonic-gate  * by redoing the initialization, e.g. making the first 90% of vop into
3360Sstevel@tonic-gate  * a subroutine. However, the most useful case is where you forgot to do
3370Sstevel@tonic-gate  * a setenv before you went into the editor and it thinks you're on a dumb
3380Sstevel@tonic-gate  * terminal. Ex treats this like hardcopy and goes into HARDOPEN mode.
3390Sstevel@tonic-gate  * This loses because the first part of vop calls oop in this case.
3400Sstevel@tonic-gate  */
3410Sstevel@tonic-gate 				if (inopen)
3420Sstevel@tonic-gate error(gettext("Can't change type of terminal from within open/visual"));
3430Sstevel@tonic-gate 				unterm();
3440Sstevel@tonic-gate 				setterm(optname);
3450Sstevel@tonic-gate 			} else {
3460Sstevel@tonic-gate 				CP(op->osvalue, optname);
3470Sstevel@tonic-gate 				op->odefault = 1;
3480Sstevel@tonic-gate 			}
3490Sstevel@tonic-gate 			break;
3500Sstevel@tonic-gate 		}
3510Sstevel@tonic-gate next:
3520Sstevel@tonic-gate 		flush();
3530Sstevel@tonic-gate 	} while (!skipend());
3540Sstevel@tonic-gate 	eol();
3550Sstevel@tonic-gate }
3560Sstevel@tonic-gate 
357*802Scf46844 void
358*802Scf46844 unterm(void)
3590Sstevel@tonic-gate {
3600Sstevel@tonic-gate 	/*
3610Sstevel@tonic-gate 	 *  All terminal mapped statements must be deleted.
3620Sstevel@tonic-gate 	 *  All user-defined mapped statements, cap=descr,
3630Sstevel@tonic-gate 	 *  are left unchanged.
3640Sstevel@tonic-gate 	 */
3650Sstevel@tonic-gate 
3660Sstevel@tonic-gate 	int i;
3670Sstevel@tonic-gate 
3680Sstevel@tonic-gate 	for (i=0; i < MAXNOMACS; i++) {
3690Sstevel@tonic-gate 
3700Sstevel@tonic-gate 		/*
3710Sstevel@tonic-gate 		 * Unmap any terminal-defined arrow keys
3720Sstevel@tonic-gate 		 */
3730Sstevel@tonic-gate 
3740Sstevel@tonic-gate 		if (arrows[i].cap && arrows[i].descr &&
3750Sstevel@tonic-gate 		    strcmp(arrows[i].cap, arrows[i].descr))
3760Sstevel@tonic-gate 			addmac(arrows[i].cap, NOSTR, NOSTR, arrows);
3770Sstevel@tonic-gate 
3780Sstevel@tonic-gate 		/*
3790Sstevel@tonic-gate 		 * Unmap any terminal-defined function keys
3800Sstevel@tonic-gate 		 */
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate 		if (immacs[i].cap && immacs[i].descr && strcmp(immacs[i].cap, immacs[i].descr))
3830Sstevel@tonic-gate 			addmac(immacs[i].cap, NOSTR, NOSTR, immacs);
3840Sstevel@tonic-gate 
3850Sstevel@tonic-gate 	}
3860Sstevel@tonic-gate }
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate 
389*802Scf46844 int
390*802Scf46844 setend(void)
3910Sstevel@tonic-gate {
3920Sstevel@tonic-gate 
3930Sstevel@tonic-gate 	return (iswhite(peekchar()) || endcmd(peekchar()));
3940Sstevel@tonic-gate }
3950Sstevel@tonic-gate 
396*802Scf46844 void
397*802Scf46844 prall(void)
3980Sstevel@tonic-gate {
399*802Scf46844 	int incr = (vi_NOPTS + 2) / 3;
400*802Scf46844 	int rows = incr;
401*802Scf46844 	struct option *op = options;
4020Sstevel@tonic-gate 
4030Sstevel@tonic-gate 	for (; rows; rows--, op++) {
4040Sstevel@tonic-gate 		propt(op);
4050Sstevel@tonic-gate 		gotab(24);
4060Sstevel@tonic-gate 		propt(&op[incr]);
4070Sstevel@tonic-gate 		if (&op[2*incr] < &options[vi_NOPTS]) {
4080Sstevel@tonic-gate 			gotab(56);
4090Sstevel@tonic-gate 			propt(&op[2 * incr]);
4100Sstevel@tonic-gate 		}
4110Sstevel@tonic-gate 		putNFL();
4120Sstevel@tonic-gate 	}
4130Sstevel@tonic-gate }
4140Sstevel@tonic-gate 
415*802Scf46844 void
416*802Scf46844 propts(void)
4170Sstevel@tonic-gate {
418*802Scf46844 	struct option *op;
4190Sstevel@tonic-gate 
4200Sstevel@tonic-gate 	for (op = options; op < &options[vi_NOPTS]; op++) {
4210Sstevel@tonic-gate 		if (op == &options[vi_TTYTYPE])
4220Sstevel@tonic-gate 			continue;
4230Sstevel@tonic-gate 		switch (op->otype) {
4240Sstevel@tonic-gate 
4250Sstevel@tonic-gate 		case ONOFF:
4260Sstevel@tonic-gate 		case NUMERIC:
4270Sstevel@tonic-gate 			if (op->ovalue == op->odefault)
4280Sstevel@tonic-gate 				continue;
4290Sstevel@tonic-gate 			break;
4300Sstevel@tonic-gate 
4310Sstevel@tonic-gate 		case STRING:
4320Sstevel@tonic-gate 			if (op->odefault == 0)
4330Sstevel@tonic-gate 				continue;
4340Sstevel@tonic-gate 			break;
4350Sstevel@tonic-gate 		}
4360Sstevel@tonic-gate 		propt(op);
4370Sstevel@tonic-gate 		putchar(' ');
4380Sstevel@tonic-gate 	}
4390Sstevel@tonic-gate 	noonl();
4400Sstevel@tonic-gate 	flush();
4410Sstevel@tonic-gate }
4420Sstevel@tonic-gate 
443*802Scf46844 void
444*802Scf46844 propt(struct option *op)
4450Sstevel@tonic-gate {
446*802Scf46844 	unsigned char *name;
4470Sstevel@tonic-gate 
4480Sstevel@tonic-gate 	name = (unsigned char *)op->oname;
4490Sstevel@tonic-gate 
4500Sstevel@tonic-gate 	switch (op->otype) {
4510Sstevel@tonic-gate 
4520Sstevel@tonic-gate 	case ONOFF:
453*802Scf46844 		viprintf("%s%s", op->ovalue ? "" : "no", name);
4540Sstevel@tonic-gate 		break;
4550Sstevel@tonic-gate 
4560Sstevel@tonic-gate 	case NUMERIC:
457*802Scf46844 		viprintf("%s=%d", name, op->ovalue);
4580Sstevel@tonic-gate 		break;
4590Sstevel@tonic-gate 
4600Sstevel@tonic-gate 	case STRING:
4610Sstevel@tonic-gate 	case OTERM:
462*802Scf46844 		viprintf("%s=%s", name, op->osvalue);
4630Sstevel@tonic-gate 		break;
4640Sstevel@tonic-gate 	}
4650Sstevel@tonic-gate }
466