[flang-commits] [flang] 874a3ba - [flang][runtime] Don't buffer unit 0 (#122614)

via flang-commits flang-commits at lists.llvm.org
Tue Jan 14 12:58:46 PST 2025


Author: Peter Klausler
Date: 2025-01-14T12:58:42-08:00
New Revision: 874a3ba868e3738d6ee21bfe032c89c6c8be3969

URL: https://github.com/llvm/llvm-project/commit/874a3ba868e3738d6ee21bfe032c89c6c8be3969
DIFF: https://github.com/llvm/llvm-project/commit/874a3ba868e3738d6ee21bfe032c89c6c8be3969.diff

LOG: [flang][runtime] Don't buffer unit 0 (#122614)

Always assume that predefined unit 0 is a terminal, so that output to it
is never buffered.

Added: 
    

Modified: 
    flang/runtime/file.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/file.cpp b/flang/runtime/file.cpp
index ec772903242b80..9e077b8cea44bb 100644
--- a/flang/runtime/file.cpp
+++ b/flang/runtime/file.cpp
@@ -134,7 +134,7 @@ void OpenFile::Open(OpenStatus status, Fortran::common::optional<Action> action,
   if (fd_ >= 0 && position == Position::Append && !RawSeekToEnd()) {
     handler.SignalError(IostatOpenBadAppend);
   }
-  isTerminal_ = fd_ >= 0 && IsATerminal(fd_) == 1;
+  isTerminal_ = fd_ >= 0 && IsATerminal(fd_);
   mayRead_ = *action != Action::Write;
   mayWrite_ = *action != Action::Read;
   if (status == OpenStatus::Old || status == OpenStatus::Unknown) {
@@ -163,7 +163,7 @@ void OpenFile::Predefine(int fd) {
   knownSize_.reset();
   nextId_ = 0;
   pending_.reset();
-  isTerminal_ = IsATerminal(fd_) == 1;
+  isTerminal_ = fd == 2 || IsATerminal(fd_);
   mayRead_ = fd == 0;
   mayWrite_ = fd != 0;
   mayPosition_ = false;


        


More information about the flang-commits mailing list