diff --git a/src/modal.c b/src/modal.c index b341e5d..2a8594e 100644 --- a/src/modal.c +++ b/src/modal.c @@ -104,7 +104,7 @@ write_rule(Rule *r, char *s, int create) } static int -run_rule(Rule *r, char *s) +apply_rule(Rule *r, char *s) { int i; char c, *a = r->a; @@ -113,7 +113,7 @@ run_rule(Rule *r, char *s) regs[i] = 0; rmin = 0xff, rmax = 0x00; } - while((c = *a)) { + while((c = *a)) { /* phase: match rule */ if(c == '?') { int regid = (int)*(++a); char *pcap = walk(s), *reg = regs[regid]; @@ -134,8 +134,7 @@ run_rule(Rule *r, char *s) if(c != *s) return 0; a++, s++; } - c = *s; - if(spacer(c)) { + if(!(c = *s) || spacer(c)) { /* phase: write rule */ char *b = r->b, *reg, *origin = dst_; while((c = *b++)) if(c == '?' && (reg = regs[(int)*b])) @@ -190,10 +189,10 @@ rewrite(void) lambda.a = dict_, s = parse_frag(s + 2); lambda.b = dict_, parse_frag(s), s = cap; while(*s == ' ') s++; - return run_rule(&lambda, s); + return apply_rule(&lambda, s); } for(r = rules; r < rules_; r++) - if(run_rule(r, s)) return 1; + if(apply_rule(r, s)) return 1; } *dst_++ = last = c; s++;