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)
|
||||
{
|
||||
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 */
|
||||
while(stack_ != stack) regs[(int)*(--stack_)] = 0;
|
||||
/* phase: match rule */
|
||||
|
@ -216,10 +216,15 @@ apply_rule(Rule *r, char *s)
|
|||
if(!spacer(c)) return 0;
|
||||
/* phase: write rule */
|
||||
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++;
|
||||
else
|
||||
*dst_++ = c;
|
||||
if(dst_ == ori){
|
||||
if(b[0] == ' ') b++;
|
||||
else if(last == ' ') dst_--;
|
||||
}
|
||||
} else
|
||||
*dst_++ = last = c;
|
||||
if(dst_ == origin) {
|
||||
while(*s == ' ') s++;
|
||||
if(*s == ')' && *(dst_ - 1) == ' ') dst_--;
|
||||
|
|
Loading…
Reference in New Issue