tisp

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

commit 964f267a3082119f5e9f99f731c0fd4634562943
parent 229859f00655a2d6ae49c1c9916eaf7cea80dcf5
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Mon,  5 Oct 2020 00:25:59 -0700

Print errors as comments

Diffstat:
tib/io.c | 3+--
tisp.c | 13+++++--------
tisp.h | 4++--
3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/tib/io.c b/tib/io.c @@ -136,8 +136,7 @@ prim_open(Tsp st, Hash env, Val args) struct Val v; Val ret; if (!(ret = malloc(sizeof(struct Val)))) { - fprintf(stderr, "malloc: "); - perror(NULL); + perror("; malloc"); exit(1); } tsp_arg_min(args, "open", 1); diff --git a/tisp.c b/tisp.c @@ -45,8 +45,7 @@ ecalloc(size_t nmemb, size_t size) { void *p; if (!(p = calloc(nmemb, size))) { - fprintf(stderr, "calloc: "); - perror(NULL); + perror("; calloc"); exit(1); } return p; @@ -57,8 +56,7 @@ emalloc(size_t size) { void *p; if (!(p = malloc(size))) { - fprintf(stderr, "malloc: "); - perror(NULL); + perror("; malloc"); exit(1); } return p; @@ -68,8 +66,7 @@ static void * erealloc(void *p, size_t size) { if (!(p = realloc(p, size))) { - fprintf(stderr, "realloc: "); - perror(NULL); + perror("; realloc"); exit(1); } return p; @@ -812,7 +809,7 @@ tisp_print(FILE *f, Val v) putc(')', f); break; default: - fprintf(stderr, "tisp: could not print value type %s\n", type_str(v->t)); + fprintf(stderr, "; tisp: could not print value type %s\n", type_str(v->t)); } } @@ -1103,7 +1100,7 @@ prim_error(Tsp st, Hash env, Val args) /* TODO have error auto print function name that was pre-defined */ tsp_arg_min(v, "error", 2); tsp_arg_type(car(v), "error", SYMBOL); - fprintf(stderr, "tisp: error: %s: ", car(v)->v.s); + fprintf(stderr, "; tisp: error: %s: ", car(v)->v.s); for (v = cdr(v); !nilp(v); v = cdr(v)) tisp_print(stderr, car(v)); fputc('\n', stderr); diff --git a/tisp.h b/tisp.h @@ -20,11 +20,11 @@ */ #define tsp_warnf(M, ...) do { \ - fprintf(stderr, "tisp: error: " M "\n", ##__VA_ARGS__); \ + fprintf(stderr, "; tisp: error: " M "\n", ##__VA_ARGS__); \ return NULL; \ } while(0) #define tsp_warn(M) do { \ - fprintf(stderr, "tisp: error: " M "\n"); \ + fprintf(stderr, "; tisp: error: " M "\n"); \ return NULL; \ } while(0)