From c63021cf0318d8f952dc5da17d4868bf57cef5a0 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 24 Apr 2024 10:39:14 -0700 Subject: [PATCH] Houeskeeping --- makefile | 2 +- src/modal.c | 21 +++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/makefile b/makefile index cf49fed..5fc6c66 100644 --- a/makefile +++ b/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 diff --git a/src/modal.c b/src/modal.c index 0a6ba31..3730ac4 100644 --- a/src/modal.c +++ b/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