summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--ChangeLog16
-rw-r--r--match.c2
-rw-r--r--stream.c6
-rw-r--r--stream.h1
-rw-r--r--txr.h1
5 files changed, 23 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index eda56c02..7a63e83d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/match.c b/match.c
index b5e489dd..d921757e 100644
--- a/match.c
+++ b/match.c
@@ -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");
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);
}
diff --git a/stream.h b/stream.h
index 14208f7a..4cb7f923 100644
--- a/stream.h
+++ b/stream.h
@@ -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);
diff --git a/txr.h b/txr.h
index 23afc823..293840a1 100644
--- a/txr.h
+++ b/txr.h
@@ -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;