tisp

tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | LICENSE

commit 26b5e2d2f527d9246a92a7e5ba2ba8f75429dd9e
parent 2207f9bf946c0b78c372cfa3b9f37488b91a2c26
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Thu, 11 Apr 2019 00:12:02 -0700

Support single hyphen argument to read from stdin

Diffstat:
main.c | 13++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/main.c b/main.c @@ -20,7 +20,7 @@ main(int argc, char *argv[]) if (!strcmp(argv[i], "-v")) { fprintf(stderr, "tisp v%s (c) 2017-2019 Ed van Bruggen\n", VERSION); exit(0); - } else if (argv[i][0] == '-') { + } else if (argv[i][0] == '-' && argv[i][1]) { fputs("usage: tisp [-hv] [FILE ...]\n", stderr); exit(argv[i][1] == 'h' ? 0 : 1); } @@ -31,13 +31,16 @@ main(int argc, char *argv[]) tib_env_io(env); #endif - if (argc == 1) { + if (argc == 1) tisp_print(stdout, tisp_eval(env, tisp_parse_file(env, NULL))); - puts(""); - } for (i = 1; i < argc; i++) - tisp_eval(env, tisp_parse_file(env, argv[i])); + if (argv[i][0] == '-') + tisp_print(stdout, tisp_eval(env, tisp_parse_file(env, NULL))); + else + tisp_print(stdout, tisp_eval(env, tisp_parse_file(env, argv[i]))); + + puts(""); /* tisp_env_free(env); */