diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-09-02 12:29:15 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-09-02 12:29:15 -0400 |
commit | 98bcc06abc0bc38859532052a5782178f4217a19 (patch) | |
tree | d34e58f34e327b11f2a2ef50274242901bd00a9a | |
parent | 8ab5902d2cb66809d478ef795a878a413dea41cc (diff) |
handle newline better, - does subtraction, don't crash on ^D
-rw-r--r-- | bc.y | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -54,6 +54,7 @@ program input_item : semicolon_list NEWLINE { + bc_print(bc_eval($1)); } | function ; @@ -172,7 +173,7 @@ expression $$ = bc_operation(ADD, $1, $3); } | expression SUB_OP expression { - $$ = bc_operation(ADD, $1, $3); + $$ = bc_operation(SUB, $1, $3); } | expression MUL_OP expression { $$ = bc_operation($2, $1, $3); @@ -221,6 +222,10 @@ static char **files; int yywrap(void) { + if (files == NULL || files[optind] == NULL) { + return 1; + } + char *file = files[optind++]; if (yyin != stdin) { |