I know that. But in nano's source code it isn't the case. Nano's author did use "wb" in fdopen() but dropped the O_BINARY flag in open(). As a result, when you use win mingw nano (you can get it from here http://code.google.com/p/mingw-and-ndk/downloads/detail?name=win-mingw-nano.7z) and explicitly assign a DOS format, you get two CRs and 1 LF for each line break. (That version of nano was compiled with mingw. I just compiled nano-2.3.2 today and got the same problem, and I have fixed that.) I didn't find any documentations mentioning that which mode (text or binary) shall be used if fdopen() mode conficts with open() mode. And that's my question.
2014-01-09 lh_mouse ------------------------------------------------------------------------------------ 发件人:Hannes Domani <ssb...@yahoo.de> 发送时间:2014-01-09 19:19 主题:Re: [Mingw-w64-public] Text/binary mode bug in fdopen()?? 收件人:"mingw-w64-public@lists.sourceforge.net"<mingw-w64-public@lists.sourceforge.net> 抄送: > In short words, on mingw-gcc 4.9.0 the following code produces a text file with contents "a\r\nb\r\n", while > replacing open() + fdopen() with a single fopen() produces "a\nb\n". Any > ideas? You have to add O_BINARY to open(). Regards Domani Hannes ------------------------------------------------------------------------------ CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public ------------------------------------------------------------------------------ CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public