diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-02-17 23:35:57 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-02-17 23:35:57 -0800 |
commit | ce6020f1f8248050bb17699cc229205e8cdbdf4e (patch) | |
tree | 08dcc1cc2d14f6b13975851b683465907d4a137e | |
parent | 0c9e4bf7503de3feca97c602689d73b467b33889 (diff) | |
download | txr-ce6020f1f8248050bb17699cc229205e8cdbdf4e.tar.gz txr-ce6020f1f8248050bb17699cc229205e8cdbdf4e.tar.bz2 txr-ce6020f1f8248050bb17699cc229205e8cdbdf4e.zip |
Reimplementation of how TXR decides whether to dump bindings
or not. This is now done right inside the standard output stream.
* match.c (output_produced): Variable removed.
(complex_open): Assignment to output_produced removed.
* stream.c (output_produced): New global variable.
(stdio_put_string, stdio_put_char): Set output_produced
to t if the target of the output is stdout.
* stream.h (output_produced): Declared.
* txr.h (output_produced): Declaration removed.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | match.c | 2 | ||||
-rw-r--r-- | stream.c | 6 | ||||
-rw-r--r-- | stream.h | 1 | ||||
-rw-r--r-- | txr.h | 1 |
5 files changed, 23 insertions, 3 deletions
@@ -1,5 +1,21 @@ 2012-02-17 Kaz Kylheku <kaz@kylheku.com> + Reimplementation of how TXR decides whether to dump bindings + or not. This is now done right inside the standard output stream. + + * match.c (output_produced): Variable removed. + (complex_open): Assignment to output_produced removed. + + * stream.c (output_produced): New global variable. + (stdio_put_string, stdio_put_char): Set output_produced + to t if the target of the output is stdout. + + * stream.h (output_produced): Declared. + + * txr.h (output_produced): Declaration removed. + +2012-02-17 Kaz Kylheku <kaz@kylheku.com> + * eval.c (dwim_loc): 2012-02-13 fix didn't do it. Here is a simpler way. We can let nil be treated as a list with a simple goto. This solves all cases. @@ -47,7 +47,6 @@ #include "eval.h" #include "match.h" -int output_produced; int opt_nobindings = 0; int opt_lisp_bindings = 0; int opt_arraydims = 1; @@ -1459,7 +1458,6 @@ static fpip_t complex_open(val name, val output, val append) if (!wcscmp(namestr, L"-")) { ret.close = fpip_fclose; ret.f = output ? stdout : stdin; - output_produced = output ? 1 : 0; } else if (namestr[0] == '!') { ret.close = fpip_pclose; ret.f = w_popen(namestr+1, output ? L"w" : L"r"); @@ -45,6 +45,7 @@ #include "utf8.h" val std_input, std_output, std_error; +val output_produced; struct strm_ops { struct cobj_ops cobj_ops; @@ -124,6 +125,9 @@ static val stdio_put_string(val stream, val str) { struct stdio_handle *h = (struct stdio_handle *) stream->co.handle; + if (h->f == stdout) + output_produced = t; + if (h->f != 0) { const wchar_t *s = c_str(str); while (*s) { @@ -138,6 +142,8 @@ static val stdio_put_string(val stream, val str) static val stdio_put_char(val stream, val ch) { struct stdio_handle *h = (struct stdio_handle *) stream->co.handle; + if (h->f == stdout) + output_produced = t; return h->f != 0 && utf8_encode(c_chr(ch), stdio_put_char_callback, (mem_t *) h->f) ? t : stdio_maybe_write_error(stream); } @@ -25,6 +25,7 @@ */ extern val std_input, std_output, std_error; +extern val output_produced; val make_stdio_stream(FILE *, val descr, val input, val output); val make_pipe_stream(FILE *, val descr, val input, val output); @@ -35,4 +35,3 @@ extern int opt_vg_debug; extern int opt_derivative_regex; extern const wchli_t *version; extern const wchar_t *progname; -extern int output_produced; |