From 368e8a45196958936b92fa5bd9e22cacdd808fdf Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 27 Jun 2016 22:55:23 -0700 Subject: Handle nonexistent HOME env var in repl. * parser.c (repl): If home is nil, don't try to extract UTF-8 string from histfile, which is also nil. Use the UTF-8 pointer for subsequent checks, since it is that pointer's use which is subject to those checks. --- parser.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'parser.c') diff --git a/parser.c b/parser.c index 3e57113c..281dd81c 100644 --- a/parser.c +++ b/parser.c @@ -663,7 +663,7 @@ val repl(val bindings, val in_stream, val out_stream) val counter = one; val home = getenv_wrap(lit("HOME")); val histfile = if2(home, format(nil, lit("~a/.txr_history"), home, nao)); - char *histfile_u8 = utf8_dup_to(c_str(histfile)); + char *histfile_u8 = if3(home, utf8_dup_to(c_str(histfile)), NULL); val rcfile = if2(home, format(nil, lit("~a/.txr_profile"), home, nao)); val old_sig_handler = set_sig_handler(num(SIGINT), func_n2(repl_intr)); val hist_len_var = lookup_global_var(listener_hist_len_s); @@ -681,7 +681,7 @@ val repl(val bindings, val in_stream, val out_stream) lino_hist_set_max_len(ls, c_num(cdr(hist_len_var))); - if (histfile) + if (histfile_u8) lino_hist_load(ls, histfile_u8); while (!done) { @@ -784,7 +784,7 @@ val repl(val bindings, val in_stream, val out_stream) set_sig_handler(num(SIGINT), old_sig_handler); - if (histfile) + if (histfile_u8) lino_hist_save(ls, histfile_u8); free(histfile_u8); -- cgit v1.2.3