Reduce register clearing tasks
This commit is contained in:
parent
acb655ad10
commit
8df2a496cc
12
src/modal.c
12
src/modal.c
|
@ -5,7 +5,7 @@ typedef struct {
|
||||||
char *a, *b;
|
char *a, *b;
|
||||||
} Rule;
|
} Rule;
|
||||||
|
|
||||||
static int flip, cycles = 0x10000;
|
static int flip, rmin = 0xff, rmax = 0x00, cycles = 0x10000;
|
||||||
static Rule rules[0x1000], lambda, *rules_ = rules;
|
static Rule rules[0x1000], lambda, *rules_ = rules;
|
||||||
static char dict[0x8000], *dict_ = dict;
|
static char dict[0x8000], *dict_ = dict;
|
||||||
static char bank_a[0x4000], *src_ = bank_a;
|
static char bank_a[0x4000], *src_ = bank_a;
|
||||||
|
@ -37,8 +37,11 @@ set_reg(int r, char *b)
|
||||||
char *a = regs[r], *aa = walk(a), *bb = walk(b);
|
char *a = regs[r], *aa = walk(a), *bb = walk(b);
|
||||||
while(a < aa && b < bb)
|
while(a < aa && b < bb)
|
||||||
if(*a++ != *b++) return 0;
|
if(*a++ != *b++) return 0;
|
||||||
} else
|
} else {
|
||||||
regs[r] = b;
|
regs[r] = b;
|
||||||
|
if(r < rmin) rmin = r;
|
||||||
|
if(r > rmax) rmax = r;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,8 +90,11 @@ match_rule(Rule *r, char *p)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char c, last = 0, *a = r->a, *b = p;
|
char c, last = 0, *a = r->a, *b = p;
|
||||||
for(i = 0x21; i < 0x7f; i++)
|
if(rmax) {
|
||||||
|
for(i = 0; i <= rmax; i++)
|
||||||
regs[i] = 0;
|
regs[i] = 0;
|
||||||
|
rmin = 0xff, rmax = 0x00;
|
||||||
|
}
|
||||||
while((c = *a)) {
|
while((c = *a)) {
|
||||||
if(spacer(last) && c == '?') {
|
if(spacer(last) && c == '?') {
|
||||||
if(!set_reg(*(++a), b)) return NULL;
|
if(!set_reg(*(++a), b)) return NULL;
|
||||||
|
|
Loading…
Reference in New Issue