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