diff --git a/src/modal.c b/src/modal.c index fb951d2..34ea05e 100644 --- a/src/modal.c +++ b/src/modal.c @@ -121,9 +121,12 @@ commit(char r, char *incoming) return 1; } -static void -save(int rule) +static int +save(int rule, char *p) { + while((*outp_++ = *p++)) + ; + *outp_++ = 0; if((direction = !direction)) prog_ = bank_b, outp_ = bank_a; else @@ -133,6 +136,7 @@ save(int rule) while(program[1] && program[0] < 0x21) program++; fprintf(stderr, "%02d %s\n", rule, program); } + return 1; } static char * @@ -174,10 +178,7 @@ rewrite(char *incoming) p += 3; r->a = parse_rulefrag(p), p = walk(p) + 1; r->b = parse_rulefrag(p), p = walk(p); - while((*outp_++ = *p++)) - ; - save(-1); - return 1; + return save(-1, p); } if(p == bank_a || p == bank_b || spacer(*(p - 1))) { for(i = 0; i < rules_len; i++) { @@ -191,11 +192,7 @@ rewrite(char *incoming) else *outp_++ = cc; } - while((*outp_++ = *res++)) - ; - *outp_++ = 0; - save(i); - return 1; + return save(i, res); } } }