Abstracted match/write rule
This commit is contained in:
parent
8e7bbb51d7
commit
4fce0e83e5
14
src/modal.c
14
src/modal.c
|
@ -165,10 +165,19 @@ parse_frag(char *s)
|
|||
return s;
|
||||
}
|
||||
|
||||
static int
|
||||
run_rule(Rule *r, char *s)
|
||||
{
|
||||
char *res;
|
||||
if((res = match_rule(r, s)) != NULL)
|
||||
return write_rule(r, res);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rewrite(void)
|
||||
{
|
||||
char c, last = 0, *cap, *s = src_, *res;
|
||||
char c, last = 0, *cap, *s = src_;
|
||||
while(*s == ' ') s++;
|
||||
while((c = *s)) {
|
||||
if(spacer(last)) {
|
||||
|
@ -190,8 +199,7 @@ rewrite(void)
|
|||
} else
|
||||
r = rules + 1;
|
||||
for(; r < rules_; r++)
|
||||
if((res = match_rule(r, s)) != NULL)
|
||||
return write_rule(r, res);
|
||||
if(run_rule(r, s)) return 1;
|
||||
}
|
||||
*dst_++ = last = c;
|
||||
s++;
|
||||
|
|
Loading…
Reference in New Issue