From 0dc32f04f979efc7e790d7c9708c7f8e3bfd7bb6 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Mon, 8 Apr 2024 09:28:36 -0700 Subject: [PATCH] Walk during commit --- src/modal.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/modal.c b/src/modal.c index d39f3ec..c3e1388 100644 --- a/src/modal.c +++ b/src/modal.c @@ -94,20 +94,15 @@ plode(char *s) static int commit(char r) { - int depth = 0; - char c, *s = regs[(int)r]; + char *s = regs[(int)r]; if(r == '*') s = plode(s); - else if(s[0] == '(') { - while((c = *s++)) { - if(c == '(') depth++; - *outp_++ = c; - if(c == ')') --depth; - if(!depth) return 1; - } - } - while(!spacer(s[0]) && (*outp_++ = *s++)) - ; + else if(s) { + char *ss = walk(s); + while((s < ss) && (*outp_++ = *s++)) + ; + } else + *outp_++ = r; return 1; } @@ -175,7 +170,7 @@ rewrite(void) char cc, *b = r->b; if(!*b && outp_ != bank_a && outp_ != bank_b) outp_--; while((cc = *b++)) { - if(cc == '?' && regs[(int)b[0]]) + if(cc == '?') commit(*b++); else *outp_++ = cc;