Halt after a number of rewrites

This commit is contained in:
Devine Lu Linvega 2024-04-15 08:47:20 -07:00
parent 8d661163af
commit 966304f09a
1 changed files with 4 additions and 4 deletions

View File

@ -5,7 +5,7 @@ typedef struct {
char *a, *b;
} Rule;
static int flip;
static int flip, cycles = 0x10000;
static Rule rules[0x1000], lambda, *rules_ = rules;
static char dict[0x8000], *dict_ = dict;
static char bank_a[0x4000], *src_ = bank_a;
@ -197,9 +197,9 @@ main(int argc, char **argv)
if(argc < 2)
return !printf("usage: modal [-v] source.modal\n");
if(argc < 3 && argv[1][0] == '-' && argv[1][1] == 'v')
return !printf("Modal Interpreter, 14 Apr 2024.\n");
return !printf("Modal Interpreter, 15 Apr 2024.\n");
if(!(f = fopen(argv[1], "r")))
return !printf("Invalid Modal file: %s.\n", argv[1]);
return !fprintf(stderr, "Invalid Modal file: %s.\n", argv[1]);
while(fread(&c, 1, 1, f)) {
c = c <= 0x20 ? 0x20 : c;
if(w > bank_a) {
@ -212,6 +212,6 @@ main(int argc, char **argv)
while(*(--w) <= ' ') *w = 0;
fclose(f);
while(rewrite())
;
if(cycles--) return !fprintf(stderr, "Cycle limit exceeded.\n");
return 0;
}