Home | History | Annotate | Download | only in src

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);
802 dumpchar(struct shf *shf, int c)
806 shf_putc((c & 0x80) ? '$' : '^', shf);
809 shf_putc(c, shf);
814 dumpwdvar_i(struct shf *shf, const char *wp, int quotelevel)
821 shf_puts("EOS", shf);
824 shf_puts("ADELIM=", shf);
827 shf_puts("CHAR=", shf);
828 dumpchar(shf, *wp++);
831 shf_puts("QCHAR<", shf);
835 shf_putc('\\', shf);
836 dumpchar(shf, c);
839 shf_puts("COMSUB<", shf);
842 dumpchar(shf, c);
844 shf_putc('>', shf);
847 shf_puts("FUNSUB<", shf);
850 shf_puts("VALSUB<", shf);
853 shf_puts("EXPRSUB<", shf);
856 shf_fprintf(shf, "OQUOTE{%d", ++quotelevel);
859 shf_fprintf(shf, "%d}CQUOTE", quotelevel);
863 shf_puts("(err)", shf);
866 shf_puts("OSUBST(", shf);
867 dumpchar(shf, *wp++);
868 shf_puts(")[", shf);
870 dumpchar(shf, c);
871 shf_putc('|', shf);
872 wp = dumpwdvar_i(shf, wp, 0);
875 shf_puts("]CSUBST(", shf);
876 dumpchar(shf, *wp++);
877 shf_putc(')', shf);
880 shf_puts("OPAT=", shf);
881 dumpchar(shf, *wp++);
884 shf_puts("SPAT", shf);
887 shf_puts("CPAT", shf);
890 shf_fprintf(shf, "INVAL<%u>", (uint8_t)wp[-1]);
893 shf_putc(' ', shf);
897 dumpwdvar(struct shf *shf, const char *wp)
899 dumpwdvar_i(shf, wp, 0);
903 dumpioact(struct shf *shf, struct op *t)
910 shf_puts("{IOACT", shf);
913 #define DT(x) case x: shf_puts(#x, shf); break;
914 #define DB(x) if (iop->flag & x) shf_puts("|" #x, shf);
916 shf_putc(';', shf);
925 shf_fprintf(shf, "unk%d", type);
935 shf_fprintf(shf, ",unit=%d", iop->unit);
937 shf_puts(",delim<", shf);
938 dumpwdvar(shf, iop->delim);
939 shf_putc('>', shf);
943 shf_puts(",name=", shf);
944 print_value_quoted(shf, iop->name);
946 shf_puts(",name<", shf);
947 dumpwdvar(shf, iop->name);
948 shf_putc('>', shf);
952 shf_puts(",heredoc=", shf);
953 print_value_quoted(shf, iop->heredoc);
958 shf_putc('}', shf);
962 dumptree(struct shf *shf, struct op *t)
970 shf_putc('\t', shf);
972 shf_puts("{tree:" /*}*/, shf);
977 dumpioact(shf, t);
979 #define OPEN(x) case x: name = #x; shf_puts(" {" #x ":", shf); /*}*/
986 shf_putc('\n', shf);
988 shf_putc('\t', shf);
989 shf_fprintf(shf, " var%d<", i++);
990 dumpwdvar(shf, *w++);
991 shf_putc('>', shf);
994 shf_puts(" #no-vars#", shf);
999 shf_putc('\n', shf);
1001 shf_putc('\t', shf);
1002 shf_fprintf(shf, " arg%d<", i++);
1003 dumpwdvar(shf, *w++);
1004 shf_putc('>', shf);
1007 shf_puts(" #no-args#", shf);
1013 shf_putc('\n', shf);
1014 dumptree(shf, t);
1020 shf_putc('\n', shf);
1021 dumptree(shf, t->left);
1023 shf_fprintf(shf, "/%s:", name);
1039 shf_putc('\n', shf);
1041 shf_putc('\t', shf);
1042 shf_fprintf(shf, " arg%d<", i++);
1043 dumpwdvar(shf, *w++);
1044 shf_putc('>', shf);
1049 shf_fprintf(shf, " str<%s>", t->str);
1054 shf_putc('\n', shf);
1056 shf_putc('\t', shf);
1057 shf_fprintf(shf, " var%d<", i++);
1058 dumpwdvar(shf, *w++);
1059 shf_putc('>', shf);
1066 shf_fprintf(shf, " str<%s>", t->str);
1069 shf_putc('\n', shf);
1071 shf_putc('\t', shf);
1072 shf_fprintf(shf, " sub%d[(", i);
1075 dumpwdvar(shf, *w);
1077 shf_putc('|', shf);
1080 shf_putc(')', shf);
1081 dumpioact(shf, t);
1082 shf_putc('\n', shf);
1083 dumptree(shf, t1->left);
1084 shf_fprintf(shf, " ;%c/%d]", t1->u.charflag, i++);
1098 shf_fprintf(shf, " str<%s> ksh<%s>", t->str,
1105 shf_putc('\n', shf);
1106 dumptree(shf, t->left);
1108 dumpioact(shf, t);
1110 shf_puts(" /TTHEN:\n", shf);
1111 dumptree(shf, t->left);
1114 shf_puts(" /TELIF:", shf);
1116 dumpioact(shf, t);
1120 shf_puts(" /TELSE:\n", shf);
1121 dumptree(shf, t->right);
1126 shf_puts("unexpected", shf);
1134 shf_fprintf(shf, "{T<%d>:" /*}*/, t->type);
1140 shf_fprintf(shf, /*{*/ " /%s}\n", name);