Limit matches queries

This commit is contained in:
Devine Lu Linvega 2024-04-24 11:12:57 -07:00
parent c63021cf03
commit 4535c11017
2 changed files with 7 additions and 6 deletions

View File

@ -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

View File

@ -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 == '?') {