This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran,patch] Fix PR libfortran/23262 (on mingw32)


FX Coudert wrote:
Attached patch fixes PR libfortran/23262 (and 23264): we need to switch I/O to binary-mode (instead of text-mode) on mingw32. With text-mode, the I/O library makes magical things with newlines, but it makes it impossible to use lseek and ftruncate. So, we need not to use them, and take care ourselves of outputting the right newline characters.

The patch adds a configure test (compile-test, with target-based guess for cross-compilers) to know whether target is a system with CRLF line terminator (and has O_BINARY open() flag available). This case, AFAIK, does arise only for mingw32.

This patch is likely to do interesting things on Cygwin, which has an option (at install time) to switch between DOS and Unix newlines.


According to my cursory understanding of how this works [1], if DOS mode is selected at install (or, more particularly, when the disk is mounted; it's a mount option), Cygwin uses the text-mode or binary-mode switch to decide whether or not to translate the line endings from DOS-mode (on disk) to Unix-mode (as seen by the program).

My guess is that the result of this patch will be to "freeze" the newline handling on Cygwin to the setting that was active at compile time, rather than allowing it to adapt to the current system settings. For distributed binaries, this means the end user's settings would get completely ignored.

Unfortunately, I don't understand enough about this to say anything with specificity, or have any suggestions for fixing it....

- Brooks


[1] Based on this FAQ answer: http://cygwin.com/faq/faq.api.html#faq.api.cr-lf


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]