Do not pass last to write_rule

This commit is contained in:
Devine Lu Linvega 2024-04-20 22:31:58 -07:00
parent 222c7f6f4c
commit 7a124eb70f
1 changed files with 4 additions and 4 deletions

View File

@ -136,9 +136,9 @@ commit_rule(Rule *r, char *s, int create)
} }
static int static int
write_rule(Rule *r, char last, char *res) write_rule(Rule *r, char *res)
{ {
char c, *b = r->b, *origin = dst_; char c, last = 0, *b = r->b, *origin = dst_;
while((c = *b++)) while((c = *b++))
if(c == '?' && last != '\\' && regs[(int)*b]) if(c == '?' && last != '\\' && regs[(int)*b])
put_reg(*b++); put_reg(*b++);
@ -197,11 +197,11 @@ rewrite(void)
create_rule(&lambda, -1, s), s = cap; create_rule(&lambda, -1, s), s = cap;
while((c = *s) && c <= ' ') s++; while((c = *s) && c <= ' ') s++;
if((res = match_rule(&lambda, s)) != NULL) if((res = match_rule(&lambda, s)) != NULL)
return write_rule(&lambda, last, res); return write_rule(&lambda, res);
} }
for(r = rules; r < rules_; r++) for(r = rules; r < rules_; r++)
if((res = match_rule(r, s)) != NULL) if((res = match_rule(r, s)) != NULL)
return write_rule(r, last, res); return write_rule(r, res);
} }
*dst_++ = last = c; *dst_++ = last = c;
s++; s++;