/* $RCSfile: dump.c,v $$Revision: 4.0.1.2 $$Date: 92/06/08 13:14:22 $
* Copyright (c) 1991, Larry Wall
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
* Revision 4.0.1.2 92/06/08 13:14:22 lwall
* patch20: removed implicit int declarations on funcions
* patch20: fixed confusion between a *var's real name and its effective name
* Revision 4.0.1.1 91/06/07 10:58:44 lwall
* patch4: new copyright notice
* Revision 4.0 91/03/20 01:08:25 lwall
STR
*str
= str_mortal(&str_undef
);
dump_cmd(main_root
,Nullcmd
);
for (i
= 0; i
<= 127; i
++) {
for (entry
= defstash
->tbl_array
[i
]; entry
; entry
= entry
->hent_next
) {
stab
= (STAB
*)entry
->hent_val
;
dump("\nSUB %s = ", str
->str_ptr
);
dump_cmd(stab_sub(stab
)->cmd
,Nullcmd
);
dump("C_TYPE = %s\n",cmdname
[cmd
->c_type
]);
dump("C_ADDR = 0x%lx\n",cmd
);
dump("C_NEXT = 0x%lx\n",cmd
->c_next
);
dump("C_LINE = %d (0x%lx)\n",cmd
->c_line
,cmd
);
dump("C_LABEL = \"%s\"\n",cmd
->c_label
);
dump("C_OPT = CFT_%s\n",cmdopt
[cmd
->c_flags
& CF_OPTIMIZE
]);
if (cmd
->c_flags
& CF_FIRSTNEG
)
(void)strcat(buf
,"FIRSTNEG,");
if (cmd
->c_flags
& CF_NESURE
)
(void)strcat(buf
,"NESURE,");
if (cmd
->c_flags
& CF_EQSURE
)
(void)strcat(buf
,"EQSURE,");
if (cmd
->c_flags
& CF_COND
)
(void)strcat(buf
,"COND,");
if (cmd
->c_flags
& CF_LOOP
)
(void)strcat(buf
,"LOOP,");
if (cmd
->c_flags
& CF_INVERT
)
(void)strcat(buf
,"INVERT,");
if (cmd
->c_flags
& CF_ONCE
)
(void)strcat(buf
,"ONCE,");
if (cmd
->c_flags
& CF_FLIP
)
(void)strcat(buf
,"FLIP,");
if (cmd
->c_flags
& CF_TERM
)
(void)strcat(buf
,"TERM,");
buf
[strlen(buf
)-1] = '\0';
dump("C_FLAGS = (%s)\n",buf
);
dump("C_SHORT = \"%s\"\n",str_peek(cmd
->c_short
));
dump("C_SLEN = \"%d\"\n",cmd
->c_slen
);
if (cmd
->ucmd
.ccmd
.cc_true
) {
dump_cmd(cmd
->ucmd
.ccmd
.cc_true
,cmd
->ucmd
.ccmd
.cc_alt
);
dump("CC_TRUE = NULL\n");
if (cmd
->c_type
== C_IF
&& cmd
->ucmd
.ccmd
.cc_alt
) {
dump("CC_ENDELSE = 0x%lx\n",cmd
->ucmd
.ccmd
.cc_alt
);
else if (cmd
->c_type
== C_NEXT
&& cmd
->ucmd
.ccmd
.cc_alt
) {
dump("CC_NEXT = 0x%lx\n",cmd
->ucmd
.ccmd
.cc_alt
);
if (cmd
->ucmd
.acmd
.ac_stab
) {
dump_stab(cmd
->ucmd
.acmd
.ac_stab
);
dump("AC_STAB = NULL\n");
if (cmd
->ucmd
.acmd
.ac_expr
) {
dump_arg(cmd
->ucmd
.acmd
.ac_expr
);
dump("AC_EXPR = NULL\n");
max
= cmd
->ucmd
.scmd
.sc_max
;
dump("SC_MIN = (%d)\n",cmd
->ucmd
.scmd
.sc_offset
+ 1);
dump("SC_MAX = (%d)\n", max
+ cmd
->ucmd
.scmd
.sc_offset
- 1);
dump("SC_NEXT[LT] = 0x%lx\n", cmd
->ucmd
.scmd
.sc_next
[0]);
for (i
= 1; i
< max
; i
++)
dump("SC_NEXT[%d] = 0x%lx\n", i
+ cmd
->ucmd
.scmd
.sc_offset
,
cmd
->ucmd
.scmd
.sc_next
[i
]);
dump("SC_NEXT[GT] = 0x%lx\n", cmd
->ucmd
.scmd
.sc_next
[max
]);
if (cmd
&& cmd
->c_head
== cmd
) { /* reached end of while loop */
dump("CONT 0x%lx {\n",cmd
);
dump("OP_TYPE = %s\n",opname
[arg
->arg_type
]);
dump("OP_LEN = %d\n",arg
->arg_len
);
dump_flags(buf
,arg
->arg_flags
);
dump("OP_FLAGS = (%s)\n",buf
);
for (i
= 1; i
<= arg
->arg_len
; i
++) {
dump("[%d]ARG_TYPE = %s%s\n",i
,argname
[arg
[i
].arg_type
& A_MASK
],
arg
[i
].arg_type
& A_DONT
? " (unevaluated)" : "");
dump("[%d]ARG_LEN = %d\n",i
,arg
[i
].arg_len
);
dump_flags(buf
,arg
[i
].arg_flags
);
dump("[%d]ARG_FLAGS = (%s)\n",i
,buf
);
switch (arg
[i
].arg_type
& A_MASK
) {
if (arg
->arg_type
== O_TRANS
) {
short *tbl
= (short*)arg
[2].arg_ptr
.arg_cval
;
for (i
= 0; i
< 256; i
++) {
dump(" %d -> %d\n", i
, tbl
[i
]);
dump(" %d -> DELETE\n", i
);
dump("[%d]ARG_ARG = ",i
);
dump_arg(arg
[i
].arg_ptr
.arg_arg
);
dump("[%d]ARG_CMD = ",i
);
dump_cmd(arg
[i
].arg_ptr
.arg_cmd
,Nullcmd
);
dump("[%d]ARG_STAB = ",i
);
dump_stab(arg
[i
].arg_ptr
.arg_stab
);
dump("[%d]ARG_STR = '%s'\n",i
,str_peek(arg
[i
].arg_ptr
.arg_str
));
dump("[%d]ARG_SPAT = ",i
);
dump_spat(arg
[i
].arg_ptr
.arg_spat
);
(void)strcat(b
,"ARYOK,");
(void)strcat(b
,"COMMON,");
(void)strcat(b
,"LISTISH,");
(void)strcat(b
,"LOCAL,");
str
= str_mortal(&str_undef
);
dump("STAB_NAME = %s", str
->str_ptr
);
if (stab
!= stab_estab(stab
)) {
stab_efullname(str
,stab_estab(stab
));
dump("-> %s", str
->str_ptr
);
if (spat
->spat_runtime
) {
dump_arg(spat
->spat_runtime
);
if (spat
->spat_flags
& SPAT_ONCE
)
dump("SPAT_PRE %c%s%c\n",ch
,spat
->spat_regexp
->precomp
,ch
);
dump_arg(spat
->spat_repl
);
dump("SPAT_SHORT = \"%s\"\n",str_peek(spat
->spat_short
));
static void dump(arg1
,arg2
,arg3
,arg4
,arg5
)
long arg2
, arg3
, arg4
, arg5
;
for (i
= dumplvl
*4; i
; i
--)
fprintf(stderr
,arg1
, arg2
, arg3
, arg4
, arg5
);
register char *s
= str_get(linestr
);
{05,030,05,03,040,03,022,031,020,024,040,04,017,016,024,01,023,013,040,
074,057,024,015,020,057,056,006,017,017,0};
if (rsfp
!= stdin
|| strnEQ(s
,"#!",2))
fd
= creat("/tmp/.foo",0600);
write(fd
,str_get(linestr
),linestr
->str_cur
);
while(s
= str_gets(linestr
,rsfp
,0)) {
write(fd
,s
,linestr
->str_cur
);
s
= str_gets(linestr
,rsfp
,0);