diff --git a/src/lake.c b/src/lake.c index a9378fa..29ec540 100644 --- a/src/lake.c +++ b/src/lake.c @@ -68,7 +68,7 @@ char *lake_repr(LakeVal *expr) break; default: - printf("error: unrecognized value, type %d, size %zu bytes", expr->type, expr->size); + fprintf(stderr, "error: unrecognized value, type %d, size %zu bytes", expr->type, expr->size); s = g_strdup(""); } diff --git a/src/parse.c b/src/parse.c index 5776b9a..31f22c0 100644 --- a/src/parse.c +++ b/src/parse.c @@ -43,7 +43,7 @@ static void warn_trailing(Ctx *ctx) /* don't warn about trailing comments */ if (ctx->i < ctx->n && peek(ctx) != ';') { char *trailing = ctx->s + ctx->i; - printf("warning: ignoring %d trailing chars: %s\n", (int)(ctx->n - ctx->i), trailing); + fprintf(stderr, "warning: ignoring %d trailing chars: %s\n", (int)(ctx->n - ctx->i), trailing); } } diff --git a/src/repl.c b/src/repl.c index b9ab99a..c8bfb60 100644 --- a/src/repl.c +++ b/src/repl.c @@ -41,7 +41,7 @@ static LakeVal *prompt_read(LakeCtx *ctx, Env *env, char *prompt) char buf[n]; if (!fgets(buf, n, stdin)) { if (ferror(stdin)) { - printf("error: cannot read from stdin"); + fprintf(stderr, "error: cannot read from stdin"); } if (feof(stdin)) { return VAL(EOF); @@ -50,19 +50,19 @@ static LakeVal *prompt_read(LakeCtx *ctx, Env *env, char *prompt) } /* trim the newline if any */ buf[strcspn(buf, "\n")] = '\0'; - + /* parse list expressions */ if (first_char(buf) == '(') { return parse_expr(ctx, buf, strlen(buf)); } - + /* try to parse a naked call without parens (makes the repl more palatable) */ LakeList *list = parse_naked_list(ctx, buf, strlen(buf)); if (!list || LIST_N(list) == 0) return NULL; LakeVal *result; - + /* naked call */ LakeVal *head; if (is_special_form(ctx, list) || @@ -75,7 +75,7 @@ static LakeVal *prompt_read(LakeCtx *ctx, Env *env, char *prompt) else { result = LIST_VAL(list, 0); } - + return result; }