From d11481b8cd38d63d21d50fb1b7fc9c49a7f21c0d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 23 Sep 2011 14:49:00 -0700 Subject: * match.c, parser.y: Support for old output syntax removed. Leading :nothrow with trailing material is an error now. * txr.1: Updated. Made note of errors in pipes being asynchronous. --- ChangeLog | 7 +++++++ match.c | 32 ++++++++++++++------------------ parser.y | 5 +++-- txr.1 | 18 ++++++------------ 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index f625f46b..facb6c99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-09-23 Kaz Kylheku + + * match.c, parser.y: Support for old output syntax removed. + Leading :nothrow with trailing material is an error now. + + * txr.1: Updated. Made note of errors in pipes being asynchronous. + 2011-09-23 Kaz Kylheku * tests/002/query-1.txr: Old next syntax rewritten to new. diff --git a/match.c b/match.c index dd30f72f..f5a35870 100644 --- a/match.c +++ b/match.c @@ -1408,29 +1408,25 @@ repeat_spec_same_data: goto repeat_spec_same_data; } else if (sym == output_s) { val specs = second(first_spec); - val old_style_dest = third(first_spec); - val new_style_dest = fourth(first_spec); - val nt = nil; + val dest_spec = third(first_spec); + val nothrow = nil; val dest; fpip_t fp; - if (old_style_dest) { - dest = cat_str(subst_vars(old_style_dest, bindings), nil); + if (eq(first(dest_spec), nothrow_k)) { + if (rest(dest_spec)) + sem_error(spec_linenum, lit("material after :nothrow in output"), nao); + dest = string(L"-"); } else { - if (eq(first(new_style_dest), nothrow_k)) - push(nil, &new_style_dest); + val form = first(dest_spec); + val val = eval_form(form, bindings); - { - val form = first(new_style_dest); - val val = eval_form(form, bindings); - - if (!val) - sem_error(spec_linenum, - lit("output: unbound variable in form ~a"), form, nao); + if (!val) + sem_error(spec_linenum, + lit("output: unbound variable in form ~a"), form, nao); - nt = eq(second(new_style_dest), nothrow_k); - dest = or2(cdr(val), string(L"-")); - } + nothrow = eq(second(dest_spec), nothrow_k); + dest = or2(cdr(val), string(L"-")); } fp = (errno = 0, complex_open(dest, t)); @@ -1438,7 +1434,7 @@ repeat_spec_same_data: debugf(lit("opening data sink ~a"), dest, nao); if (complex_open_failed(fp)) { - if (nt) { + if (nothrow) { debugf(lit("could not open ~a: " "treating as failed match due to nothrow"), dest, nao); return nil; diff --git a/parser.y b/parser.y index 98d299f3..7fb277af 100644 --- a/parser.y +++ b/parser.y @@ -267,13 +267,14 @@ catch_clauses_opt : CATCH ')' newl output_clause : OUTPUT ')' o_elems '\n' out_clauses - END newl { $$ = list(output_s, $5, $3, nao); } + END newl { $$ = nil; + yyerror("obsolete output syntax: trailing material"); } | OUTPUT ')' newl out_clauses END newl { $$ = list(output_s, $4, nao); } | OUTPUT exprs ')' newl out_clauses - END newl { $$ = list(output_s, $5, nil, $2, nao); } + END newl { $$ = list(output_s, $5, $2, nao); } | OUTPUT exprs ')' o_elems '\n' out_clauses END newl { $$ = nil; diff --git a/txr.1 b/txr.1 index 78b109cd..82d128e3 100644 --- a/txr.1 +++ b/txr.1 @@ -2280,27 +2280,21 @@ The syntax of the @(output) directive is: . @(end) -An obsolescent syntax is also supported: - - @(output)...optional destination... - . - . one or more output directives or lines - . - @(end) - The optional destination is a filename, the special name, - which redirects to standard output, or a shell command preceded by the ! symbol. In the first form, the destination may be specified as a variable which holds text, a string literal or a quasiliteral -In the second obsolescent form, the material to the right of @(output) -is query text which may contain variables. - -The new syntax throws an exception if the output destination +The syntax throws an exception if the output destination cannot be opened, unless the :nothrow keyword is present, in which case the situation is treated as a match failure. The old syntax throws an exception. +Note that since command pipes are processes that report errors +asynchronously, a failing command will not throw an immediate exception that +can be suppressed with :nothrow. This is for synchronous errors, like +trying to open a destination file, but not having permissions, etc. + .SS Output Text Text in an output clause is not matched against anything, but is output -- cgit v1.2.3