From c73b9f0ad7cd61b673929c5ef1cacdc62092d1d6 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Tue, 23 Apr 2024 20:20:31 -0700 Subject: [PATCH] Housekeeping --- src/modal.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/modal.c b/src/modal.c index af322ae..a4b3001 100644 --- a/src/modal.c +++ b/src/modal.c @@ -14,7 +14,7 @@ static char bank_b[0x4000], *dst_ = bank_b; /* clang-format off */ #define spacer(c) (c <= ' ' || c == '(' || c == ')') -#define get_reg(x) { regid = x; for(i = 0; i < regs_ptr; i++) if(regs_key[i] == regid) { reg = regs_val[i]; break; } } +#define get_reg(x) { regid = x; for(i = 0; i < rptr; i++) if(rkey[i] == regid) { reg = rval[i]; break; } } /* clang-format on */ @@ -76,10 +76,9 @@ write_reg(char r, char *reg) *dst_++ = ' '; *dst_++ = '(', reg++, depth++; } - } else { /* token */ + } else /* token */ while((c = *reg++) && !spacer(c)) *dst_++ = c, *dst_++ = ' ', *dst_++ = '(', depth++; - } for(i = 0; i < depth; i++) *dst_++ = ')'; return 1; } @@ -111,8 +110,8 @@ write_rule(Rule *r, char *s, int create) static int apply_rule(Rule *r, char *s) { - int i, regid, regs_ptr = 0; - char c, *a = r->a, regs_key[0x10], *regs_val[0x10]; + int i, regid, rptr = 0; + char c, *a = r->a, rkey[0x10], *rval[0x10]; while((c = *a)) { /* phase: match rule */ if(c == '?') { char *pcap = walk(s), *reg = NULL; @@ -122,7 +121,7 @@ apply_rule(Rule *r, char *s) while(reg < rcap || pp < pcap) if(*reg++ != *pp++) return 0; } else /* reg set */ - regs_key[regs_ptr] = regid, regs_val[regs_ptr++] = s; + rkey[rptr] = regid, rval[rptr++] = s; a++, s = pcap; if(!spacer(*a)) while((c = *a) && !spacer(c)) a++; @@ -187,8 +186,7 @@ rewrite(void) return write_rule(r, s, 1); } if(c == '?' && s[1] == '(') { /* lambda */ - cap = walk(s + 1); - lambda.id = -1; + cap = walk(s + 1), lambda.id = -1; lambda.a = dict_, s = parse_frag(s + 2); lambda.b = dict_, parse_frag(s), s = cap; while(*s == ' ') s++;