[llvm] [flang] Tweak integer output under width-free I/G editing (PR #136316)
Peter Klausler via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 18 08:25:12 PDT 2025
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/136316
A recent patch fixed Fujitsu test case 0561_0168 by emitting a leading space for "bare" (no width 'w') I and G output editing of integer values. This fix has broken another Fujitsu test case (0561_0168), since the leading space should not be produced at the first column of the output record. Adjust.
>From f9b0f26ce2f4280a2b54106e1b9c92118de82e9c Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Fri, 18 Apr 2025 08:19:35 -0700
Subject: [PATCH] [flang] Tweak integer output under width-free I/G editing
A recent patch fixed Fujitsu test case 0561_0168 by emitting a
leading space for "bare" (no width 'w') I and G output editing of integer
values. This fix has broken another Fujitsu test case (0561_0168),
since the leading space should not be produced at the first column
of the output record. Adjust.
---
flang-rt/lib/runtime/edit-output.cpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/flang-rt/lib/runtime/edit-output.cpp b/flang-rt/lib/runtime/edit-output.cpp
index 3699213e1f7b7..f90b6fb10963f 100644
--- a/flang-rt/lib/runtime/edit-output.cpp
+++ b/flang-rt/lib/runtime/edit-output.cpp
@@ -182,8 +182,11 @@ bool RT_API_ATTRS EditIntegerOutput(IoStatementState &io, const DataEdit &edit,
leadingSpaces = 1;
} else if (!edit.width) {
// Bare 'I' and 'G' are interpreted with various default widths in the
- // compilers that support them, so there's always some leading space.
- leadingSpaces = std::max(1, leadingSpaces);
+ // compilers that support them, so there's always some leading space
+ // after column 1.
+ if (io.GetConnectionState().positionInRecord > 0) {
+ leadingSpaces = 1;
+ }
}
return EmitRepeated(io, ' ', leadingSpaces) &&
EmitAscii(io, n < 0 ? "-" : "+", signChars) &&
More information about the llvm-commits
mailing list