[flang-commits] [flang] 885b904 - [flang] Pad output correctly after tabbing with ADVANCE='no' (bug#63111)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Mon Jun 5 15:36:07 PDT 2023


Author: Peter Klausler
Date: 2023-06-05T15:35:58-07:00
New Revision: 885b904a70651207c655a2e5732be63fc500cbd5

URL: https://github.com/llvm/llvm-project/commit/885b904a70651207c655a2e5732be63fc500cbd5
DIFF: https://github.com/llvm/llvm-project/commit/885b904a70651207c655a2e5732be63fc500cbd5.diff

LOG: [flang] Pad output correctly after tabbing with ADVANCE='no' (bug#63111)

Correct the code that implements the production of spaces to bring the
furthestPositionInRecord up to a positionInRecord that was tabbed forward
by a T or TR control edit descriptor.

Fixes bug https://github.com/llvm/llvm-project/issues/63111.

Differential Revision: https://reviews.llvm.org/D152201

Added: 
    

Modified: 
    flang/runtime/io-stmt.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/io-stmt.cpp b/flang/runtime/io-stmt.cpp
index 9467822d8e410..6935f1fdfa22c 100644
--- a/flang/runtime/io-stmt.cpp
+++ b/flang/runtime/io-stmt.cpp
@@ -335,8 +335,8 @@ void ExternalIoStatementState<DIR>::CompleteOperation() {
   } else { // output
     if (mutableModes().nonAdvancing) {
       // Make effects of positioning past the last Emit() visible with blanks.
-      std::int64_t n{unit().positionInRecord - unit().furthestPositionInRecord};
-      while (n-- > 0 && unit().Emit(" ", 1, 1, *this)) {
+      if (unit().positionInRecord > unit().furthestPositionInRecord) {
+        unit().Emit("", 0, 1, *this); // Emit() will pad
       }
       unit().leftTabLimit = unit().positionInRecord;
     } else {


        


More information about the flang-commits mailing list