Lines Matching refs:shf
30 static void ptree(struct op *, int, struct shf *);
31 static void pioact(struct shf *, struct ioword *);
32 static const char *wdvarput(struct shf *, const char *, int, int);
33 static void vfptreef(struct shf *, int, const char *, va_list);
43 static struct shf ptree_heredoc;
44 #define ptree_outhere(shf) do { \
46 shf_puts(shf_sclose(&ptree_heredoc), (shf)); \
47 shf_putc('\n', (shf)); \
59 ptree(struct op *t, int indent, struct shf *shf)
90 fptreef(shf, indent, Tf_S, t->vars[0]);
97 fptreef(shf, indent, Tf_S_, *w++);
101 shf_puts("#no-vars# ", shf);
109 shf_putc('\\', shf);
110 shf_puts(cp, shf);
111 shf_putc(' ', shf);
115 fptreef(shf, indent, Tf_S_, *w++);
119 shf_puts("#no-args# ", shf);
126 fptreef(shf, indent + 2, "( %T) ", t->left);
129 fptreef(shf, indent, "%T| ", t->left);
133 fptreef(shf, indent, "%T%;", t->left);
138 fptreef(shf, indent, "%T%s %T",
142 shf_puts("! ", shf);
148 shf_puts("[[", shf);
150 fptreef(shf, indent, Tf__S, *w++);
151 shf_puts(" ]] ", shf);
155 fptreef(shf, indent, "%s %s ",
158 shf_puts("in ", shf);
161 fptreef(shf, indent, Tf_S_, *w++);
162 fptreef(shf, indent, Tft_end);
164 fptreef(shf, indent + INDENT, "do%N%T", t->left);
165 fptreef(shf, indent, "%;done ");
168 fptreef(shf, indent, "case %S in", t->str);
170 fptreef(shf, indent, "%N(");
173 fptreef(shf, indent, "%S%c", *w,
177 fptreef(shf, indent + INDENT, "%N%T%N;%c", t1->left,
180 fptreef(shf, indent, "%Nesac ");
192 fptreef(shf, indent, Tft_end);
195 fptreef(shf, indent + 5 - i, Telif_pT + i, t1->left);
198 fptreef(shf, indent, Tft_end);
199 fptreef(shf, indent + INDENT, "%s%N%T",
204 fptreef(shf, indent, Tft_end);
205 fptreef(shf, indent + INDENT, "%s%N%T",
208 fptreef(shf, indent, "%;fi ");
213 fptreef(shf, indent + 6, Tf_s_T,
216 fptreef(shf, indent, Tft_end);
217 fptreef(shf, indent + INDENT, "do%N%T", t->right);
218 fptreef(shf, indent, "%;done ");
221 fptreef(shf, indent + INDENT, "{%N%T", t->left);
222 fptreef(shf, indent, "%;} ");
225 fptreef(shf, indent, "%T|& ", t->left);
229 fptreef(shf, indent, "%T& ", t->left);
233 fpFUNCTf(shf, indent, tobool(t->u.ksh_func), t->str, t->left);
236 fptreef(shf, indent, Tf_s_T, Ttime, t->left);
239 shf_puts("<botch>", shf);
245 pioact(shf, *ioact++);
249 pioact(struct shf *shf, struct ioword *iop)
260 shf_fprintf(shf, Tf_d, (int)iop->unit);
264 shf_putc('<', shf);
268 shf_puts("<<<", shf);
271 shf_puts("<<", shf);
273 shf_putc('-', shf);
289 wdvarput(shf, iop->delim, 0, WDS_TPUTS);
292 shf_puts(">>", shf);
295 shf_putc('>', shf);
297 shf_putc('|', shf);
300 shf_puts("<>", shf);
303 shf_puts(flag & IORDUP ? "<&" : ">&", shf);
309 print_value_quoted(shf, iop->ioname);
311 wdvarput(shf, iop->ioname, 0, WDS_TPUTS);
313 shf_putc(' ', shf);
319 wdvarput(struct shf *shf, const char *wp, int quotelevel, int opmode)
346 shf_putc(c, shf);
359 shf_putc(ORD('\\'), shf);
362 shf_putc(c, shf);
366 shf_puts("$(", shf);
369 shf_putc(' ', shf);
372 shf_putc(c, shf);
373 shf_puts(cs, shf);
382 shf_putc('$', shf);
383 shf_putc('{', shf);
384 shf_putc(c, shf);
388 shf_puts("$((", shf);
394 shf_putc('"', shf);
401 shf_putc('"', shf);
405 shf_putc('$', shf);
407 shf_putc('{', shf);
409 shf_putc(c, shf);
410 wp = wdvarput(shf, wp, 0, opmode);
415 shf_putc('}', shf);
419 shf_putchar(*wp++, shf);
420 shf_putc('(', shf);
428 shf_putc(c, shf);
439 fptreef(struct shf *shf, int indent, const char *fmt, ...)
444 vfptreef(shf, indent, fmt, va);
453 struct shf shf;
455 shf_sopen(s, n, SHF_WR | (s ? 0 : SHF_DYNAMIC), &shf);
458 vfptreef(&shf, 0, fmt, va);
462 return (shf_sclose(&shf));
466 vfptreef(struct shf *shf, int indent, const char *fmt, va_list va)
478 shf_putchar(va_arg(va, int), shf);
482 shf_puts(va_arg(va, char *), shf);
486 wdvarput(shf, va_arg(va, char *), 0, WDS_TPUTS);
490 shf_fprintf(shf, Tf_d, va_arg(va, int));
494 shf_fprintf(shf, "%u", va_arg(va, unsigned int));
498 ptree(va_arg(va, struct op *), indent, shf);
504 if (shf->flags & SHF_STRING) {
507 shf_putc(';', shf);
508 shf_putc(' ', shf);
512 ptree_outhere(shf);
513 shf_putc('\n', shf);
515 shf_putc('\t', shf);
519 shf_putc(' ', shf);
524 pioact(shf, va_arg(va, struct ioword *));
527 shf_putc(c, shf);
531 shf_putc(c, shf);
538 ptree_outhere(shf);
679 struct shf shf;
681 shf_sopen(NULL, 32, SHF_WR | SHF_DYNAMIC, &shf);
682 wdvarput(&shf, wp, 0, opmode);
684 return (shf_sclose(&shf));
772 fpFUNCTf(struct shf *shf, int i, bool isksh, const char *k, struct op *v)
775 fptreef(shf, i, "%s %s %T", Tfunction, k, v);
777 fptreef(shf, i, "%s %s() %T", Tfunction, k, v);
779 fptreef(shf, i, "%s() %T", k, v);
830 dumpchar(struct shf *shf, unsigned char c)
834 shf_putc('^', shf);
837 shf_putc(c, shf);
842 dumpwdvar_i(struct shf *shf, const char *wp, int quotelevel)
849 shf_puts("EOS", shf);
853 shf_puts(/*{*/ "]ADELIM(})", shf);
856 shf_puts("ADELIM=", shf);
860 shf_puts("CHAR=", shf);
861 dumpchar(shf, *wp++);
864 shf_puts("QCHAR<", shf);
868 shf_putc('\\', shf);
869 dumpchar(shf, c);
872 shf_puts("COMASUB<", shf);
875 shf_puts("COMSUB<", shf);
878 dumpchar(shf, c);
880 shf_putc('>', shf);
883 shf_puts("FUNASUB<", shf);
886 shf_puts("FUNSUB<", shf);
889 shf_puts("VALSUB<", shf);
892 shf_puts("EXPRSUB<", shf);
895 shf_fprintf(shf, "OQUOTE{%d" /*}*/, ++quotelevel);
898 shf_fprintf(shf, /*{*/ "%d}CQUOTE", quotelevel);
902 shf_puts("(err)", shf);
905 shf_puts("OSUBST(", shf);
906 dumpchar(shf, *wp++);
907 shf_puts(")[", shf);
909 dumpchar(shf, c);
910 shf_putc('|', shf);
911 wp = dumpwdvar_i(shf, wp, 0);
914 shf_puts("]CSUBST(", shf);
915 dumpchar(shf, *wp++);
916 shf_putc(')', shf);
919 shf_puts("OPAT=", shf);
920 dumpchar(shf, *wp++);
923 shf_puts("SPAT", shf);
926 shf_puts("CPAT", shf);
929 shf_fprintf(shf, "INVAL<%u>", (uint8_t)wp[-1]);
932 shf_putc(' ', shf);
936 dumpwdvar(struct shf *shf, const char *wp)
938 dumpwdvar_i(shf, wp, 0);
942 dumpioact(struct shf *shf, struct op *t)
949 shf_puts("{IOACT", shf);
952 #define DT(x) case x: shf_puts(#x, shf); break;
953 #define DB(x) if (iop->ioflag & x) shf_puts("|" #x, shf);
955 shf_putc(';', shf);
964 shf_fprintf(shf, "unk%d", type);
974 shf_fprintf(shf, ",unit=%d", (int)iop->unit);
976 shf_puts(",delim<", shf);
977 dumpwdvar(shf, iop->delim);
978 shf_putc('>', shf);
982 shf_puts(",name=", shf);
983 print_value_quoted(shf, iop->ioname);
985 shf_puts(",name<", shf);
986 dumpwdvar(shf, iop->ioname);
987 shf_putc('>', shf);
991 shf_puts(",heredoc=", shf);
992 print_value_quoted(shf, iop->heredoc);
997 shf_putc('}', shf);
1001 dumptree(struct shf *shf, struct op *t)
1009 shf_putc('\t', shf);
1011 shf_puts("{tree:" /*}*/, shf);
1016 dumpioact(shf, t);
1018 #define OPEN(x) case x: name = #x; shf_puts(" {" #x ":", shf); /*}*/
1025 shf_putc('\n', shf);
1027 shf_putc('\t', shf);
1028 shf_fprintf(shf, " var%d<", i++);
1029 dumpwdvar(shf, *w++);
1030 shf_putc('>', shf);
1033 shf_puts(" #no-vars#", shf);
1038 shf_putc('\n', shf);
1040 shf_putc('\t', shf);
1041 shf_fprintf(shf, " arg%d<", i++);
1042 dumpwdvar(shf, *w++);
1043 shf_putc('>', shf);
1046 shf_puts(" #no-args#", shf);
1052 shf_putc('\n', shf);
1053 dumptree(shf, t);
1059 shf_putc('\n', shf);
1060 dumptree(shf, t->left);
1062 shf_fprintf(shf, "/%s:", name);
1078 shf_putc('\n', shf);
1080 shf_putc('\t', shf);
1081 shf_fprintf(shf, " arg%d<", i++);
1082 dumpwdvar(shf, *w++);
1083 shf_putc('>', shf);
1088 shf_fprintf(shf, " str<%s>", t->str);
1093 shf_putc('\n', shf);
1095 shf_putc('\t', shf);
1096 shf_fprintf(shf, " var%d<", i++);
1097 dumpwdvar(shf, *w++);
1098 shf_putc('>', shf);
1105 shf_fprintf(shf, " str<%s>", t->str);
1108 shf_putc('\n', shf);
1110 shf_putc('\t', shf);
1111 shf_fprintf(shf, " sub%d[(", i);
1114 dumpwdvar(shf, *w);
1116 shf_putc('|', shf);
1119 shf_putc(')', shf);
1120 dumpioact(shf, t);
1121 shf_putc('\n', shf);
1122 dumptree(shf, t1->left);
1123 shf_fprintf(shf, " ;%c/%d]", t1->u.charflag, i++);
1137 shf_fprintf(shf, " str<%s> ksh<%s>", t->str,
1144 shf_putc('\n', shf);
1145 dumptree(shf, t->left);
1147 dumpioact(shf, t);
1149 shf_puts(" /TTHEN:\n", shf);
1150 dumptree(shf, t->left);
1153 shf_puts(" /TELIF:", shf);
1155 dumpioact(shf, t);
1159 shf_puts(" /TELSE:\n", shf);
1160 dumptree(shf, t->right);
1165 shf_puts(Tunexpected, shf);
1173 shf_fprintf(shf, "{T<%d>:" /*}*/, t->type);
1179 shf_fprintf(shf, /*{*/ " /%s}\n", name);