diff options
-rw-r--r-- | share/txr/stdlib/getput.tl | 4 | ||||
-rw-r--r-- | stream.c | 18 | ||||
-rw-r--r-- | stream.h | 1 |
3 files changed, 20 insertions, 3 deletions
diff --git a/share/txr/stdlib/getput.tl b/share/txr/stdlib/getput.tl index cb3e621e..53779b6c 100644 --- a/share/txr/stdlib/getput.tl +++ b/share/txr/stdlib/getput.tl @@ -107,9 +107,9 @@ (put-lines lines s))) (defun command-get-buf (cmd) - (with-stream (s (open-command cmd)) + (with-stream (s (open-command cmd "rb")) (sys:get-buf-common s))) (defun command-put-buf (cmd buf) - (with-stream (s (open-command cmd "w")) + (with-stream (s (open-command cmd "wb")) (put-buf buf 0 s))) @@ -1446,6 +1446,22 @@ val normalize_mode(struct stdio_mode *m, val mode_str, struct stdio_mode m_dfl) return format_mode(*m); } +val normalize_mode_no_bin(struct stdio_mode *m, val mode_str, struct stdio_mode m_dfl) +{ +#ifdef __CYGWIN__ + return normalize_mode(m, mode_str, m_dfl); +#else + *m = do_parse_mode(mode_str, m_dfl); + + if (m->malformed) + uw_throwf(file_error_s, lit("invalid file open mode ~a"), mode_str, nao); + + m->binary = 0; + + return format_mode(*m); +#endif +} + val set_mode_props(const struct stdio_mode m, val stream) { if (m.interactive || m.linebuf || m.unbuf || m.buforder != -1) { @@ -3857,7 +3873,7 @@ static void fds_restore(struct save_fds *fds) val open_command(val path, val mode_str) { struct stdio_mode m, m_r = stdio_mode_init_r; - val mode = normalize_mode(&m, mode_str, m_r); + val mode = normalize_mode_no_bin(&m, mode_str, m_r); int input = m.read != 0; struct save_fds sfds; FILE *f = 0; @@ -143,6 +143,7 @@ void stream_mark_op(val stream); void stream_destroy_op(val stream); struct stdio_mode parse_mode(val mode_str, struct stdio_mode m_dfl); val normalize_mode(struct stdio_mode *m, val mode_str, struct stdio_mode m_dfl); +val normalize_mode_no_bin(struct stdio_mode *m, val mode_str, struct stdio_mode m_dfl); val set_mode_props(const struct stdio_mode m, val stream); val generic_get_line(val stream); val errno_to_string(val err); |