diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -7,6 +7,7 @@ extern ht_t *WORD_TABLE; extern array_t *STACK; extern char *INBUF; extern parser_t *PARSER; +extern array_t *EVAL_STACK; void usage() { printf("Usage: stem [-hv] [file]\n"); @@ -15,7 +16,7 @@ void usage() { void version() { printf("Author: Preston Pan, MIT License 2023\n"); - printf("stem, version 1.0\n"); + printf("stem, version 1.1\n"); exit(0); } @@ -34,6 +35,11 @@ int main(int argc, char **argv) { } FILE *FP = fopen(argv[1], "rb"); + + if (!FP) { + usage(); + } + ssize_t bytes_read = getdelim(&INBUF, &len, '\0', FP); if (FP != NULL) { fflush(FP); @@ -43,7 +49,7 @@ int main(int argc, char **argv) { PARSER = init_parser(INBUF); STACK = init_array(10); WORD_TABLE = init_ht(500); - + EVAL_STACK = init_array(10); while (1) { v = parser_get_next(PARSER); if (v == NULL) @@ -56,5 +62,6 @@ int main(int argc, char **argv) { array_free(STACK); free(PARSER); free(INBUF); + array_free(EVAL_STACK); return 0; } |