summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-04-15 20:27:59 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-04-15 20:27:59 -0700
commit6912b6a6a5faf876adf04437c6bdbed5470ebc12 (patch)
treea548fe81e59ff7512a81d3fbe2ef7aa3623999a3
parenta4dabadfdb2c090cf985bae80c72f2c6477de046 (diff)
downloadtxr-6912b6a6a5faf876adf04437c6bdbed5470ebc12.tar.gz
txr-6912b6a6a5faf876adf04437c6bdbed5470ebc12.tar.bz2
txr-6912b6a6a5faf876adf04437c6bdbed5470ebc12.zip
Fix internal error: bug in data stream opening logic.
Test case: txr -c '@(bind x 1)A' name The problem here is that the specline has multiple elements, so when processing the bind, rest(specline) isn't nil. This means that control passes through to horizontal matching logic. No data source is open yet; just before that logic executes, open_data_source is called. However, open_data_source refuses because @(bind) is a directive that doesn't require data. So we end up in the internal error case, because we a data source, and no attempt was made to open one. The fix is for open_data_source to also check rest(specline). It cannot skip opening the data source just because the first_spec is a non-matching directive, according to the non_matching_directive_table. This criterion should only apply if it is the *only* directive, however. A spec line with multiple items must match a line of data; that's how the TXR language works. * match.c (open_data_source): Add a condition for classifying the directive as non-matching: it must be the only directive in the line (rest(specline) must be nil).
-rw-r--r--match.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/match.c b/match.c
index 857e1df6..6480bd68 100644
--- a/match.c
+++ b/match.c
@@ -3902,8 +3902,9 @@ static void open_data_source(match_files_ctx *c)
if (stringp(name)) {
spec_bind (specline, first_spec, c->spec);
- if (consp(first_spec) && (gethash(non_matching_directive_table,
- first(first_spec))))
+ if (consp(first_spec) &&
+ (gethash(non_matching_directive_table, first(first_spec))) &&
+ !rest(specline))
{
debuglf(first_spec, lit("not opening source ~a "
"since query starts with non-matching "