Let save handle the rest of the string

This commit is contained in:
Devine Lu Linvega 2024-04-07 14:55:55 -07:00
parent 18d1987568
commit 6cb6c810d9
1 changed files with 8 additions and 11 deletions

View File

@ -121,9 +121,12 @@ commit(char r, char *incoming)
return 1;
}
static void
save(int rule)
static int
save(int rule, char *p)
{
while((*outp_++ = *p++))
;
*outp_++ = 0;
if((direction = !direction))
prog_ = bank_b, outp_ = bank_a;
else
@ -133,6 +136,7 @@ save(int rule)
while(program[1] && program[0] < 0x21) program++;
fprintf(stderr, "%02d %s\n", rule, program);
}
return 1;
}
static char *
@ -174,10 +178,7 @@ rewrite(char *incoming)
p += 3;
r->a = parse_rulefrag(p), p = walk(p) + 1;
r->b = parse_rulefrag(p), p = walk(p);
while((*outp_++ = *p++))
;
save(-1);
return 1;
return save(-1, p);
}
if(p == bank_a || p == bank_b || spacer(*(p - 1))) {
for(i = 0; i < rules_len; i++) {
@ -191,11 +192,7 @@ rewrite(char *incoming)
else
*outp_++ = cc;
}
while((*outp_++ = *res++))
;
*outp_++ = 0;
save(i);
return 1;
return save(i, res);
}
}
}