This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [gfortran,patch] Fix PR libfortran/23262 (on mingw32)
FX Coudert wrote:
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.
I'm not sure how this works either, but from the FAQ link you posted, it
seems clear that only a few people use the mount switch. Plus, I do
think that specifying binary mode in the code does override the user
option (the opposite behaviour doesn't seem to make sense to me).
What wasn't clear from that FAQ link is that, while few people use the
mount switch directly, there's a checkbox in the Cygwin install program
to choose DOS or Unix line endings -- and, unless I'm mistaken, that
checkbox sets up a default for how "mount" is called for the disks when
the computer first boots. So the switch is effectively being used by
everyone who chooses the "DOS" option at install time.
Specifying binary mode appears to override the user option, yes. What
I'm thinking is that, when a gfortran-compiled program is creating a
text file, it may not be appropriate to override the user option --
because, if we do, a Cygwin user may not get the line ending type that
they want.
The reason that I say this will be "interesting" [1] is that I'm pretty
sure your compile-time switch will return different results depending on
the way Cygwin is set on the compiling computer. And thus Paul T.'s
setting on his computer -- rather than anything in the gfortran code or
in the Cygwin code -- will determine the line endings for everyone who
uses his compiled binaries. (In practice, this is probably not a
serious problem, but it's going to be a pain to track down if it becomes
one, unless there's a comment about it somewhere obvious.)
I may have a chance to poke at this a bit and confirm some of this
experimentally in the next couple of weeks; if I do, I'll report back.
- Brooks
[1] In the sense of the "may you live in interesting times" curse....