Skip to content

Commit

Permalink
Merge pull request #142 from jrincayc/fix_debug_statements
Browse files Browse the repository at this point in the history
Fix debug statements
  • Loading branch information
dmalec committed Jan 7, 2023
2 parents 64fc46e + a82dba4 commit f6be508
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
23 changes: 14 additions & 9 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ NODE
#define USE_GCC_DISPATCH 1
#endif

/* Hint:
make "redefp "true
to get lots of output after defining DEBUGGING 1
*/
#define DEBUGGING 0

#if DEBUGGING
Expand All @@ -75,27 +79,28 @@ void vs_print() {
"MACRO_RETURN"};

if (!varTrue(Redefp)) return;
printf("Val_status = ");
ndprintf(stdout, "Val_status = ");
for (i=0; i<6; i++) {
if (vs&1) {
printf(vnames[i]);
ndprintf(stdout, vnames[i]);
vs >>= 1;
if (vs != 0) printf("|");
if (vs != 0) ndprintf(stdout, "|");
} else vs >>= 1;
if (vs == 0) break;
if (vs == 0) break;
}
if (vs != 0) printf("0%o", vs<<6);
printf(", stopping_flag = %s\n", names[stopping_flag]);
if (vs != 0) ndprintf(stdout, "0%o", vs<<6);
ndprintf(stdout, ", stopping_flag = %t\n", names[stopping_flag]);
}

void debprint(char *name) {
void debprintline(int line, char *name) {
if (!varTrue(Redefp)) return;
printf("%s: ", name);
ndprintf(stdout, "%d %t:\n", line, name);
do_debug(deb_enum)
vs_print();
printf("current_unode=0x%x, output_unode=0x%x\n",current_unode,
ndprintf(stdout, "current_unode=0x%x, output_unode=0x%x\n\n",current_unode,
output_unode);
}
#define debprint(name) debprintline(__LINE__, name)
#define debprint2(a,b) if (varTrue(Redefp)) ndprintf(stdout,a,b)
#else
#define debprint(name)
Expand Down
5 changes: 5 additions & 0 deletions print.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ void ndprintf(FILE *strm, char *fmt, ...) {
sprintf(buf,"%ld",i);
cp = buf;
while ((ch = *cp++) != '\0') print_char(strm,ch);
} else if (ch == 'x') { /* hexadecimal */
i = va_arg(ap, int);
sprintf(buf,"%lx",i);
cp = buf;
while ((ch = *cp++) != '\0') print_char(strm,ch);
} else {
print_char(strm,'%');
print_char(strm,ch);
Expand Down

0 comments on commit f6be508

Please sign in to comment.