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