Cache value before entering spacer macro

This commit is contained in:
Devine Lu Linvega 2024-04-08 10:10:56 -07:00
parent a512cb2888
commit c25561c650
1 changed files with 8 additions and 6 deletions

View File

@ -25,7 +25,7 @@ walk(char *s)
if(!depth) return s;
}
}
while(!spacer(s[0]) && *s++)
while((c = *s) && !spacer(c) && *s++)
;
return s;
}
@ -63,7 +63,8 @@ match(char *p, Rule *r)
if(*a != *b) return NULL;
a++, b++;
}
return spacer(*b) ? b : NULL;
c = *b;
return spacer(c) ? b : NULL;
}
static char *
@ -81,8 +82,8 @@ plode(char *s)
} else { /* explode */
*outp_++ = *s++, *outp_++ = ' ';
while((c = *s++) && !spacer(c)) {
*outp_++ = '(', *outp_++ = c, depth++;
if(!spacer(*s))
*outp_++ = '(', *outp_++ = c, depth++, c = *s;
if(!spacer(c))
*outp_++ = ' ';
}
for(i = 0; i < depth; i++)
@ -135,7 +136,7 @@ parse_rule(char *s)
static int
rewrite(void)
{
char c, last = 0, *p = direction ? bank_b : bank_a, *o = p;
char c, c_ = 0, last = 0, *p = direction ? bank_b : bank_a, *o = p;
while((c = *p) && c <= ' ') p++;
while((c = *p)) {
int i;
@ -148,7 +149,8 @@ rewrite(void)
r->b = parse_rule(p), p = walk(p);
return save(-1, p);
}
if(p == o || spacer(*(p - 1))) {
if(p != o) c_ = *(p - 1);
if(p == o || spacer(c_)) {
for(i = 0; i < rules_len; i++) {
Rule *r = &rules[i];
char *res = match(p, r);