Removed copy after rewriting

This commit is contained in:
Devine Lu Linvega 2024-04-06 08:36:10 -07:00
parent f2e1b60f99
commit cced3c8d26
1 changed files with 7 additions and 7 deletions

View File

@ -4,7 +4,7 @@ typedef struct {
char *a, *b; char *a, *b;
} Rule; } Rule;
static int rules_len; static int rules_len, direction = 0;
static Rule rules[0x100]; static Rule rules[0x100];
static char dict[0x8000], *dict_ = dict; static char dict[0x8000], *dict_ = dict;
static char bank_a[0x1000], *prog_ = bank_a; static char bank_a[0x1000], *prog_ = bank_a;
@ -89,11 +89,11 @@ bind(char r)
static void static void
save(int rule) save(int rule)
{ {
int i, end = outp_ - bank_b; if((direction = !direction))
/* todo: change pointer instead of copying memory */ prog_ = bank_b, outp_ = bank_a;
for(i = 0; i <= end; i++) bank_a[i] = bank_b[i]; else
prog_ = bank_a, outp_ = bank_b; prog_ = bank_a, outp_ = bank_b;
printf("%02d %s\n", rule, bank_a); printf("%02d %s\n", rule, direction ? bank_b : bank_a);
} }
static char * static char *
@ -138,7 +138,7 @@ addrule(char *s)
static int static int
rewrite(void) rewrite(void)
{ {
char c, *p = bank_a; char c, *p = direction ? bank_b : bank_a;
while((c = *p)) { while((c = *p)) {
int i; int i;
if(p[0] == '<' && p[1] == '>') if(p[0] == '<' && p[1] == '>')