From 6cb6c810d9ffddc2ab593914135668c94db6efb6 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sun, 7 Apr 2024 14:55:55 -0700 Subject: [PATCH] Let save handle the rest of the string --- src/modal.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) 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); } } }