summaryrefslogtreecommitdiffstats
path: root/stream.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-02-17 23:35:57 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-02-17 23:35:57 -0800
commitce6020f1f8248050bb17699cc229205e8cdbdf4e (patch)
tree08dcc1cc2d14f6b13975851b683465907d4a137e /stream.c
parent0c9e4bf7503de3feca97c602689d73b467b33889 (diff)
downloadtxr-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.
Diffstat (limited to 'stream.c')
-rw-r--r--stream.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/stream.c b/stream.c
index 023e8390..64380b87 100644
--- a/stream.c
+++ b/stream.c
@@ -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);
}