diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-07 14:26:56 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-07 14:26:56 -0700 |
commit | 73584c632d9a61c679cea57ba09f5d1843bf1435 (patch) | |
tree | ce00779351ef10f7f77e07fb5f457839a9b3640c /match.c | |
parent | 2d5fcd953cd1632dece9d4202e477a5b2cc95663 (diff) | |
download | txr-73584c632d9a61c679cea57ba09f5d1843bf1435.tar.gz txr-73584c632d9a61c679cea57ba09f5d1843bf1435.tar.bz2 txr-73584c632d9a61c679cea57ba09f5d1843bf1435.zip |
TXR 105 regression: real-time stream not used on tty.
When the -n option was introduced, on Mar 29, 2015, the
change didn't take into account that the hacky complex_open
function takes the C stdin stream directly, and not the
std_input Lisp stream. After that change, only the std_input
is automaticaly marked for real-time input if standard input
is a tty, and not any stream later opened from stdin.
* match.c (enum fpip_close): New enum member, fpip_close_stream.
(struct fpip): New member s, for smuggling through a stream.
(complex_open): If name is "-", then plant std_input or std_output
as the s member of fpip_t, rather than planting stdin or stdout
as the f member.
(complex_open_failed): Check for nil stream also.
(complex_snarf, complex_stream): Handle stream case.
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -1576,17 +1576,18 @@ static val txeval_allow_ub(val spec, val form, val bindings) return do_txeval(spec, form, bindings, t); } -enum fpip_close { fpip_fclose, fpip_pclose, fpip_closedir }; +enum fpip_close { fpip_fclose, fpip_pclose, fpip_closedir, fpip_close_stream }; typedef struct fpip { FILE *f; DIR *d; + val s; enum fpip_close close; } fpip_t; static fpip_t complex_open(val name, val output, val append) { - fpip_t ret = { 0, 0 }; + fpip_t ret = { 0, 0, nil, 0 }; const wchar_t *namestr = c_str(name); cnum len = c_num(length_str(name)); @@ -1594,8 +1595,8 @@ static fpip_t complex_open(val name, val output, val append) return ret; if (!wcscmp(namestr, L"-")) { - ret.close = fpip_fclose; - ret.f = output ? stdout : stdin; + ret.close = fpip_close_stream; + ret.s = output ? std_output : std_input; } else if (namestr[0] == '!') { ret.close = fpip_pclose; ret.f = w_popen(namestr+1, output ? L"w" : L"r"); @@ -1617,7 +1618,7 @@ static fpip_t complex_open(val name, val output, val append) static int complex_open_failed(fpip_t fp) { - return fp.f == 0 && fp.d == 0; + return fp.f == 0 && fp.d == 0 && fp.s == nil; } static val complex_snarf(fpip_t fp, val name) @@ -1629,6 +1630,8 @@ static val complex_snarf(fpip_t fp, val name) return lazy_stream_cons(make_pipe_stream(fp.f, name)); case fpip_closedir: return lazy_stream_cons(make_dir_stream(fp.d)); + case fpip_close_stream: + return lazy_stream_cons(fp.s); } internal_error("bad input source type"); @@ -1643,9 +1646,11 @@ static val complex_stream(fpip_t fp, val name) return make_pipe_stream(fp.f, name); case fpip_closedir: uw_throwf(query_error_s, lit("cannot output to directory: ~a"), name, nao); + case fpip_close_stream: + return fp.s; } - internal_error("bad input source type"); + internal_error("bad output destination type"); } static val robust_length(val obj) |