summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-01-13 20:37:46 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-01-13 20:37:46 -0800
commitf711590ceae82493b8a87eba0bfaaed30af06c34 (patch)
tree5288cc5c75489c31d1542cc4904ae1881e8cb039 /parser.c
parentd1d529634ca0efabd8def4d1e4d103facb9f9380 (diff)
downloadtxr-f711590ceae82493b8a87eba0bfaaed30af06c34.tar.gz
txr-f711590ceae82493b8a87eba0bfaaed30af06c34.tar.bz2
txr-f711590ceae82493b8a87eba0bfaaed30af06c34.zip
Pastes produced using :read are now numbered.
* parser.c (read_eval_read_last): New argument: counter. Incorporate counter into name of stream. (repl): Pass prev_counter into read_eval_read_last so the paste inherits the line number of the :read command.
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/parser.c b/parser.c
index fe5527b2..040dd54b 100644
--- a/parser.c
+++ b/parser.c
@@ -615,13 +615,14 @@ static val repl_intr(val signo, val async_p)
uw_throw(intr_s, lit("intr"));
}
-static val read_eval_ret_last(val env, val in_stream, val out_stream)
+static val read_eval_ret_last(val env, val counter,
+ val in_stream, val out_stream)
{
val lineno = one;
+ val name = format(nil, lit("paste-~a"), counter, nao);
for (;; lineno = succ(lineno)) {
- val form = lisp_parse(in_stream, out_stream, colon_k,
- lit("paste"), lineno);
+ val form = lisp_parse(in_stream, out_stream, colon_k, name, lineno);
val parser = get_parser(in_stream);
val value = eval_intrinsic(form, nil);
@@ -735,7 +736,8 @@ val repl(val bindings, val in_stream, val out_stream)
} else {
val value = if3(form != read_k,
eval_intrinsic(form, repl_env),
- read_eval_ret_last(repl_env, in_stream, out_stream));
+ read_eval_ret_last(repl_env, prev_counter,
+ in_stream, out_stream));
reg_varl(var_sym, value);
sethash(result_hash, var_counter, value);
prinl(value, out_stream);