Exit after match in rewrite
This commit is contained in:
parent
920be34b20
commit
8702b6472b
17
src/modal.c
17
src/modal.c
|
@ -73,10 +73,10 @@ save(void)
|
||||||
static int
|
static int
|
||||||
rewrite(void)
|
rewrite(void)
|
||||||
{
|
{
|
||||||
int success = 0;
|
|
||||||
char c, *p = prog;
|
char c, *p = prog;
|
||||||
while((c = *p)) {
|
while((c = *p)) {
|
||||||
int i, found = 0;
|
int i;
|
||||||
for(i = 0; i < rules_len; i++) {
|
for(i = 0; i < rules_len; i++) {
|
||||||
Rule *r = &rules[i];
|
Rule *r = &rules[i];
|
||||||
char *res = match(p, r);
|
char *res = match(p, r);
|
||||||
|
@ -88,19 +88,18 @@ rewrite(void)
|
||||||
else
|
else
|
||||||
*outp_++ = cc;
|
*outp_++ = cc;
|
||||||
}
|
}
|
||||||
found = success = 1;
|
while((*outp_++ = *res++))
|
||||||
p = res;
|
;
|
||||||
|
*outp_++ = 0;
|
||||||
|
save();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!found) {
|
|
||||||
*outp_++ = c;
|
*outp_++ = c;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
*outp_++ = 0;
|
*outp_++ = 0;
|
||||||
if(success)
|
return 0;
|
||||||
save();
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue