From d70e7b808cb61af565fe0fbf0e5211e8a3c5352b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 10 Nov 2011 22:05:07 -0800 Subject: Bug #34799: errors in horizontal functions reported to caller line number. * match.c (ml_bindings_specline): Extended with extra argument (h_coll): Pass nil for new argument of ml_bindings_specline. (h_fun): Extract line number from stored function. Pass line number to ml_bindings_specline. (h_define, v_define): Store function as a cons cell containing the line number and body. --- ChangeLog | 12 ++++++++++++ match.c | 15 +++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 18a3e863..6082d9bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2011-11-10 Kaz Kylheku + + Bug #34799: errors in horizontal functions + reported to caller line number. + + * match.c (ml_bindings_specline): Extended with extra argument + (h_coll): Pass nil for new argument of ml_bindings_specline. + (h_fun): Extract line number from stored function. + Pass line number to ml_bindings_specline. + (h_define, v_define): Store function as a cons cell containing + the line number and body. + 2011-11-10 Kaz Kylheku * txr.1: Document -l/--lisp-bindings. diff --git a/match.c b/match.c index 85558f1c..d4bd86de 100644 --- a/match.c +++ b/match.c @@ -376,11 +376,13 @@ static match_line_ctx ml_specline(match_line_ctx c, val specline) return nc; } -static match_line_ctx ml_bindings_specline(match_line_ctx c, val bindings, val specline) +static match_line_ctx ml_bindings_specline(match_line_ctx c, val bindings, val specline, val lineno) { match_line_ctx nc = c; nc.bindings = bindings; nc.specline = specline; + if (lineno) + nc.spec_lineno = lineno; return nc; } @@ -697,7 +699,7 @@ static val h_coll(match_line_ctx c, match_line_ctx *cout) if (until_last_specline) { cons_bind (sym, spec, until_last_specline); cons_bind (until_last_bindings, until_pos, - match_line(ml_bindings_specline(c, new_bindings, spec))); + match_line(ml_bindings_specline(c, new_bindings, spec, nil))); if (until_pos) { LOG_MATCH("until/last", until_pos); @@ -911,7 +913,8 @@ static val h_fun(match_line_ctx c, match_line_ctx *cout) val args = rest(elem); val params = car(func); val ub_p_a_pairs = nil; - val body = cdr(func); + val body = cdr(cdr(func)); + val lineno = car(cdr(func)); val piter, aiter; val bindings_cp = copy_alist(c.bindings); @@ -945,7 +948,7 @@ static val h_fun(match_line_ctx c, match_line_ctx *cout) uw_block_begin(nil, result); uw_env_begin; - result = match_line(ml_bindings_specline(c, bindings_cp, body)); + result = match_line(ml_bindings_specline(c, bindings_cp, body, lineno)); uw_env_end; uw_block_end; @@ -2722,7 +2725,7 @@ static val h_define(match_line_ctx c, match_line_ctx *cout) val name = first(args); val params = second(args); val existing = uw_get_func(name); - uw_set_func(name, cons(car(existing), cons(params, body))); + uw_set_func(name, cons(car(existing), cons(params, cons(c.spec_lineno, body)))); *cout = c; return next_spec_k; } @@ -2742,7 +2745,7 @@ static val v_define(match_files_ctx *c) val name = first(args); val params = second(args); val existing = uw_get_func(name); - uw_set_func(name, cons(car(existing), cons(params, body))); + uw_set_func(name, cons(car(existing), cons(params, cons(spec_linenum, body)))); return next_spec_k; } else { val args = second(first_spec); -- cgit v1.2.3