Houeskeeping
This commit is contained in:
parent
b866c69776
commit
c63021cf03
2
makefile
2
makefile
|
@ -8,7 +8,7 @@ all: dest
|
|||
dest:
|
||||
@ mkdir -p bin
|
||||
run: all bin/modal
|
||||
@ bin/modal -q examples/hello.modal
|
||||
@ bin/modal examples/hello.modal
|
||||
debug: all bin/modal-debug
|
||||
@ bin/modal-debug examples/hello.modal
|
||||
test: all bin/modal-debug bin/modal
|
||||
|
|
21
src/modal.c
21
src/modal.c
|
@ -109,18 +109,14 @@ apply_rule(Rule *r, char *s)
|
|||
while((c = *a)) { /* phase: match rule */
|
||||
if(c == '?') {
|
||||
char *pcap = walk(s), *reg = NULL;
|
||||
int id = *(++a);
|
||||
unsigned int id2 = id - '0';
|
||||
if(id2 < r->ptr) {
|
||||
reg = regs[id2];
|
||||
}
|
||||
unsigned int id = *(++a) - '0';
|
||||
if(id < r->ptr) reg = regs[id];
|
||||
if(reg) { /* reg cmp */
|
||||
char *rcap = walk(reg), *pp = s;
|
||||
while(reg < rcap || pp < pcap)
|
||||
if(*reg++ != *pp++) return 0;
|
||||
} else { /* reg set */
|
||||
regs[id2] = s;
|
||||
}
|
||||
} else /* reg set */
|
||||
regs[id] = s;
|
||||
a++, s = pcap;
|
||||
if(!spacer(*a))
|
||||
while((c = *a) && !spacer(c)) a++;
|
||||
|
@ -134,14 +130,11 @@ apply_rule(Rule *r, char *s)
|
|||
while((c = *b++)) {
|
||||
if(c == '?') {
|
||||
char *reg = NULL;
|
||||
int id = *b;
|
||||
unsigned int id2 = id - '0';
|
||||
if(id2 < r->ptr) {
|
||||
reg = regs[id2];
|
||||
}
|
||||
unsigned int id = *b - '0';
|
||||
if(id < r->ptr) reg = regs[id];
|
||||
if(reg) {
|
||||
b++;
|
||||
if(!write_reg(r->key[id2], reg) && dst_ != origin) dst_--;
|
||||
if(!write_reg(r->key[id], reg) && dst_ != origin) dst_--;
|
||||
} else
|
||||
*dst_++ = c;
|
||||
} else
|
||||
|
|
Loading…
Reference in New Issue