From f139f3218e0f8a74abd2c42908b38c79b01d4cee Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 20 Apr 2024 11:09:43 -0700 Subject: [PATCH] Do not injest register on empty put_reg --- src/modal.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/modal.c b/src/modal.c index 3b654cd..fd5e6e5 100644 --- a/src/modal.c +++ b/src/modal.c @@ -48,12 +48,7 @@ set_reg(int r, char *b) static void put_reg(char r) { - char c, *s = regs[(int)r], *ss; - if(!s) { - *dst_++ = '?', *dst_++ = r; - return; - } - ss = walk(s); + char c, *s = regs[(int)r], *ss = walk(s); if(r == '*') { int i, depth = 0; if(*s == '(') { /* special explode tuple */ @@ -142,7 +137,7 @@ write_rule(Rule *r, char last, char *res) { char c, *b = r->b, *origin = dst_; while((c = *b++)) - if(spacer(last) && c == '?') + if(spacer(last) && c == '?' && regs[(int)*b]) put_reg(*b++); else *dst_++ = c, last = c; @@ -222,7 +217,7 @@ main(int argc, char **argv) return !printf("usage: modal [-vqn] source.modal\n"); for(i = 1; i < argc && *argv[i] == '-'; i++) { switch(argv[i][1]) { - case 'v': /* version */ return !printf("Modal Interpreter, 19 Apr 2024.\n"); + case 'v': /* version */ return !printf("Modal Interpreter, 20 Apr 2024.\n"); case 'q': /* quiet */ fclose(stderr); break; case 'n': /* infinite */ cycles = 0xffffffff; break; }