From b7f76edb07c6395e8ae6f3a336292666ea1c8eda Mon Sep 17 00:00:00 2001 From: Kaz Kylheku <kaz@kylheku.com> Date: Thu, 5 Aug 2021 06:52:25 -0700 Subject: txr: @(eof) takes argument for binding termination status. We extend the matching context structures to keep track of the underlying stream from which lines are being taken via the lazy list. Then the implementation of the @(eof) directive, when it hits the eof condition, can use this stream to gain access to the termination status. * match.c (match_line_ctx, match_files_ctx): New member, stream. (ml_all): Take stream argument and initialize new member. (h_call, do_match_line): Pass stream argument to h_call. (mf_all, mf_file_data): Take stream argument and initialize new member. (mf_from_ml): Propagate stream from line context to file context. (freeform_prepare, v_next_impl, match_filter, match_fun, extract): Pass stream argument where now needed. (v_eof): Implement termination status binding via the stream stored in the context. (open_data_source): Store stream in match files context. * tests/010/eof-status.txr: New file. * tests/010/eof-status.expected: New file. * Makefile (tst/tests/010/eof-status.ok): -B option for new test. * txr.1: Documented eof directive, argument and all. * stdlib/doc-syms.tl: Updated. --- Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index cac9b3c0..b3084a23 100644 --- a/Makefile +++ b/Makefile @@ -418,6 +418,7 @@ tst/tests/009/json.ok: TXR_ARGS := $(addprefix tests/009/,webapp.json pass1.json tst/tests/010/align-columns.ok: TXR_ARGS := tests/010/align-columns.dat tst/tests/010/block.ok: TXR_OPTS := -B tst/tests/010/reghash.ok: TXR_OPTS := -B +tst/tests/010/eof-status.ok: TXR_OPTS := -B tst/tests/013/maze.ok: TXR_ARGS := 20 20 tst/tests/018/chmod.ok: TXR_ARGS := tst/tests/018/tempfile -- cgit v1.2.3