Removed temporary pointers
This commit is contained in:
parent
3f5e099051
commit
ca76fdd9c3
73
src/modal.c
73
src/modal.c
|
@ -162,66 +162,51 @@ static char *
|
||||||
compile_rule(Rule *r, int id, char *src)
|
compile_rule(Rule *r, int id, char *src)
|
||||||
{
|
{
|
||||||
int wrapped, reg;
|
int wrapped, reg;
|
||||||
char c, *cap, *s2;
|
char c, *cap;
|
||||||
r->id = id, r->ptr = 0;
|
r->id = id, r->ptr = 0;
|
||||||
|
/* phase: left */
|
||||||
/* left ==================================== */
|
|
||||||
|
|
||||||
r->a = r->b = dict_;
|
r->a = r->b = dict_;
|
||||||
s2 = src;
|
while((c = *src) && c == ' ') src++;
|
||||||
|
if(c == ')' || (c == '<' && src[1] == '>')) {
|
||||||
while((c = *s2) && c == ' ') s2++;
|
|
||||||
if(c == ')' || (c == '<' && s2[1] == '>')) {
|
|
||||||
*dict_++ = 0;
|
*dict_++ = 0;
|
||||||
return s2;
|
return src;
|
||||||
}
|
}
|
||||||
|
cap = walk(src);
|
||||||
cap = walk(s2);
|
|
||||||
wrapped = c == '(';
|
wrapped = c == '(';
|
||||||
if(wrapped) s2++, cap--;
|
if(wrapped) src++, cap--;
|
||||||
while(s2 < cap) {
|
while(src < cap) {
|
||||||
if(*s2 == '?') {
|
if(*src == '?') {
|
||||||
*dict_++ = *s2++;
|
*dict_++ = *src++;
|
||||||
reg = find_register(r, *s2);
|
reg = find_register(r, *src);
|
||||||
if(reg < 0 && *s2 != '(')
|
if(reg < 0 && *src != '(')
|
||||||
r->key[r->ptr] = *s2, reg = r->ptr++;
|
r->key[r->ptr] = *src, reg = r->ptr++;
|
||||||
*dict_++ = '0' + reg;
|
*dict_++ = '0' + reg;
|
||||||
} else
|
} else
|
||||||
*dict_++ = *s2++;
|
*dict_++ = *src++;
|
||||||
}
|
}
|
||||||
s2 += wrapped;
|
src += wrapped;
|
||||||
|
|
||||||
*dict_++ = 0;
|
*dict_++ = 0;
|
||||||
src = s2;
|
/* phase: right */
|
||||||
|
|
||||||
/* right ==================================== */
|
|
||||||
|
|
||||||
r->b = dict_;
|
r->b = dict_;
|
||||||
s2 = src;
|
while((c = *src) && c == ' ') src++;
|
||||||
|
if(c == ')' || (c == '<' && src[1] == '>')) {
|
||||||
while((c = *s2) && c == ' ') s2++;
|
|
||||||
if(c == ')' || (c == '<' && s2[1] == '>')) {
|
|
||||||
*dict_++ = 0;
|
*dict_++ = 0;
|
||||||
return s2;
|
return src;
|
||||||
}
|
}
|
||||||
|
cap = walk(src);
|
||||||
cap = walk(s2);
|
|
||||||
wrapped = c == '(';
|
wrapped = c == '(';
|
||||||
if(wrapped) s2++, cap--;
|
if(wrapped) src++, cap--;
|
||||||
while(s2 < cap) {
|
while(src < cap) {
|
||||||
if(*s2 == '?') {
|
if(*src == '?') {
|
||||||
*dict_++ = *s2++;
|
*dict_++ = *src++;
|
||||||
reg = find_register(r, *s2);
|
reg = find_register(r, *src);
|
||||||
*dict_++ = reg >= 0 ? ('0' + reg) : *s2;
|
*dict_++ = reg >= 0 ? ('0' + reg) : *src;
|
||||||
s2++;
|
src++;
|
||||||
} else
|
} else
|
||||||
*dict_++ = *s2++;
|
*dict_++ = *src++;
|
||||||
}
|
}
|
||||||
s2 += wrapped;
|
src += wrapped;
|
||||||
|
|
||||||
*dict_++ = 0;
|
*dict_++ = 0;
|
||||||
src = s2;
|
|
||||||
|
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue