tisp

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

commit 16bcc405d01aed1fabc48bcdbd8ef2a544985d66
parent fc2f69af5a00b76b45b0c54051b8c061f08cfa42
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Mon, 18 Nov 2019 14:32:24 -0800

Check if tisp_read is NULL

Diffstat:
main.c | 4+++-
tibs/io.c | 2+-
tisp.c | 5+++--
3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/main.c b/main.c @@ -18,6 +18,7 @@ main(int argc, char *argv[]) { int i; struct Str str = { NULL }; + Val v; Env env = tisp_env_init(64); #ifndef TIB_DYNAMIC @@ -39,7 +40,8 @@ main(int argc, char *argv[]) fputs("tisp: expected command after -c\n", stderr); exit(2); } - tisp_print(stdout, tisp_eval(env, tisp_read(env, &str))); + if ((v = tisp_read(env, &str))) + tisp_print(stdout, tisp_eval(env, v)); } else if (argv[i][1] == 'v') { /* version and copyright info */ fprintf(stderr, "tisp v%s (c) 2017-2019 Ed van Bruggen\n", VERSION); exit(0); diff --git a/tibs/io.c b/tibs/io.c @@ -91,7 +91,7 @@ prim_parse(Env env, Val args) tsp_arg_type(v, "parse", STRING); str.d = v->v.s; v = tisp_read(env, &str); - return v; + return v ? v : env->none; } void diff --git a/tisp.c b/tisp.c @@ -1113,10 +1113,11 @@ void tisp_env_lib(Env env, char* lib) { struct Str s; + Val v; if (!(s.d = strndup(lib, strlen(lib)))) return; - /* TODO check if tisp_read is NULL */ - tisp_eval_list(env, tisp_read(env, &s)); + if ((v = tisp_read(env, &s))) + tisp_eval_list(env, v); } void