[flang-commits] [flang] a68612a - [flang][runtime] Preserve effect of positioning in record in non-advancing output
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Thu Apr 14 15:36:57 PDT 2022
Author: Peter Klausler
Date: 2022-04-14T15:33:15-07:00
New Revision: a68612a964b43d8382a93bb36084b51f2add756f
URL: https://github.com/llvm/llvm-project/commit/a68612a964b43d8382a93bb36084b51f2add756f
DIFF: https://github.com/llvm/llvm-project/commit/a68612a964b43d8382a93bb36084b51f2add756f.diff
LOG: [flang][runtime] Preserve effect of positioning in record in non-advancing output
When formatted non-advancing output ends in a control edit descriptor
like nX or Tn or TRn that effectively extends the record, fill any
gap with explicit blanks at the completion of the WRITE.
Differential Revision: https://reviews.llvm.org/D123716
Added:
Modified:
flang/runtime/io-stmt.cpp
Removed:
################################################################################
diff --git a/flang/runtime/io-stmt.cpp b/flang/runtime/io-stmt.cpp
index fba77171062ef..ac2a7e0a11ed2 100644
--- a/flang/runtime/io-stmt.cpp
+++ b/flang/runtime/io-stmt.cpp
@@ -318,8 +318,13 @@ void ExternalIoStatementState<DIR>::CompleteOperation() {
if (!mutableModes().nonAdvancing || GetIoStat() == IostatEor) {
FinishReadingRecord();
}
- } else {
+ } else { // output
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;
} else {
unit().leftTabLimit.reset();
More information about the flang-commits
mailing list