[flang-commits] [PATCH] D119015: [flang] Debugging of ACCESS='STREAM' I/O (take 2)

Michael Kruse via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Feb 4 13:18:59 PST 2022


Meinersbur accepted this revision.
Meinersbur added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: flang/runtime/file.cpp:164
+#ifdef _WIN32
+  isWindowsTextFile_ = true;
+#endif
----------------
klausler wrote:
> Meinersbur wrote:
> > I have a concern here: If `fd` is `<=2`, (stdout or stderr), it will be in text mode, which expects a single `\n` for a newline, but with `isWindowsTextFile_ = true`, we will write `\r\n` (which the c-runtime expands to `\r\r\n`).
> When isWindowsTextFile_ is true, only the \n will be written.  See unit.cpp line 557 -- the emission of the \r is controlled by "if (!isWindowsTextFile())" (note the negation).
Correct, I was inverting what the flag means. Hence, effectively with `OpenFile::Open` the file will be opened in binary mode write `\r\n` and with `OpenFile::Predefine` text mode is assumed and only `\n` is written. 

Still means that with `OpenFile::Predefine` `lineEndingBytes` is set to 2 even though it effectively writes `\r\n`, but since stdout/stderr is not generalably seekable I don't think it matters.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119015/new/

https://reviews.llvm.org/D119015



More information about the flang-commits mailing list