[flang][runtime] Fix nonadvancing output edge case

When nonadvancing output uses T/TL control edit descriptors to reposition
the record, don't reset the position to the furthest point written at
the end of the write.

Differential Revision: https://reviews.llvm.org/D127420
This commit is contained in:
Peter Klausler 2022-06-06 09:09:19 -07:00
parent a2c4d6d332
commit 2496938522

View file

@ -325,10 +325,9 @@ void ExternalIoStatementState<DIR>::CompleteOperation() {
if (mutableModes().nonAdvancing) {
// Make effects of positioning past the last Emit() visible with blanks.
std::int64_t n{unit().positionInRecord - unit().furthestPositionInRecord};
unit().positionInRecord = unit().furthestPositionInRecord;
while (n-- > 0 && unit().Emit(" ", 1, 1, *this)) {
}
unit().leftTabLimit = unit().furthestPositionInRecord;
unit().leftTabLimit = unit().positionInRecord;
} else {
unit().AdvanceRecord(*this);
}