diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-02-13 20:00:25 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-02-13 20:00:25 -0800 |
commit | ed86d5e4ab4996b12c3a3f20043ab364d8e00652 (patch) | |
tree | 69117f929e8548e1633988f706b77522fc59e13e | |
parent | 980e782e8973fa48fb3f4533dd731d75eb3d9287 (diff) | |
download | txr-ed86d5e4ab4996b12c3a3f20043ab364d8e00652.tar.gz txr-ed86d5e4ab4996b12c3a3f20043ab364d8e00652.tar.bz2 txr-ed86d5e4ab4996b12c3a3f20043ab364d8e00652.zip |
@(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.
-rw-r--r-- | match.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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); |