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) { } else if(s) {
char *ss = walk(s); char *ss = walk(s);
if(r == ':') { if(r == ':') {
if(*(outp_ - 1) == ' ') outp_--;
if(*s == '(') s++, --ss; if(*s == '(') s++, --ss;
while(s < ss) { while(s < ss) {
char c = *s++; char c = *s++;
@ -135,13 +134,13 @@ 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 last, char *res)
{ {
char cc, *b = r->b; char cc, *b = r->b, *origin = outp_;
if(!*b && last == ' ') outp_--;
while((cc = *b++)) while((cc = *b++))
if(spacer(last) && cc == '?') if(spacer(last) && cc == '?')
put_reg(*b++); put_reg(*b++);
else else
*outp_++ = cc, last = cc; *outp_++ = cc, last = cc;
if(last == ' ' && outp_ - origin == 0) outp_--;
return commit_rule(r, res, 0); return commit_rule(r, res, 0);
} }