Writing registers
This commit is contained in:
parent
36cf4b295f
commit
91b68104d0
18
src/modal.c
18
src/modal.c
|
@ -37,6 +37,21 @@ match(char *p, Rule *r)
|
|||
return b;
|
||||
}
|
||||
|
||||
static int
|
||||
writereg(char r)
|
||||
{
|
||||
int depth = 0;
|
||||
char c, *s = regs[(int)r];
|
||||
while((c = *s++)) {
|
||||
if(c == '(') depth++;
|
||||
if(c == ')') --depth;
|
||||
if(c == ' ' && !depth)
|
||||
break;
|
||||
*outp_++ = c;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
rewrite(void)
|
||||
{
|
||||
|
@ -49,6 +64,9 @@ rewrite(void)
|
|||
if(res != NULL) {
|
||||
char cc, *b = r->b;
|
||||
while((cc = *b++)) {
|
||||
if(cc == '?')
|
||||
writereg(*b++);
|
||||
else
|
||||
*outp_++ = cc;
|
||||
}
|
||||
found = 1;
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<> bar baz
|
||||
<> (?x dup) (?x ?x)
|
||||
|
||||
foo bar
|
||||
foo (hey dup)
|
Loading…
Reference in New Issue