Generalized space-eating writing

This commit is contained in:
Devine Lu Linvega 2024-04-12 09:34:55 -07:00
parent 9c9814d6f7
commit 86bc540ee2
1 changed files with 2 additions and 3 deletions

View File

@ -76,7 +76,6 @@ put_reg(char r)
} else if(s) {
char *ss = walk(s);
if(r == ':') {
if(*(outp_ - 1) == ' ') outp_--;
if(*s == '(') s++, --ss;
while(s < ss) {
char c = *s++;
@ -135,13 +134,13 @@ commit_rule(Rule *r, char *s, int create)
static int
write_rule(Rule *r, char last, char *res)
{
char cc, *b = r->b;
if(!*b && last == ' ') outp_--;
char cc, *b = r->b, *origin = outp_;
while((cc = *b++))
if(spacer(last) && cc == '?')
put_reg(*b++);
else
*outp_++ = cc, last = cc;
if(last == ' ' && outp_ - origin == 0) outp_--;
return commit_rule(r, res, 0);
}