From 392e05d19e5013415ad48fcea197eec4d5cc45a4 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 27 Apr 2024 09:02:56 -0700 Subject: [PATCH] Send everything to stdout --- src/modal.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/modal.c b/src/modal.c index fdc68e8..8a594e1 100644 --- a/src/modal.c +++ b/src/modal.c @@ -139,7 +139,7 @@ apply_rule(Rule *r, char *s) while(*s == ' ') s++; if(*s == ')' && *(dst_ - 1) == ' ') dst_--; } - if(!quiet && r) fprintf(stderr, "%02d %s\n", r->id, src_), ++r->refs; + if(!quiet && r) printf("%02d %s\n", r->id, src_), ++r->refs; return write_tail(s); } @@ -216,7 +216,7 @@ rewrite(void) if(c == '<' && s[1] == '>') { r = rules_++; s = compile_rule(r, rules_ - rules - 1, s + 2); - if(!quiet && r->a) fprintf(stderr, "<> (%s) (%s)\n", r->a, r->b); + if(!quiet && r->a) printf("<> (%s) (%s)\n", r->a, r->b); while(*s == ' ') s++; return write_tail(s); } @@ -225,7 +225,7 @@ rewrite(void) s += 2; while(*s == ' ') s++; cap = walk(s), r = find_rule(s, cap), r->a = 0; - if(!quiet && r->a) fprintf(stderr, ">< (%s)\n", r->a); + if(!quiet && r->a) printf(">< (%s)\n", r->a); while(*cap == ' ') cap++; return write_tail(cap); } @@ -263,7 +263,7 @@ main(int argc, char **argv) } } if(!(f = fopen(argv[i], "r"))) - return !fprintf(stdout, "Modal file invalid: %s.\n", argv[i]); + return !printf("Modal file invalid: %s.\n", argv[i]); while(fread(&c, 1, 1, f)) { c = c <= 0x20 ? 0x20 : c; if(c == ' ' && last == '(') continue; @@ -278,11 +278,14 @@ main(int argc, char **argv) while(*(--w) <= ' ') *w = 0; fclose(f); if(pr != pl) - return !fprintf(stdout, "Modal program imbalanced.\n"); + return !printf("Modal program imbalanced.\n"); while(rewrite() && ++rw) - if(!cycles--) return !fprintf(stdout, "Modal rewrites exceeded.\n"); - while(rules_-- > rules && !quiet) - if(!rules_->refs && rules_->a) printf("-- Unused rule: %d <> (%s) (%s)\n", rules_->refs, rules_->a, rules_->b); - if(!quiet) printf(".. %s\nCompleted in %d rewrites.\n", src_, rw); + if(!cycles--) return !printf("Modal rewrites exceeded.\n"); + if(!quiet) { + while(rules_-- > rules) + if(!rules_->refs && rules_->a) + printf("-- Unused rule: %d <> (%s) (%s)\n", rules_->refs, rules_->a, rules_->b); + printf(".. %s\nCompleted in %d rewrites.\n", src_, rw); + } return 0; } \ No newline at end of file