diff --git a/src/modal.c b/src/modal.c index 9cd090f..ff74cc4 100644 --- a/src/modal.c +++ b/src/modal.c @@ -7,8 +7,8 @@ typedef struct { static int rules_len; static Rule rules[0x100]; static char dict[0x8000], *dict_ = dict; -static char prog[0x1000], *prog_ = prog; -static char outp[0x1000], *outp_ = outp; +static char bank_a[0x1000], *prog_ = bank_a; +static char bank_b[0x1000], *outp_ = bank_b; static char *regs[0x100]; #define spacer(c) (c == ' ' || c == '(' || c == ')') @@ -78,7 +78,7 @@ bind(char r) if(c == '(') depth++; *outp_++ = c; if(c == ')') --depth; - if(!depth) return; + if(!depth) return 1; } } while(!spacer(s[0]) && (*outp_++ = *s++)) @@ -89,11 +89,11 @@ bind(char r) static void save(int rule) { - int i, end = outp_ - outp; + int i, end = outp_ - bank_b; /* todo: change pointer instead of copying memory */ - for(i = 0; i <= end; i++) prog[i] = outp[i]; - prog_ = prog, outp_ = outp; - printf("%02d %s\n", rule, prog); + for(i = 0; i <= end; i++) bank_a[i] = bank_b[i]; + prog_ = bank_a, outp_ = bank_b; + printf("%02d %s\n", rule, bank_a); } static char * @@ -138,7 +138,7 @@ addrule(char *s) static int rewrite(void) { - char c, *p = prog; + char c, *p = bank_a; while((c = *p)) { int i; if(p[0] == '<' && p[1] == '>') @@ -217,7 +217,7 @@ main(int argc, char **argv) if(!parse(argv[1])) return !printf("Invalid Modal file: %s.\n", argv[1]); print_rules(); - printf(".. %s\n", prog); + printf(".. %s\n", bank_a); while(rewrite()) ; return 0;