From 2bf9fd3d12fd285d1f09d92f885ca4924bf224c7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 28 Jun 2016 22:56:36 -0700 Subject: 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. --- stream.c | 5 +++++ txr.1 | 4 ++++ 2 files changed, 9 insertions(+) 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); } diff --git a/txr.1 b/txr.1 index 2a3d5b03..b5d7f0be 100644 --- a/txr.1 +++ b/txr.1 @@ -43537,6 +43537,10 @@ mark, if the symbol was previously defined as a special variable. Also, until version 143 many more places in the \*(TX pattern language used bind expressions rather than Lisp expressions. The compatibility option restores these behaviors. +Lastly, starting in version 144, on the Cygwin platform, streams +opened in text mode perform conversion between the CR-LF line +endings in the external representations and newline characters +in the stream. .IP 142 Until version 142, the \*(TX pattern language supported a prefix convention on data sources. Data sources beginning with the character -- cgit v1.2.3