da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/***********************************************************************
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* This software is part of the ast package *
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner* Copyright (c) 1982-2010 AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* and is licensed under the *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Common Public License, Version 1.0 *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin* by AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* A copy of the License is available at *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Information and Software Systems Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* AT&T Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Florham Park NJ *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* David Korn <dgk@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin***********************************************************************/
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * David Korn
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * AT&T Labs
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * shell deparser
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/* flags that can be specified with p_tree() */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic void p_arg(const struct argnod*, int endchar, int opts);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic void p_keyword(const char*,int);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinvoid sh_deparse(Sfio_t *out, const Shnode_t *t,int tflags)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * print script corresponding to shell tree <t>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic void p_tree(register const Shnode_t *t,register int tflags)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if(tr->tre.tretyp==TWH && tr->wh.whinc && t->lst.lstlef->tre.tretyp==TARITH)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* arithmetic for statement */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin p_tree(t->lst.lstlef,NEED_BRACE|NO_NEWLINE|(tflags&NO_BRACKET));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* new test compound command */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * print a keyword
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * increment indent level for flag==BEGIN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * decrement indent level for flag==END
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic void p_arg(register const struct argnod *arg,register int endchar,int opts)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* case alternation lists in reverse order */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* compound assignment */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin else if((arg->argflag&ARG_RAW) && (cp[1] || (*cp!='[' && *cp!=']')))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic void p_redirect(register const struct ionod *iop)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* here document */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic void p_comlist(const struct dolnod *dol,int endchar)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * output here documents