Added comments
This commit is contained in:
parent
91150500dd
commit
157d1909ea
11
src/modal.c
11
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++;
|
||||
|
|
Loading…
Reference in New Issue