From 85884df6a3564348a684b3b90f76812f81350ec5 Mon Sep 17 00:00:00 2001 From: d_m Date: Thu, 18 Apr 2024 14:07:44 -0400 Subject: [PATCH] Add two new options for modal: -n do not enforce cycle limit -q do not emit rules on STDERR, equivalent to 2>/dev/null Really, -n uses 0xffffffff as the new cycle limit, which is large enough that it's unlikely to be a problem. --- src/modal.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/modal.c b/src/modal.c index 6b1cb0a..9b07201 100644 --- a/src/modal.c +++ b/src/modal.c @@ -217,12 +217,22 @@ main(int argc, char **argv) { FILE *f; char c, *w = bank_a; + int i; 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, 17 Apr 2024.\n"); - if(!(f = fopen(argv[1], "r"))) - return !fprintf(stderr, "Invalid Modal file: %s.\n", argv[1]); + for(i = 1; i < argc && argv[i][0] == '-'; i++) { + if(argv[i][1] == 'v') { + return !printf("Modal Interpreter, 17 Apr 2024.\n"); + } else if(argv[i][1] == 'q') { + fclose(stderr); + } else if(argv[i][1] == 'n') { + cycles = 0xffffffff; + } else { + break; + } + } + if(!(f = fopen(argv[i], "r"))) + return !fprintf(stderr, "Invalid Modal file: %s.\n", argv[i]); while(fread(&c, 1, 1, f)) { c = c <= 0x20 ? 0x20 : c; if(w > bank_a) {