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 *
|
static char *
|
||||||
parse_frag(char **side, char *src)
|
parse_frag(char **side, char *s)
|
||||||
{
|
{
|
||||||
int wrapped;
|
int wrapped;
|
||||||
char c, *cap;
|
char c, *cap;
|
||||||
while((c = *src) && c == ' ') src++;
|
while((c = *s) && c == ' ') s++;
|
||||||
if(c == ')' || (c == '<' && src[1] == '>')) {
|
if(c == ')' || (c == '<' && s[1] == '>')) {
|
||||||
*side = ∅
|
*side = ∅
|
||||||
return src;
|
return s;
|
||||||
}
|
}
|
||||||
*side = dict_, cap = walk(src), wrapped = c == '(';
|
*side = dict_, cap = walk(s), wrapped = c == '(';
|
||||||
if(wrapped) src++, cap--;
|
if(wrapped) s++, cap--;
|
||||||
while(src < cap) *dict_++ = *src++;
|
dict_ = copy(s, dict_, cap - s), s = cap + wrapped, *dict_++ = 0;
|
||||||
src += wrapped, *dict_++ = 0;
|
return s;
|
||||||
return src;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Rule *
|
static Rule *
|
||||||
|
@ -291,7 +290,7 @@ rewrite(void)
|
||||||
parse_frag(&r->b, parse_frag(&r->a, s + 2));
|
parse_frag(&r->b, parse_frag(&r->a, s + 2));
|
||||||
s = cap;
|
s = cap;
|
||||||
while(*s == ' ') s++;
|
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;
|
if(!quiet) fprintf(stderr, "%02d %s\n", r->id, src_), ++r->refs;
|
||||||
write_tail(s);
|
write_tail(s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue