From 176185cd6530bad1f8c3b36fe54bcab7580260ff Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 13 Feb 2020 20:00:25 -0800 Subject: @(line): get meaningful value in horizontal mode. When @(line var) is used in a horizontal match, line is bound to zero. This is because the line number isn't being propagated. * match.c (mf_from_ml): Both the file and line context structurs have a data_lineno, yet this function doesn't propagate it. Instead of using ml_all, whose name tells a subtle lie since it neglects the data_lineno, let's just do the member for member logic here. This function is used in one place, the hv_trampoline. So this fixes the line number for all vertical directives called out of horizontal context. --- match.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/match.c b/match.c index 30f26137..c08464a4 100644 --- a/match.c +++ b/match.c @@ -2305,7 +2305,16 @@ static match_files_ctx mf_file_data(match_files_ctx c, val file, static match_files_ctx mf_from_ml(match_line_ctx ml) { - return mf_all(cons(ml.specline, nil), nil, ml.bindings, nil, ml.file); + match_files_ctx mf; + + mf.spec = cons(ml.specline, nil); + mf.files = nil; + mf.curfile = ml.file; + mf.bindings = ml.bindings; + mf.data = nil; + mf.data_lineno = ml.data_lineno; + + return mf; } static val match_files(match_files_ctx a); -- cgit v1.2.3