From 3136ae834fe67ffa8dcb6421ec1fba6acece3b32 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 24 Apr 2024 11:18:06 -0700 Subject: [PATCH] Walk over incompiled registers --- src/modal.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/modal.c b/src/modal.c index 8a1744a..8296df0 100644 --- a/src/modal.c +++ b/src/modal.c @@ -105,11 +105,11 @@ write_rule(Rule *r, char *s, int create) static int apply_rule(Rule *r, char *s) { - char c, *a = r->a, *regs[0x08] = {NULL}; + char c, *a = r->a, *regs[0x08] = {NULL}, *reg; /* phase: match rule */ while((c = *a)) { if(c == '?') { - char *pcap = walk(s), *reg = NULL; + char *pcap = walk(s); unsigned int id = *(++a) - '0'; if((reg = regs[id])) { /* reg cmp */ char *rcap = walk(reg), *pp = s; @@ -129,11 +129,9 @@ apply_rule(Rule *r, char *s) if(!(c = *s) || spacer(c)) { char *b = r->b, *origin = dst_; while((c = *b++)) { - if(c == '?') { - char *reg = NULL; + if(c == '?' && (unsigned int)(*b - '0') < 9) { unsigned int id = *b - '0'; - if(id < r->ptr) reg = regs[id]; - if(reg) { + if((reg = regs[id])) { b++; if(!write_reg(r->key[id], reg) && dst_ != origin) dst_--; } else