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

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Jun 5 15:02:01 PDT 2023


klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added subscribers: sunshaoce, jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

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.


https://reviews.llvm.org/D152201

Files:
  flang/runtime/io-stmt.cpp


Index: flang/runtime/io-stmt.cpp
===================================================================
--- flang/runtime/io-stmt.cpp
+++ flang/runtime/io-stmt.cpp
@@ -335,8 +335,8 @@
   } 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 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152201.528589.patch
Type: text/x-patch
Size: 670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230605/b327c64b/attachment-0001.bin>


More information about the flang-commits mailing list