From 93540455669ab9ad55bd7e24a42a305194a109af Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Mon, 20 May 2024 16:16:07 -0700 Subject: [NFC][flang][runtime] Avoid recursion in EditCharacterOutput and EditLogicalOutput. (#92806) --- flang/runtime/edit-output.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'flang') diff --git a/flang/runtime/edit-output.cpp b/flang/runtime/edit-output.cpp index 13ab91f..6b24c56 100644 --- a/flang/runtime/edit-output.cpp +++ b/flang/runtime/edit-output.cpp @@ -832,8 +832,11 @@ RT_API_ATTRS bool EditLogicalOutput( reinterpret_cast(&truth), sizeof truth); case 'A': { // legacy extension int truthBits{truth}; - return EditCharacterOutput( - io, edit, reinterpret_cast(&truthBits), sizeof truthBits); + int len{sizeof truthBits}; + int width{edit.width.value_or(len)}; + return EmitRepeated(io, ' ', std::max(0, width - len)) && + EmitEncoded( + io, reinterpret_cast(&truthBits), std::min(width, len)); } default: io.GetIoErrorHandler().SignalError(IostatErrorInFormat, -- cgit v1.1