From 98748fb44dd7e4eb305e358de76b05904db09f4e Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sun, 7 Apr 2024 10:58:39 -0700 Subject: [PATCH] Inlined load --- src/modal.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/modal.c b/src/modal.c index 3812bdd..e188595 100644 --- a/src/modal.c +++ b/src/modal.c @@ -213,12 +213,17 @@ print_rules(void) fprintf(stderr, "\n"); } -static int -load(char *path) +int +main(int argc, char **argv) { + FILE *f; char c, *w = bank_a; - FILE *f = fopen(path, "r"); - if(!f) return 0; + if(argc < 2) + return !printf("usage: modal [-v] source.modal\n"); + if(argc < 3 && argv[1][0] == '-' && argv[1][1] == 'v') + return !printf("Modal - Modal Interpreter, 4 Apr 2024.\n"); + if(!(f = fopen(argv[1], "r"))) + return !printf("Invalid Modal file: %s.\n", argv[1]); while(fread(&c, 1, 1, f)) { if(prog_ > bank_a) { if(c == ')' && *(w - 1) == ' ') w--; @@ -231,18 +236,6 @@ load(char *path) } *w++ = 0; fclose(f); - return 1; -} - -int -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 - Modal Interpreter, 4 Apr 2024.\n"); - if(!load(argv[1])) - return !printf("Invalid Modal file: %s.\n", argv[1]); queue = 2; while(rewrite(argv[queue])) ;