xref: /titanic_53/usr/src/cmd/sh/func.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*7c478bd9Sstevel@tonic-gate 
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate /*
27*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1996, by Sun Microsystems, Inc.
28*7c478bd9Sstevel@tonic-gate  * All rights reserved.
29*7c478bd9Sstevel@tonic-gate  */
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.4.1.3	*/
32*7c478bd9Sstevel@tonic-gate /*
33*7c478bd9Sstevel@tonic-gate  * UNIX shell
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #include	"defs.h"
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate freefunc(n)
39*7c478bd9Sstevel@tonic-gate 	struct namnod 	*n;
40*7c478bd9Sstevel@tonic-gate {
41*7c478bd9Sstevel@tonic-gate 	freetree((struct trenod *)(n->namenv));
42*7c478bd9Sstevel@tonic-gate }
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate freetree(t)
46*7c478bd9Sstevel@tonic-gate 	register struct trenod *t;
47*7c478bd9Sstevel@tonic-gate {
48*7c478bd9Sstevel@tonic-gate 	if (t)
49*7c478bd9Sstevel@tonic-gate 	{
50*7c478bd9Sstevel@tonic-gate 		register int type;
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate 		if (t->tretyp & CNTMSK)
53*7c478bd9Sstevel@tonic-gate 		{
54*7c478bd9Sstevel@tonic-gate 			t->tretyp--;
55*7c478bd9Sstevel@tonic-gate 			return;
56*7c478bd9Sstevel@tonic-gate 		}
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate 		type = t->tretyp & COMMSK;
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate 		switch (type)
61*7c478bd9Sstevel@tonic-gate 		{
62*7c478bd9Sstevel@tonic-gate 			case TFND:
63*7c478bd9Sstevel@tonic-gate 				free(fndptr(t)->fndnam);
64*7c478bd9Sstevel@tonic-gate 				freetree(fndptr(t)->fndval);
65*7c478bd9Sstevel@tonic-gate 				break;
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate 			case TCOM:
68*7c478bd9Sstevel@tonic-gate 				freeio(comptr(t)->comio);
69*7c478bd9Sstevel@tonic-gate 				free_arg(comptr(t)->comarg);
70*7c478bd9Sstevel@tonic-gate 				free_arg(comptr(t)->comset);
71*7c478bd9Sstevel@tonic-gate 				break;
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate 			case TFORK:
74*7c478bd9Sstevel@tonic-gate 				freeio(forkptr(t)->forkio);
75*7c478bd9Sstevel@tonic-gate 				freetree(forkptr(t)->forktre);
76*7c478bd9Sstevel@tonic-gate 				break;
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate 			case TPAR:
79*7c478bd9Sstevel@tonic-gate 				freetree(parptr(t)->partre);
80*7c478bd9Sstevel@tonic-gate 				break;
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate 			case TFIL:
83*7c478bd9Sstevel@tonic-gate 			case TLST:
84*7c478bd9Sstevel@tonic-gate 			case TAND:
85*7c478bd9Sstevel@tonic-gate 			case TORF:
86*7c478bd9Sstevel@tonic-gate 				freetree(lstptr(t)->lstlef);
87*7c478bd9Sstevel@tonic-gate 				freetree(lstptr(t)->lstrit);
88*7c478bd9Sstevel@tonic-gate 				break;
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate 			case TFOR:
91*7c478bd9Sstevel@tonic-gate 			{
92*7c478bd9Sstevel@tonic-gate 				struct fornod *f = (struct fornod *)t;
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate 				free(f->fornam);
95*7c478bd9Sstevel@tonic-gate 				freetree(f->fortre);
96*7c478bd9Sstevel@tonic-gate 				if (f->forlst)
97*7c478bd9Sstevel@tonic-gate 				{
98*7c478bd9Sstevel@tonic-gate 					freeio(f->forlst->comio);
99*7c478bd9Sstevel@tonic-gate 					free_arg(f->forlst->comarg);
100*7c478bd9Sstevel@tonic-gate 					free_arg(f->forlst->comset);
101*7c478bd9Sstevel@tonic-gate 					free(f->forlst);
102*7c478bd9Sstevel@tonic-gate 				}
103*7c478bd9Sstevel@tonic-gate 			}
104*7c478bd9Sstevel@tonic-gate 			break;
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate 			case TWH:
107*7c478bd9Sstevel@tonic-gate 			case TUN:
108*7c478bd9Sstevel@tonic-gate 				freetree(whptr(t)->whtre);
109*7c478bd9Sstevel@tonic-gate 				freetree(whptr(t)->dotre);
110*7c478bd9Sstevel@tonic-gate 				break;
111*7c478bd9Sstevel@tonic-gate 
112*7c478bd9Sstevel@tonic-gate 			case TIF:
113*7c478bd9Sstevel@tonic-gate 				freetree(ifptr(t)->iftre);
114*7c478bd9Sstevel@tonic-gate 				freetree(ifptr(t)->thtre);
115*7c478bd9Sstevel@tonic-gate 				freetree(ifptr(t)->eltre);
116*7c478bd9Sstevel@tonic-gate 				break;
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate 			case TSW:
119*7c478bd9Sstevel@tonic-gate 				free(swptr(t)->swarg);
120*7c478bd9Sstevel@tonic-gate 				freereg(swptr(t)->swlst);
121*7c478bd9Sstevel@tonic-gate 				break;
122*7c478bd9Sstevel@tonic-gate 		}
123*7c478bd9Sstevel@tonic-gate 		free(t);
124*7c478bd9Sstevel@tonic-gate 	}
125*7c478bd9Sstevel@tonic-gate }
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate free_arg(argp)
128*7c478bd9Sstevel@tonic-gate 	register struct argnod 	*argp;
129*7c478bd9Sstevel@tonic-gate {
130*7c478bd9Sstevel@tonic-gate 	register struct argnod 	*sav;
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate 	while (argp)
133*7c478bd9Sstevel@tonic-gate 	{
134*7c478bd9Sstevel@tonic-gate 		sav = argp->argnxt;
135*7c478bd9Sstevel@tonic-gate 		free(argp);
136*7c478bd9Sstevel@tonic-gate 		argp = sav;
137*7c478bd9Sstevel@tonic-gate 	}
138*7c478bd9Sstevel@tonic-gate }
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate freeio(iop)
142*7c478bd9Sstevel@tonic-gate 	register struct ionod *iop;
143*7c478bd9Sstevel@tonic-gate {
144*7c478bd9Sstevel@tonic-gate 	register struct ionod *sav;
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate 	while (iop)
147*7c478bd9Sstevel@tonic-gate 	{
148*7c478bd9Sstevel@tonic-gate 		if (iop->iofile & IODOC)
149*7c478bd9Sstevel@tonic-gate 		{
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate #ifdef DEBUG
152*7c478bd9Sstevel@tonic-gate 			prs("unlinking ");
153*7c478bd9Sstevel@tonic-gate 			prs(iop->ioname);
154*7c478bd9Sstevel@tonic-gate 			newline();
155*7c478bd9Sstevel@tonic-gate #endif
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate 			unlink(iop->ioname);
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate 			if (fiotemp == iop)
160*7c478bd9Sstevel@tonic-gate 				fiotemp = iop->iolst;
161*7c478bd9Sstevel@tonic-gate 			else
162*7c478bd9Sstevel@tonic-gate 			{
163*7c478bd9Sstevel@tonic-gate 				struct ionod *fiop = fiotemp;
164*7c478bd9Sstevel@tonic-gate 
165*7c478bd9Sstevel@tonic-gate 				while (fiop->iolst != iop)
166*7c478bd9Sstevel@tonic-gate 					fiop = fiop->iolst;
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate 				fiop->iolst = iop->iolst;
169*7c478bd9Sstevel@tonic-gate 			}
170*7c478bd9Sstevel@tonic-gate 		}
171*7c478bd9Sstevel@tonic-gate 		free(iop->ioname);
172*7c478bd9Sstevel@tonic-gate 		free(iop->iolink);
173*7c478bd9Sstevel@tonic-gate 		sav = iop->ionxt;
174*7c478bd9Sstevel@tonic-gate 		free(iop);
175*7c478bd9Sstevel@tonic-gate 		iop = sav;
176*7c478bd9Sstevel@tonic-gate 	}
177*7c478bd9Sstevel@tonic-gate }
178*7c478bd9Sstevel@tonic-gate 
179*7c478bd9Sstevel@tonic-gate 
180*7c478bd9Sstevel@tonic-gate freereg(regp)
181*7c478bd9Sstevel@tonic-gate 	register struct regnod 	*regp;
182*7c478bd9Sstevel@tonic-gate {
183*7c478bd9Sstevel@tonic-gate 	register struct regnod 	*sav;
184*7c478bd9Sstevel@tonic-gate 
185*7c478bd9Sstevel@tonic-gate 	while (regp)
186*7c478bd9Sstevel@tonic-gate 	{
187*7c478bd9Sstevel@tonic-gate 		free_arg(regp->regptr);
188*7c478bd9Sstevel@tonic-gate 		freetree(regp->regcom);
189*7c478bd9Sstevel@tonic-gate 		sav = regp->regnxt;
190*7c478bd9Sstevel@tonic-gate 		free(regp);
191*7c478bd9Sstevel@tonic-gate 		regp = sav;
192*7c478bd9Sstevel@tonic-gate 	}
193*7c478bd9Sstevel@tonic-gate }
194*7c478bd9Sstevel@tonic-gate 
195*7c478bd9Sstevel@tonic-gate 
196*7c478bd9Sstevel@tonic-gate static nonl = 0;
197*7c478bd9Sstevel@tonic-gate 
198*7c478bd9Sstevel@tonic-gate prbgnlst()
199*7c478bd9Sstevel@tonic-gate {
200*7c478bd9Sstevel@tonic-gate 	if (nonl)
201*7c478bd9Sstevel@tonic-gate 		prc_buff(SPACE);
202*7c478bd9Sstevel@tonic-gate 	else
203*7c478bd9Sstevel@tonic-gate 		prc_buff(NL);
204*7c478bd9Sstevel@tonic-gate }
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate prendlst()
207*7c478bd9Sstevel@tonic-gate {
208*7c478bd9Sstevel@tonic-gate 	if (nonl) {
209*7c478bd9Sstevel@tonic-gate 		prc_buff(';');
210*7c478bd9Sstevel@tonic-gate 		prc_buff(SPACE);
211*7c478bd9Sstevel@tonic-gate 	}
212*7c478bd9Sstevel@tonic-gate 	else
213*7c478bd9Sstevel@tonic-gate 		prc_buff(NL);
214*7c478bd9Sstevel@tonic-gate }
215*7c478bd9Sstevel@tonic-gate 
216*7c478bd9Sstevel@tonic-gate prcmd(t)
217*7c478bd9Sstevel@tonic-gate {
218*7c478bd9Sstevel@tonic-gate 	nonl++;
219*7c478bd9Sstevel@tonic-gate 	prf(t);
220*7c478bd9Sstevel@tonic-gate 	nonl = 0;
221*7c478bd9Sstevel@tonic-gate }
222*7c478bd9Sstevel@tonic-gate 
223*7c478bd9Sstevel@tonic-gate prf(t)
224*7c478bd9Sstevel@tonic-gate 	register struct trenod	*t;
225*7c478bd9Sstevel@tonic-gate {
226*7c478bd9Sstevel@tonic-gate 	sigchk();
227*7c478bd9Sstevel@tonic-gate 
228*7c478bd9Sstevel@tonic-gate 	if (t)
229*7c478bd9Sstevel@tonic-gate 	{
230*7c478bd9Sstevel@tonic-gate 		register int	type;
231*7c478bd9Sstevel@tonic-gate 
232*7c478bd9Sstevel@tonic-gate 		type = t->tretyp & COMMSK;
233*7c478bd9Sstevel@tonic-gate 
234*7c478bd9Sstevel@tonic-gate 		switch(type)
235*7c478bd9Sstevel@tonic-gate 		{
236*7c478bd9Sstevel@tonic-gate 			case TFND:
237*7c478bd9Sstevel@tonic-gate 			{
238*7c478bd9Sstevel@tonic-gate 				register struct fndnod *f = (struct fndnod *)t;
239*7c478bd9Sstevel@tonic-gate 
240*7c478bd9Sstevel@tonic-gate 				prs_buff(f->fndnam);
241*7c478bd9Sstevel@tonic-gate 				prs_buff("(){");
242*7c478bd9Sstevel@tonic-gate 				prbgnlst();
243*7c478bd9Sstevel@tonic-gate 				prf(f->fndval);
244*7c478bd9Sstevel@tonic-gate 				prbgnlst();
245*7c478bd9Sstevel@tonic-gate 				prs_buff("}");
246*7c478bd9Sstevel@tonic-gate 				break;
247*7c478bd9Sstevel@tonic-gate 			}
248*7c478bd9Sstevel@tonic-gate 
249*7c478bd9Sstevel@tonic-gate 			case TCOM:
250*7c478bd9Sstevel@tonic-gate 				if (comptr(t)->comset) {
251*7c478bd9Sstevel@tonic-gate 					prarg(comptr(t)->comset);
252*7c478bd9Sstevel@tonic-gate 					prc_buff(SPACE);
253*7c478bd9Sstevel@tonic-gate 				}
254*7c478bd9Sstevel@tonic-gate 				prarg(comptr(t)->comarg);
255*7c478bd9Sstevel@tonic-gate 				prio(comptr(t)->comio);
256*7c478bd9Sstevel@tonic-gate 				break;
257*7c478bd9Sstevel@tonic-gate 
258*7c478bd9Sstevel@tonic-gate 			case TFORK:
259*7c478bd9Sstevel@tonic-gate 				prf(forkptr(t)->forktre);
260*7c478bd9Sstevel@tonic-gate 				prio(forkptr(t)->forkio);
261*7c478bd9Sstevel@tonic-gate 				if (forkptr(t)->forktyp & FAMP)
262*7c478bd9Sstevel@tonic-gate 					prs_buff(" &");
263*7c478bd9Sstevel@tonic-gate 				break;
264*7c478bd9Sstevel@tonic-gate 
265*7c478bd9Sstevel@tonic-gate 			case TPAR:
266*7c478bd9Sstevel@tonic-gate 				prs_buff("(");
267*7c478bd9Sstevel@tonic-gate 				prf(parptr(t)->partre);
268*7c478bd9Sstevel@tonic-gate 				prs_buff(")");
269*7c478bd9Sstevel@tonic-gate 				break;
270*7c478bd9Sstevel@tonic-gate 
271*7c478bd9Sstevel@tonic-gate 			case TFIL:
272*7c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstlef);
273*7c478bd9Sstevel@tonic-gate 				prs_buff(" | ");
274*7c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstrit);
275*7c478bd9Sstevel@tonic-gate 				break;
276*7c478bd9Sstevel@tonic-gate 
277*7c478bd9Sstevel@tonic-gate 			case TLST:
278*7c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstlef);
279*7c478bd9Sstevel@tonic-gate 				prendlst();
280*7c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstrit);
281*7c478bd9Sstevel@tonic-gate 				break;
282*7c478bd9Sstevel@tonic-gate 
283*7c478bd9Sstevel@tonic-gate 			case TAND:
284*7c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstlef);
285*7c478bd9Sstevel@tonic-gate 				prs_buff(" && ");
286*7c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstrit);
287*7c478bd9Sstevel@tonic-gate 				break;
288*7c478bd9Sstevel@tonic-gate 
289*7c478bd9Sstevel@tonic-gate 			case TORF:
290*7c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstlef);
291*7c478bd9Sstevel@tonic-gate 				prs_buff(" || ");
292*7c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstrit);
293*7c478bd9Sstevel@tonic-gate 				break;
294*7c478bd9Sstevel@tonic-gate 
295*7c478bd9Sstevel@tonic-gate 			case TFOR:
296*7c478bd9Sstevel@tonic-gate 				{
297*7c478bd9Sstevel@tonic-gate 					register struct argnod	*arg;
298*7c478bd9Sstevel@tonic-gate 					register struct fornod 	*f = (struct fornod *)t;
299*7c478bd9Sstevel@tonic-gate 
300*7c478bd9Sstevel@tonic-gate 					prs_buff("for ");
301*7c478bd9Sstevel@tonic-gate 					prs_buff(f->fornam);
302*7c478bd9Sstevel@tonic-gate 
303*7c478bd9Sstevel@tonic-gate 					if (f->forlst)
304*7c478bd9Sstevel@tonic-gate 					{
305*7c478bd9Sstevel@tonic-gate 						arg = f->forlst->comarg;
306*7c478bd9Sstevel@tonic-gate 						prs_buff(" in");
307*7c478bd9Sstevel@tonic-gate 
308*7c478bd9Sstevel@tonic-gate 						while(arg != ENDARGS)
309*7c478bd9Sstevel@tonic-gate 						{
310*7c478bd9Sstevel@tonic-gate 							prc_buff(SPACE);
311*7c478bd9Sstevel@tonic-gate 							prs_buff(arg->argval);
312*7c478bd9Sstevel@tonic-gate 							arg = arg->argnxt;
313*7c478bd9Sstevel@tonic-gate 						}
314*7c478bd9Sstevel@tonic-gate 					}
315*7c478bd9Sstevel@tonic-gate 
316*7c478bd9Sstevel@tonic-gate 					prendlst();
317*7c478bd9Sstevel@tonic-gate 					prs_buff("do");
318*7c478bd9Sstevel@tonic-gate 					prbgnlst();
319*7c478bd9Sstevel@tonic-gate 					prf(f->fortre);
320*7c478bd9Sstevel@tonic-gate 					prendlst();
321*7c478bd9Sstevel@tonic-gate 					prs_buff("done");
322*7c478bd9Sstevel@tonic-gate 				}
323*7c478bd9Sstevel@tonic-gate 				break;
324*7c478bd9Sstevel@tonic-gate 
325*7c478bd9Sstevel@tonic-gate 			case TWH:
326*7c478bd9Sstevel@tonic-gate 			case TUN:
327*7c478bd9Sstevel@tonic-gate 				if (type == TWH)
328*7c478bd9Sstevel@tonic-gate 					prs_buff("while ");
329*7c478bd9Sstevel@tonic-gate 				else
330*7c478bd9Sstevel@tonic-gate 					prs_buff("until ");
331*7c478bd9Sstevel@tonic-gate 				prf(whptr(t)->whtre);
332*7c478bd9Sstevel@tonic-gate 				prendlst();
333*7c478bd9Sstevel@tonic-gate 				prs_buff("do");
334*7c478bd9Sstevel@tonic-gate 				prbgnlst();
335*7c478bd9Sstevel@tonic-gate 				prf(whptr(t)->dotre);
336*7c478bd9Sstevel@tonic-gate 				prendlst();
337*7c478bd9Sstevel@tonic-gate 				prs_buff("done");
338*7c478bd9Sstevel@tonic-gate 				break;
339*7c478bd9Sstevel@tonic-gate 
340*7c478bd9Sstevel@tonic-gate 			case TIF:
341*7c478bd9Sstevel@tonic-gate 			{
342*7c478bd9Sstevel@tonic-gate 				struct ifnod *f = (struct ifnod *)t;
343*7c478bd9Sstevel@tonic-gate 
344*7c478bd9Sstevel@tonic-gate 				prs_buff("if ");
345*7c478bd9Sstevel@tonic-gate 				prf(f->iftre);
346*7c478bd9Sstevel@tonic-gate 				prendlst();
347*7c478bd9Sstevel@tonic-gate 				prs_buff("then");
348*7c478bd9Sstevel@tonic-gate 				prendlst();
349*7c478bd9Sstevel@tonic-gate 				prf(f->thtre);
350*7c478bd9Sstevel@tonic-gate 
351*7c478bd9Sstevel@tonic-gate 				if (f->eltre)
352*7c478bd9Sstevel@tonic-gate 				{
353*7c478bd9Sstevel@tonic-gate 					prendlst();
354*7c478bd9Sstevel@tonic-gate 					prs_buff("else");
355*7c478bd9Sstevel@tonic-gate 					prendlst();
356*7c478bd9Sstevel@tonic-gate 					prf(f->eltre);
357*7c478bd9Sstevel@tonic-gate 				}
358*7c478bd9Sstevel@tonic-gate 
359*7c478bd9Sstevel@tonic-gate 				prendlst();
360*7c478bd9Sstevel@tonic-gate 				prs_buff("fi");
361*7c478bd9Sstevel@tonic-gate 				break;
362*7c478bd9Sstevel@tonic-gate 			}
363*7c478bd9Sstevel@tonic-gate 
364*7c478bd9Sstevel@tonic-gate 			case TSW:
365*7c478bd9Sstevel@tonic-gate 				{
366*7c478bd9Sstevel@tonic-gate 					register struct regnod 	*swl;
367*7c478bd9Sstevel@tonic-gate 
368*7c478bd9Sstevel@tonic-gate 					prs_buff("case ");
369*7c478bd9Sstevel@tonic-gate 					prs_buff(swptr(t)->swarg);
370*7c478bd9Sstevel@tonic-gate 
371*7c478bd9Sstevel@tonic-gate 					swl = swptr(t)->swlst;
372*7c478bd9Sstevel@tonic-gate 					while(swl)
373*7c478bd9Sstevel@tonic-gate 					{
374*7c478bd9Sstevel@tonic-gate 						struct argnod	*arg = swl->regptr;
375*7c478bd9Sstevel@tonic-gate 
376*7c478bd9Sstevel@tonic-gate 						if (arg)
377*7c478bd9Sstevel@tonic-gate 						{
378*7c478bd9Sstevel@tonic-gate 							prs_buff(arg->argval);
379*7c478bd9Sstevel@tonic-gate 							arg = arg->argnxt;
380*7c478bd9Sstevel@tonic-gate 						}
381*7c478bd9Sstevel@tonic-gate 
382*7c478bd9Sstevel@tonic-gate 						while(arg)
383*7c478bd9Sstevel@tonic-gate 						{
384*7c478bd9Sstevel@tonic-gate 							prs_buff(" | ");
385*7c478bd9Sstevel@tonic-gate 							prs_buff(arg->argval);
386*7c478bd9Sstevel@tonic-gate 							arg = arg->argnxt;
387*7c478bd9Sstevel@tonic-gate 						}
388*7c478bd9Sstevel@tonic-gate 
389*7c478bd9Sstevel@tonic-gate 						prs_buff(")");
390*7c478bd9Sstevel@tonic-gate 						prf(swl->regcom);
391*7c478bd9Sstevel@tonic-gate 						prs_buff(";;");
392*7c478bd9Sstevel@tonic-gate 						swl = swl->regnxt;
393*7c478bd9Sstevel@tonic-gate 					}
394*7c478bd9Sstevel@tonic-gate 				}
395*7c478bd9Sstevel@tonic-gate 				break;
396*7c478bd9Sstevel@tonic-gate 			}
397*7c478bd9Sstevel@tonic-gate 		}
398*7c478bd9Sstevel@tonic-gate 
399*7c478bd9Sstevel@tonic-gate 	sigchk();
400*7c478bd9Sstevel@tonic-gate }
401*7c478bd9Sstevel@tonic-gate 
402*7c478bd9Sstevel@tonic-gate prarg(argp)
403*7c478bd9Sstevel@tonic-gate 	register struct argnod	*argp;
404*7c478bd9Sstevel@tonic-gate {
405*7c478bd9Sstevel@tonic-gate 	while (argp)
406*7c478bd9Sstevel@tonic-gate 	{
407*7c478bd9Sstevel@tonic-gate 		prs_buff(argp->argval);
408*7c478bd9Sstevel@tonic-gate 		argp=argp->argnxt;
409*7c478bd9Sstevel@tonic-gate 		if (argp)
410*7c478bd9Sstevel@tonic-gate 			prc_buff(SPACE);
411*7c478bd9Sstevel@tonic-gate 	}
412*7c478bd9Sstevel@tonic-gate }
413*7c478bd9Sstevel@tonic-gate 
414*7c478bd9Sstevel@tonic-gate 
415*7c478bd9Sstevel@tonic-gate prio(iop)
416*7c478bd9Sstevel@tonic-gate 	register struct ionod	*iop;
417*7c478bd9Sstevel@tonic-gate {
418*7c478bd9Sstevel@tonic-gate 	register int	iof;
419*7c478bd9Sstevel@tonic-gate 	register unsigned char	*ion;
420*7c478bd9Sstevel@tonic-gate 
421*7c478bd9Sstevel@tonic-gate 	while (iop)
422*7c478bd9Sstevel@tonic-gate 	{
423*7c478bd9Sstevel@tonic-gate 		iof = iop->iofile;
424*7c478bd9Sstevel@tonic-gate 		ion = (unsigned char *) iop->ioname;
425*7c478bd9Sstevel@tonic-gate 
426*7c478bd9Sstevel@tonic-gate 		if (*ion)
427*7c478bd9Sstevel@tonic-gate 		{
428*7c478bd9Sstevel@tonic-gate 			prc_buff(SPACE);
429*7c478bd9Sstevel@tonic-gate 
430*7c478bd9Sstevel@tonic-gate 			prn_buff(iof & IOUFD);
431*7c478bd9Sstevel@tonic-gate 
432*7c478bd9Sstevel@tonic-gate 			if (iof & IODOC)
433*7c478bd9Sstevel@tonic-gate 				prs_buff("<<");
434*7c478bd9Sstevel@tonic-gate 			else if (iof & IOMOV)
435*7c478bd9Sstevel@tonic-gate 			{
436*7c478bd9Sstevel@tonic-gate 				if (iof & IOPUT)
437*7c478bd9Sstevel@tonic-gate 					prs_buff(">&");
438*7c478bd9Sstevel@tonic-gate 				else
439*7c478bd9Sstevel@tonic-gate 					prs_buff("<&");
440*7c478bd9Sstevel@tonic-gate 
441*7c478bd9Sstevel@tonic-gate 			}
442*7c478bd9Sstevel@tonic-gate 			else if ((iof & IOPUT) == 0)
443*7c478bd9Sstevel@tonic-gate 				prc_buff('<');
444*7c478bd9Sstevel@tonic-gate 			else if (iof & IOAPP)
445*7c478bd9Sstevel@tonic-gate 				prs_buff(">>");
446*7c478bd9Sstevel@tonic-gate 			else
447*7c478bd9Sstevel@tonic-gate 				prc_buff('>');
448*7c478bd9Sstevel@tonic-gate 
449*7c478bd9Sstevel@tonic-gate 			prs_buff(ion);
450*7c478bd9Sstevel@tonic-gate 		}
451*7c478bd9Sstevel@tonic-gate 		iop = iop->ionxt;
452*7c478bd9Sstevel@tonic-gate 	}
453*7c478bd9Sstevel@tonic-gate }
454