From 86bc540ee227bbbb7c1b9bb91388c8dc13b6e33b Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Fri, 12 Apr 2024 09:34:55 -0700 Subject: [PATCH] Generalized space-eating writing --- src/modal.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/modal.c b/src/modal.c index ae56375..fa9c848 100644 --- a/src/modal.c +++ b/src/modal.c @@ -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); }