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);
46 ptree(struct op *t, int indent, struct shf *shf)
73 fptreef(shf, indent, "%S", t->vars[0]);
80 fptreef(shf, indent, "%S ", *w++);
82 shf_puts("#no-vars# ", shf);
86 fptreef(shf, indent, "%S ", *w++);
88 shf_puts("#no-args# ", shf);
94 fptreef(shf, indent + 2, "( %T) ", t->left);
97 fptreef(shf, indent, "%T| ", t->left);
101 fptreef(shf, indent, "%T%;", t->left);
106 fptreef(shf, indent, "%T%s %T",
110 shf_puts("! ", shf);
116 shf_puts("[[", shf);
118 fptreef(shf, indent, " %S", *w++);
119 shf_puts(" ]] ", shf);
123 fptreef(shf, indent, "%s %s ",
126 shf_puts("in ", shf);
129 fptreef(shf, indent, "%S ", *w++);
130 fptreef(shf, indent, "%;");
132 fptreef(shf, indent + INDENT, "do%N%T", t->left);
133 fptreef(shf, indent, "%;done ");
136 fptreef(shf, indent, "case %S in", t->str);
138 fptreef(shf, indent, "%N(");
141 fptreef(shf, indent, "%S%c", *w,
145 fptreef(shf, indent + INDENT, "%N%T%N;%c", t1->left,
148 fptreef(shf, indent, "%Nesac ");
162 fptreef(shf, indent, "%;");
165 fptreef(shf, indent + 5 - i, Telif_pT + i, t1->left);
168 fptreef(shf, indent, "%;");
169 fptreef(shf, indent + INDENT, "%s%N%T",
174 fptreef(shf, indent, "%;");
175 fptreef(shf, indent + INDENT, "%s%N%T",
178 fptreef(shf, indent, "%;fi ");
183 fptreef(shf, indent + 6, "%s %T",
186 fptreef(shf, indent, "%;");
187 fptreef(shf, indent + INDENT, "do%N%T", t->right);
188 fptreef(shf, indent, "%;done ");
191 fptreef(shf, indent + INDENT, "{%N%T", t->left);
192 fptreef(shf, indent, "%;} ");
195 fptreef(shf, indent, "%T|& ", t->left);
199 fptreef(shf, indent, "%T& ", t->left);
203 fpFUNCTf(shf, indent, tobool(t->u.ksh_func), t->str, t->left);
206 fptreef(shf, indent, "%s %T", "time", t->left);
209 shf_puts("<botch>", shf);
217 pioact(shf, *ioact++);
226 shf_putc('\n', shf);
227 shf_puts(iop->heredoc, shf);
228 fptreef(shf, indent, "%s",
240 shf_putc('\n', shf);
247 pioact(struct shf *shf, struct ioword *iop)
258 shf_fprintf(shf, "%d", iop->unit);
262 shf_putc('<', shf);
265 shf_puts("<<", shf);
267 shf_putc('-', shf);
270 shf_puts(">>", shf);
273 shf_putc('>', shf);
275 shf_putc('|', shf);
278 shf_puts("<>", shf);
281 shf_puts(flag & IORDUP ? "<&" : ">&", shf);
287 wdvarput(shf, iop->delim, 0, WDS_TPUTS);
289 shf_putc(' ', shf);
292 print_value_quoted(shf, iop->name);
294 wdvarput(shf, iop->name, 0, WDS_TPUTS);
295 shf_putc(' ', shf);
302 wdvarput(struct shf *shf, const char *wp, int quotelevel, int opmode)
327 shf_putc(MAGIC, shf);
328 shf_putc(c, shf);
343 shf_putc('\\', shf);
344 shf_putc(c, shf);
348 shf_puts("$(", shf);
352 shf_putc(c, shf);
353 shf_puts(cs, shf);
361 shf_putc('$', shf);
362 shf_putc('{', shf);
363 shf_putc(c, shf);
367 shf_puts("$((", shf);
373 shf_putc('"', shf);
380 shf_putc('"', shf);
384 shf_putc('$', shf);
386 shf_putc('{', shf);
388 shf_putc(c, shf);
389 wp = wdvarput(shf, wp, 0, opmode);
393 shf_putc('}', shf);
397 shf_putc(MAGIC, shf);
398 shf_putchar(*wp++ | 0x80, shf);
400 shf_putchar(*wp++, shf);
401 shf_putc('(', shf);
410 shf_putc(MAGIC, shf);
411 shf_putc(c, shf);
422 fptreef(struct shf *shf, int indent, const char *fmt, ...)
427 vfptreef(shf, indent, fmt, va);
436 struct shf shf;
438 shf_sopen(s, n, SHF_WR | (s ? 0 : SHF_DYNAMIC), &shf);
441 vfptreef(&shf, 0, fmt, va);
445 return (shf_sclose(&shf));
449 vfptreef(struct shf *shf, int indent, const char *fmt, va_list va)
458 shf_putchar(va_arg(va, int), shf);
462 shf_puts(va_arg(va, char *), shf);
466 wdvarput(shf, va_arg(va, char *), 0, WDS_TPUTS);
470 shf_fprintf(shf, "%d", va_arg(va, int));
474 shf_fprintf(shf, "%u", va_arg(va, unsigned int));
478 ptree(va_arg(va, struct op *), indent, shf);
484 if (shf->flags & SHF_STRING) {
486 shf_putc(';', shf);
487 shf_putc(' ', shf);
491 shf_putc('\n', shf);
494 shf_putc('\t', shf);
498 shf_putc(' ', shf);
503 pioact(shf, va_arg(va, struct ioword *));
506 shf_putc(c, shf);
510 shf_putc(c, shf);
650 struct shf shf;
652 shf_sopen(NULL, 32, SHF_WR | SHF_DYNAMIC, &shf);
653 wdvarput(&shf, wp, 0, opmode);
655 return (shf_sclose(&shf));
747 fpFUNCTf(struct shf *shf, int i, bool isksh, const char *k, struct op *v)
750 fptreef(shf, i, "%s %s %T", Tfunction, k, v);
752 fptreef(shf, i, "%s() %T", k, v);
803 dumpchar(struct shf *shf, int c)
807 shf_putc((c & 0x80) ? '$' : '^', shf);
810 shf_putc(c, shf);
815 dumpwdvar_i(struct shf *shf, const char *wp, int quotelevel)
822 shf_puts("EOS", shf);
825 shf_puts("ADELIM=", shf);
828 shf_puts("CHAR=", shf);
829 dumpchar(shf, *wp++);
832 shf_puts("QCHAR<", shf);
836 shf_putc('\\', shf);
837 dumpchar(shf, c);
840 shf_puts("COMSUB<", shf);
843 dumpchar(shf, c);
845 shf_putc('>', shf);
848 shf_puts("FUNSUB<", shf);
851 shf_puts("VALSUB<", shf);
854 shf_puts("EXPRSUB<", shf);
857 shf_fprintf(shf, "OQUOTE{%d", ++quotelevel);
860 shf_fprintf(shf, "%d}CQUOTE", quotelevel);
864 shf_puts("(err)", shf);
867 shf_puts("OSUBST(", shf);
868 dumpchar(shf, *wp++);
869 shf_puts(")[", shf);
871 dumpchar(shf, c);
872 shf_putc('|', shf);
873 wp = dumpwdvar_i(shf, wp, 0);
876 shf_puts("]CSUBST(", shf);
877 dumpchar(shf, *wp++);
878 shf_putc(')', shf);
881 shf_puts("OPAT=", shf);
882 dumpchar(shf, *wp++);
885 shf_puts("SPAT", shf);
888 shf_puts("CPAT", shf);
891 shf_fprintf(shf, "INVAL<%u>", (uint8_t)wp[-1]);
894 shf_putc(' ', shf);
898 dumpwdvar(struct shf *shf, const char *wp)
900 dumpwdvar_i(shf, wp, 0);
904 dumpioact(struct shf *shf, struct op *t)
911 shf_puts("{IOACT", shf);
914 #define DT(x) case x: shf_puts(#x, shf); break;
915 #define DB(x) if (iop->flag & x) shf_puts("|" #x, shf);
917 shf_putc(';', shf);
926 shf_fprintf(shf, "unk%d", type);
936 shf_fprintf(shf, ",unit=%d", iop->unit);
938 shf_puts(",delim<", shf);
939 dumpwdvar(shf, iop->delim);
940 shf_putc('>', shf);
944 shf_puts(",name=", shf);
945 print_value_quoted(shf, iop->name);
947 shf_puts(",name<", shf);
948 dumpwdvar(shf, iop->name);
949 shf_putc('>', shf);
953 shf_puts(",heredoc=", shf);
954 print_value_quoted(shf, iop->heredoc);
959 shf_putc('}', shf);
963 dumptree(struct shf *shf, struct op *t)
971 shf_putc('\t', shf);
973 shf_puts("{tree:" /*}*/, shf);
978 dumpioact(shf, t);
980 #define OPEN(x) case x: name = #x; shf_puts(" {" #x ":", shf); /*}*/
987 shf_putc('\n', shf);
989 shf_putc('\t', shf);
990 shf_fprintf(shf, " var%d<", i++);
991 dumpwdvar(shf, *w++);
992 shf_putc('>', shf);
995 shf_puts(" #no-vars#", shf);
1000 shf_putc('\n', shf);
1002 shf_putc('\t', shf);
1003 shf_fprintf(shf, " arg%d<", i++);
1004 dumpwdvar(shf, *w++);
1005 shf_putc('>', shf);
1008 shf_puts(" #no-args#", shf);
1014 shf_putc('\n', shf);
1015 dumptree(shf, t);
1021 shf_putc('\n', shf);
1022 dumptree(shf, t->left);
1024 shf_fprintf(shf, "/%s:", name);
1040 shf_putc('\n', shf);
1042 shf_putc('\t', shf);
1043 shf_fprintf(shf, " arg%d<", i++);
1044 dumpwdvar(shf, *w++);
1045 shf_putc('>', shf);
1050 shf_fprintf(shf, " str<%s>", t->str);
1055 shf_putc('\n', shf);
1057 shf_putc('\t', shf);
1058 shf_fprintf(shf, " var%d<", i++);
1059 dumpwdvar(shf, *w++);
1060 shf_putc('>', shf);
1067 shf_fprintf(shf, " str<%s>", t->str);
1070 shf_putc('\n', shf);
1072 shf_putc('\t', shf);
1073 shf_fprintf(shf, " sub%d[(", i);
1076 dumpwdvar(shf, *w);
1078 shf_putc('|', shf);
1081 shf_putc(')', shf);
1082 dumpioact(shf, t);
1083 shf_putc('\n', shf);
1084 dumptree(shf, t1->left);
1085 shf_fprintf(shf, " ;%c/%d]", t1->u.charflag, i++);
1099 shf_fprintf(shf, " str<%s> ksh<%s>", t->str,
1106 shf_putc('\n', shf);
1107 dumptree(shf, t->left);
1109 dumpioact(shf, t);
1111 shf_puts(" /TTHEN:\n", shf);
1112 dumptree(shf, t->left);
1115 shf_puts(" /TELIF:", shf);
1117 dumpioact(shf, t);
1121 shf_puts(" /TELSE:\n", shf);
1122 dumptree(shf, t->right);
1127 shf_puts("unexpected", shf);
1135 shf_fprintf(shf, "{T<%d>:" /*}*/, t->type);
1141 shf_fprintf(shf, /*{*/ " /%s}\n", name);