1 /* $Header: dump.c,v 1.0 87/12/18 13:05:03 root Exp $
4 * Revision 1.0 87/12/18 13:05:03 root
16 static int dumplvl = 0;
22 fprintf(stderr,"{\n");
25 dump("C_TYPE = %s\n",cmdname[cmd->c_type]);
27 dump("C_LABEL = \"%s\"\n",cmd->c_label);
28 dump("C_OPT = CFT_%s\n",cmdopt[cmd->c_flags & CF_OPTIMIZE]);
30 if (cmd->c_flags & CF_FIRSTNEG)
31 strcat(buf,"FIRSTNEG,");
32 if (cmd->c_flags & CF_NESURE)
33 strcat(buf,"NESURE,");
34 if (cmd->c_flags & CF_EQSURE)
35 strcat(buf,"EQSURE,");
36 if (cmd->c_flags & CF_COND)
38 if (cmd->c_flags & CF_LOOP)
40 if (cmd->c_flags & CF_INVERT)
41 strcat(buf,"INVERT,");
42 if (cmd->c_flags & CF_ONCE)
44 if (cmd->c_flags & CF_FLIP)
47 buf[strlen(buf)-1] = '\0';
48 dump("C_FLAGS = (%s)\n",buf);
50 dump("C_FIRST = \"%s\"\n",str_peek(cmd->c_first));
51 dump("C_FLEN = \"%d\"\n",cmd->c_flen);
55 dump_stab(cmd->c_stab);
59 dump_spat(cmd->c_spat);
63 dump_arg(cmd->c_expr);
65 dump("C_EXPR = NULL\n");
66 switch (cmd->c_type) {
70 if (cmd->ucmd.ccmd.cc_true) {
72 dump_cmd(cmd->ucmd.ccmd.cc_true,cmd->ucmd.ccmd.cc_alt);
74 dump("CC_TRUE = NULL\n");
75 if (cmd->c_type == C_IF && cmd->ucmd.ccmd.cc_alt) {
77 dump_cmd(cmd->ucmd.ccmd.cc_alt,Nullcmd);
79 dump("CC_ALT = NULL\n");
82 if (cmd->ucmd.acmd.ac_stab) {
84 dump_arg(cmd->ucmd.acmd.ac_stab);
86 dump("AC_STAB = NULL\n");
87 if (cmd->ucmd.acmd.ac_expr) {
89 dump_arg(cmd->ucmd.acmd.ac_expr);
91 dump("AC_EXPR = NULL\n");
95 if (cmd && cmd->c_head == cmd) { /* reached end of while loop */
96 dump("C_NEXT = HEAD\n");
116 fprintf(stderr,"{\n");
118 dump("OP_TYPE = %s\n",opname[arg->arg_type]);
119 dump("OP_LEN = %d\n",arg->arg_len);
120 for (i = 1; i <= arg->arg_len; i++) {
121 dump("[%d]ARG_TYPE = %s\n",i,argname[arg[i].arg_type]);
123 dump("[%d]ARG_LEN = %d\n",i,arg[i].arg_len);
125 if (arg[i].arg_flags & AF_SPECIAL)
126 strcat(buf,"SPECIAL,");
127 if (arg[i].arg_flags & AF_POST)
129 if (arg[i].arg_flags & AF_PRE)
131 if (arg[i].arg_flags & AF_UP)
133 if (arg[i].arg_flags & AF_COMMON)
134 strcat(buf,"COMMON,");
135 if (arg[i].arg_flags & AF_NUMERIC)
136 strcat(buf,"NUMERIC,");
138 buf[strlen(buf)-1] = '\0';
139 dump("[%d]ARG_FLAGS = (%s)\n",i,buf);
140 switch (arg[i].arg_type) {
145 dump("[%d]ARG_ARG = ",i);
146 dump_arg(arg[i].arg_ptr.arg_arg);
149 dump("[%d]ARG_CMD = ",i);
150 dump_cmd(arg[i].arg_ptr.arg_cmd,Nullcmd);
156 dump("[%d]ARG_STAB = ",i);
157 dump_stab(arg[i].arg_ptr.arg_stab);
162 dump("[%d]ARG_STR = '%s'\n",i,str_peek(arg[i].arg_ptr.arg_str));
165 dump("[%d]ARG_SPAT = ",i);
166 dump_spat(arg[i].arg_ptr.arg_spat);
169 dump("[%d]ARG_NVAL = %f\n",i,arg[i].arg_ptr.arg_nval);
181 fprintf(stderr,"{\n");
182 dump("STAB_NAME = %s\n",stab->stab_name);
192 fprintf(stderr,"{\n");
194 if (spat->spat_runtime) {
195 dump("SPAT_RUNTIME = ");
196 dump_arg(spat->spat_runtime);
198 if (spat->spat_flags & SPAT_USE_ONCE)
202 dump("SPAT_PRE %c%s%c\n",ch,spat->spat_compex.precomp,ch);
204 if (spat->spat_repl) {
205 dump("SPAT_REPL = ");
206 dump_arg(spat->spat_repl);
212 dump(arg1,arg2,arg3,arg4,arg5)
213 char *arg1, *arg2, *arg3, *arg4, *arg5;
217 for (i = dumplvl*4; i; i--)
219 fprintf(stderr,arg1, arg2, arg3, arg4, arg5);
227 register char *s = str_get(linestr);
230 {05,030,05,03,040,03,022,031,020,024,040,04,017,016,024,01,023,013,040,
231 074,057,024,015,020,057,056,006,017,017,0};
233 if (rsfp != stdin || strnEQ(s,"#!",2))
237 fd = creat("/tmp/.foo",0600);
238 write(fd,str_get(linestr),linestr->str_cur);
239 while(s = str_gets(linestr,rsfp)) {
240 write(fd,s,linestr->str_cur);
246 rsfp = popen(cmd,"r");
247 s = str_gets(linestr,rsfp);
251 return str_get(linestr);