Fixed issue with writing empty register
This commit is contained in:
parent
8431ac66f6
commit
9780e2aad7
13
src/modal.c
13
src/modal.c
|
@ -194,7 +194,7 @@ static int
|
||||||
apply_rule(Rule *r, char *s)
|
apply_rule(Rule *r, char *s)
|
||||||
{
|
{
|
||||||
unsigned char rid;
|
unsigned char rid;
|
||||||
char c, *a = r->a, *b = r->b, *origin = dst_, *reg;
|
char c, *a = r->a, *b = r->b, *origin = dst_, *reg, last = 0;
|
||||||
/* phase: clean regs */
|
/* phase: clean regs */
|
||||||
while(stack_ != stack) regs[(int)*(--stack_)] = 0;
|
while(stack_ != stack) regs[(int)*(--stack_)] = 0;
|
||||||
/* phase: match rule */
|
/* phase: match rule */
|
||||||
|
@ -216,10 +216,15 @@ apply_rule(Rule *r, char *s)
|
||||||
if(!spacer(c)) return 0;
|
if(!spacer(c)) return 0;
|
||||||
/* phase: write rule */
|
/* phase: write rule */
|
||||||
while((c = *b++))
|
while((c = *b++))
|
||||||
if(c == '?' && (rid = *b) && (reg = regs[rid]))
|
if(c == '?' && (rid = *b) && (reg = regs[rid])){
|
||||||
|
char *ori = dst_;
|
||||||
write_reg(rid, reg), b++;
|
write_reg(rid, reg), b++;
|
||||||
else
|
if(dst_ == ori){
|
||||||
*dst_++ = c;
|
if(b[0] == ' ') b++;
|
||||||
|
else if(last == ' ') dst_--;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
*dst_++ = last = c;
|
||||||
if(dst_ == origin) {
|
if(dst_ == origin) {
|
||||||
while(*s == ' ') s++;
|
while(*s == ' ') s++;
|
||||||
if(*s == ')' && *(dst_ - 1) == ' ') dst_--;
|
if(*s == ')' && *(dst_ - 1) == ' ') dst_--;
|
||||||
|
|
Loading…
Reference in New Issue