diff --git a/makefile b/makefile index 5fc6c66..cf49fed 100644 --- a/makefile +++ b/makefile @@ -8,7 +8,7 @@ all: dest dest: @ mkdir -p bin run: all bin/modal - @ bin/modal examples/hello.modal + @ bin/modal -q examples/hello.modal debug: all bin/modal-debug @ bin/modal-debug examples/hello.modal test: all bin/modal-debug bin/modal diff --git a/src/modal.c b/src/modal.c index 3730ac4..8a1744a 100644 --- a/src/modal.c +++ b/src/modal.c @@ -105,13 +105,13 @@ write_rule(Rule *r, char *s, int create) static int apply_rule(Rule *r, char *s) { - char c, *a = r->a, *regs[0x10] = {NULL}; - while((c = *a)) { /* phase: match rule */ + char c, *a = r->a, *regs[0x08] = {NULL}; + /* phase: match rule */ + while((c = *a)) { if(c == '?') { char *pcap = walk(s), *reg = NULL; unsigned int id = *(++a) - '0'; - if(id < r->ptr) reg = regs[id]; - if(reg) { /* reg cmp */ + if((reg = regs[id])) { /* reg cmp */ char *rcap = walk(reg), *pp = s; while(reg < rcap || pp < pcap) if(*reg++ != *pp++) return 0; @@ -125,7 +125,8 @@ apply_rule(Rule *r, char *s) if(c != *s) return 0; a++, s++; } - if(!(c = *s) || spacer(c)) { /* phase: write rule */ + /* phase: write rule */ + if(!(c = *s) || spacer(c)) { char *b = r->b, *origin = dst_; while((c = *b++)) { if(c == '?') {