diff --git a/flang/runtime/buffer.h b/flang/runtime/buffer.h --- a/flang/runtime/buffer.h +++ b/flang/runtime/buffer.h @@ -79,7 +79,7 @@ MakeDataContiguous(handler, bytes); RUNTIME_CHECK(handler, at == fileOffset_ + frame_); } - while (FrameLength() < bytes) { + if (FrameLength() < bytes) { auto next{start_ + length_}; RUNTIME_CHECK(handler, next < size_); auto minBytes{bytes - FrameLength()}; @@ -88,9 +88,6 @@ fileOffset_ + length_, buffer_ + next, minBytes, maxBytes, handler)}; length_ += got; RUNTIME_CHECK(handler, length_ <= size_); - if (got < minBytes) { - break; // error or EOF & program can handle it - } } return FrameLength(); } diff --git a/flang/runtime/io-api.cpp b/flang/runtime/io-api.cpp --- a/flang/runtime/io-api.cpp +++ b/flang/runtime/io-api.cpp @@ -310,7 +310,7 @@ ExternalUnit unitNumber, const char *sourceFile, int sourceLine) { Terminator terminator{sourceFile, sourceLine}; ExternalFileUnit &unit{ExternalFileUnit::LookUpOrCreateAnonymous( - unitNumber, Direction::Output, true /*formatted*/, terminator)}; + unitNumber, Direction::Output, false /*formatted*/, terminator)}; return &unit.BeginIoStatement( unit, ExternalMiscIoStatementState::Endfile, sourceFile, sourceLine); } @@ -319,7 +319,7 @@ ExternalUnit unitNumber, const char *sourceFile, int sourceLine) { Terminator terminator{sourceFile, sourceLine}; ExternalFileUnit &unit{ExternalFileUnit::LookUpOrCreateAnonymous( - unitNumber, Direction::Input, true /*formatted*/, terminator)}; + unitNumber, Direction::Input, false /*formatted*/, terminator)}; return &unit.BeginIoStatement( unit, ExternalMiscIoStatementState::Rewind, sourceFile, sourceLine); }