Merge remote-tracking branch 'upstream/master' into d6/binary
This commit is contained in:
commit
a80a5ab826
22
src/modal.c
22
src/modal.c
|
@ -216,23 +216,19 @@ int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char c, *w = bank_a;
|
|
||||||
int i;
|
int i;
|
||||||
|
char c, *w = bank_a;
|
||||||
if(argc < 2)
|
if(argc < 2)
|
||||||
return !printf("usage: modal [-v] source.modal\n");
|
return !printf("usage: modal [-vqn] source.modal\n");
|
||||||
for(i = 1; i < argc && argv[i][0] == '-'; i++) {
|
for(i = 1; i < argc && *argv[i] == '-'; i++) {
|
||||||
if(argv[i][1] == 'v') {
|
switch(argv[i][1]) {
|
||||||
return !printf("Modal Interpreter, 17 Apr 2024.\n");
|
case 'v': /* version */ return !printf("Modal Interpreter, 18 Apr 2024.\n");
|
||||||
} else if(argv[i][1] == 'q') {
|
case 'q': /* quiet */ fclose(stderr); break;
|
||||||
fclose(stderr);
|
case 'n': /* infinite */ cycles = 0xffffffff; break;
|
||||||
} else if(argv[i][1] == 'n') {
|
|
||||||
cycles = 0xffffffff;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!(f = fopen(argv[i], "r")))
|
if(!(f = fopen(argv[i], "r")))
|
||||||
return !fprintf(stderr, "Invalid Modal file: %s.\n", argv[i]);
|
return !fprintf(stdout, "Invalid Modal file: %s.\n", argv[i]);
|
||||||
while(fread(&c, 1, 1, f)) {
|
while(fread(&c, 1, 1, f)) {
|
||||||
c = c <= 0x20 ? 0x20 : c;
|
c = c <= 0x20 ? 0x20 : c;
|
||||||
if(w > bank_a) {
|
if(w > bank_a) {
|
||||||
|
@ -245,6 +241,6 @@ main(int argc, char **argv)
|
||||||
while(*(--w) <= ' ') *w = 0;
|
while(*(--w) <= ' ') *w = 0;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
while(rewrite())
|
while(rewrite())
|
||||||
if(!cycles--) return !fprintf(stderr, "Cycle limit exceeded.\n");
|
if(!cycles--) return !fprintf(stdout, "Modal rewrites exceeded.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue