summaryrefslogtreecommitdiffstats
path: root/stream.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-06-28 22:56:36 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-06-28 22:56:36 -0700
commitd41d8ed8ed5d73aa0abcd4f6e562d06df33dc3e9 (patch)
tree23cf5d678bd9d148ac8757bd203548f6dadddfc7 /stream.c
parent8e02b2cad2fe00aadd8b20e0977588f1fe1c00f3 (diff)
downloadtxr-d41d8ed8ed5d73aa0abcd4f6e562d06df33dc3e9.tar.gz
txr-d41d8ed8ed5d73aa0abcd4f6e562d06df33dc3e9.tar.bz2
txr-d41d8ed8ed5d73aa0abcd4f6e562d06df33dc3e9.zip
We would like the Windows port of TXR to open files in text
mode by default, such that "\r\n" is converted to "\n". Cygwin's stdio streams aren't doing this. This is fine when working in the Cygwin world, but not fine when we are making a "native" Windows program with the help of the Cygwin DLL. However, Cygwin supports the "t" mode letter in fopen, and that forces a text mode which does the conversion. * stream.c (format_mode): On Cygwin, if the mode isn't binary, add the 't' letter to the normalized mode string, unless compatibility <= 143 is requested. * txr.1: Added compat notes.
Diffstat (limited to 'stream.c')
-rw-r--r--stream.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/stream.c b/stream.c
index 535396ea..5df416f8 100644
--- a/stream.c
+++ b/stream.c
@@ -1314,6 +1314,11 @@ static val format_mode(const struct stdio_mode m)
if (m.binary)
*ptr++ = 'b';
+#ifdef __CYGWIN__
+ if (!m.binary && (!opt_compat || opt_compat > 143))
+ *ptr++ = 't';
+#endif
+
*ptr = 0;
return string(buf);
}