diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-06-27 22:55:23 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-06-27 22:55:23 -0700 |
commit | 368e8a45196958936b92fa5bd9e22cacdd808fdf (patch) | |
tree | 092dc2a58888841323c1977b3a5fb37752bd075d /parser.c | |
parent | 834e128a6c89dd87008d340f3e0cd60446ca4a0f (diff) | |
download | txr-368e8a45196958936b92fa5bd9e22cacdd808fdf.tar.gz txr-368e8a45196958936b92fa5bd9e22cacdd808fdf.tar.bz2 txr-368e8a45196958936b92fa5bd9e22cacdd808fdf.zip |
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.
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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); |