Use copy() in parse_frag
This commit is contained in:
parent
0de5bb473b
commit
f6d0cc8ece
19
src/modal.c
19
src/modal.c
|
@ -221,20 +221,19 @@ apply_rule(Rule *r, char *s)
|
|||
}
|
||||
|
||||
static char *
|
||||
parse_frag(char **side, char *src)
|
||||
parse_frag(char **side, char *s)
|
||||
{
|
||||
int wrapped;
|
||||
char c, *cap;
|
||||
while((c = *src) && c == ' ') src++;
|
||||
if(c == ')' || (c == '<' && src[1] == '>')) {
|
||||
while((c = *s) && c == ' ') s++;
|
||||
if(c == ')' || (c == '<' && s[1] == '>')) {
|
||||
*side = ∅
|
||||
return src;
|
||||
return s;
|
||||
}
|
||||
*side = dict_, cap = walk(src), wrapped = c == '(';
|
||||
if(wrapped) src++, cap--;
|
||||
while(src < cap) *dict_++ = *src++;
|
||||
src += wrapped, *dict_++ = 0;
|
||||
return src;
|
||||
*side = dict_, cap = walk(s), wrapped = c == '(';
|
||||
if(wrapped) s++, cap--;
|
||||
dict_ = copy(s, dict_, cap - s), s = cap + wrapped, *dict_++ = 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
static Rule *
|
||||
|
@ -291,7 +290,7 @@ rewrite(void)
|
|||
parse_frag(&r->b, parse_frag(&r->a, s + 2));
|
||||
s = cap;
|
||||
while(*s == ' ') s++;
|
||||
if(!apply_rule(r, s)) {
|
||||
if(r->a && !apply_rule(r, s)) {
|
||||
if(!quiet) fprintf(stderr, "%02d %s\n", r->id, src_), ++r->refs;
|
||||
write_tail(s);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue