summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-06 10:13:16 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-06 10:13:16 -0700
commit495cc0601c52ffeac902843c0278eb461b201830 (patch)
tree641c7fb917cceecb5ad6c173eca792263a764f4b /parser.c
parentdb8b34eea88e1b634073b120acede13b1e19a8d8 (diff)
downloadtxr-495cc0601c52ffeac902843c0278eb461b201830.tar.gz
txr-495cc0601c52ffeac902843c0278eb461b201830.tar.bz2
txr-495cc0601c52ffeac902843c0278eb461b201830.zip
Erroneous lines must go into history also.
* parser.c (repl): If an exception is thrown, we record a nil value for the line backreference variable, and add the line to history.
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/parser.c b/parser.c
index e7dab1ca..f64c4681 100644
--- a/parser.c
+++ b/parser.c
@@ -498,6 +498,9 @@ val repl(val bindings, val in_stream, val out_stream)
val prompt = format(nil, lit("~a> "), counter, nao);
val prev_counter = counter;
val var_counter = mod(counter, num_fast(100));
+ val var_name = format(nil, lit("*~a"), var_counter, nao);
+ val var_sym = intern(var_name, user_package);
+
char *prompt_u8 = utf8_dup_to(c_str(prompt));
reg_varl(counter_sym, counter);
@@ -524,10 +527,7 @@ val repl(val bindings, val in_stream, val out_stream)
if (value == quit_k) {
done = t;
} else {
- val var_name = format(nil, lit("*~a"), var_counter, nao);
- val sym = intern(var_name, user_package);
-
- reg_varl(sym, value);
+ reg_varl(var_sym, value);
sethash(result_hash, var_counter, value);
prinl(value, out_stream);
lino_hist_add(ls, line_u8);
@@ -535,6 +535,10 @@ val repl(val bindings, val in_stream, val out_stream)
}
uw_catch (exsym, exvals) {
+ reg_varl(var_sym, nil);
+ sethash(result_hash, var_counter, nil);
+ lino_hist_add(ls, line_u8);
+
if (uw_exception_subtype_p(exsym, syntax_error_s)) {
/* suppress syntax error exceptions: uninformative in the repl */
} else if (uw_exception_subtype_p(exsym, error_s)) {