Exit after match in rewrite

This commit is contained in:
Devine Lu Linvega 2024-04-04 19:55:05 -07:00
parent 920be34b20
commit 8702b6472b
1 changed files with 10 additions and 11 deletions

View File

@ -73,10 +73,10 @@ save(void)
static int
rewrite(void)
{
int success = 0;
char c, *p = prog;
while((c = *p)) {
int i, found = 0;
int i;
for(i = 0; i < rules_len; i++) {
Rule *r = &rules[i];
char *res = match(p, r);
@ -88,19 +88,18 @@ rewrite(void)
else
*outp_++ = cc;
}
found = success = 1;
p = res;
while((*outp_++ = *res++))
;
*outp_++ = 0;
save();
return 1;
}
}
if(!found) {
*outp_++ = c;
p++;
}
}
*outp_++ = 0;
if(success)
save();
return success;
return 0;
}
static void