diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-11-14 15:47:22 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-11-14 15:47:22 -0800 |
commit | 9ae8fe9b48cd8e56816225e467f8882c8313d876 (patch) | |
tree | 24e289d6fc0ccddfbbc67a296142469855f804a4 /match.c | |
parent | a8be305b735b4d5c96cdcc4fbbfd5825a4b2194b (diff) | |
download | txr-9ae8fe9b48cd8e56816225e467f8882c8313d876.tar.gz txr-9ae8fe9b48cd8e56816225e467f8882c8313d876.tar.bz2 txr-9ae8fe9b48cd8e56816225e467f8882c8313d876.zip |
Bugfix: horizontal directives were being treated as vertical,
and the trailing material silently ignored.
For instance @(bind a 1)@(bind b 2). This was going to v_bind,
v_bind does not check for the trailing material and doe snot
call decline_s. The result was that b was not bound.
Correct behavior is to process these binds in match_line.
* match.c (match_line): Check if a directive IS found in the vertical
table, and if so report a different error message. The fallback
case is that there is no such function or directive.
(v_next): Do not check for obsolete syntax any more. This case
will not occur any more due to the following changes.
(match_files): Do not defer opening the file if the data starts
with an incorrectly written next directive.
Do not look up and process a vertical directive or function
call if it is followed by more material in the same line.
Thus vertical directives can longer receive trailing material.
This fixes the bug of horizontal directives being treated as
vertical
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -1052,7 +1052,12 @@ static val match_line(match_line_ctx c) c = nc; continue; } else if (result == decline_k) { - sem_error(elem, lit("unknown directive: ~a"), directive, nao); + if (gethash(v_directive_table, directive)) + sem_error(elem, lit("~a only exists as a vertical directive"), + directive, nao); + else + sem_error(elem, lit("no such function or directive: ~a"), + directive, nao); } else { return result; } @@ -1752,13 +1757,6 @@ static val v_next(match_files_ctx *c) { spec_bind (specline, first_spec, c->spec); - if (rest(first_spec) && rest(specline)) - sem_error(specline, lit("invalid combination of old " - "and new next syntax"), nao); - if (rest(specline)) { - sem_error(specline, lit("obsolete next syntax: trailing material"), nao); - } - if ((c->spec = rest(c->spec)) == nil) return cons(c->bindings, cons(c->data, c->data_lineno)); @@ -2945,10 +2943,10 @@ static val match_files(match_files_ctx c) val source_spec = first(c.files); val name = consp(source_spec) ? cdr(source_spec) : source_spec; fpip_t fp = (errno = 0, complex_open(name, nil, nil)); - val first_spec_item = first(first(c.spec)); + spec_bind (specline, first_spec, c.spec); - if (consp(first_spec_item) && eq(first(first_spec_item), next_s)) { - debuglf(first_spec_item, lit("not opening source ~a " + if (consp(first_spec) && eq(first(first_spec), next_s) && !rest(specline)) { + debuglf(first_spec, lit("not opening source ~a " "since query starts with next directive"), name, nao); } else { val spec = first(c.spec); @@ -2983,7 +2981,7 @@ repeat_spec_same_data: { spec_bind (specline, first_spec, c.spec); - if (consp(first_spec)) { + if (consp(first_spec) && !rest(specline)) { val sym = first(first_spec); val entry = gethash(v_directive_table, sym); |