File tree Expand file tree Collapse file tree 6 files changed +20
-4
lines changed
flang/include/flang/Runtime Expand file tree Collapse file tree 6 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,14 @@ struct ConnectionState : public ConnectionAttributes {
6666 RT_API_ATTRS bool NeedAdvance (std::size_t width) const {
6767 return positionInRecord > 0 && width > RemainingSpaceInRecord ();
6868 }
69+ RT_API_ATTRS bool NeedHardAdvance (std::size_t width) const {
70+ auto recl{recordLength};
71+ if (!recl) {
72+ recl = openRecl;
73+ }
74+ return recl && positionInRecord > 0 &&
75+ static_cast <std::int64_t >(positionInRecord + width) > *recl;
76+ }
6977 RT_API_ATTRS void HandleAbsolutePosition (std::int64_t n) {
7078 positionInRecord = (n < 0 ? 0 : n) + leftTabLimit.value_or (0 );
7179 }
Original file line number Diff line number Diff line change @@ -430,6 +430,9 @@ RT_API_ATTRS int FormatControl<CONTEXT>::CueUpNextDataEdit(
430430 if constexpr (std::is_base_of_v<InputStatementState, CONTEXT>) {
431431 context.HandleRelativePosition (chars);
432432 } else {
433+ if (context.GetConnectionState ().NeedHardAdvance (chars)) {
434+ context.AdvanceRecord ();
435+ }
433436 EmitAscii (context, format_ + start, chars);
434437 }
435438 } else if (ch == ' H' ) {
@@ -442,6 +445,9 @@ RT_API_ATTRS int FormatControl<CONTEXT>::CueUpNextDataEdit(
442445 if constexpr (std::is_base_of_v<InputStatementState, CONTEXT>) {
443446 context.HandleRelativePosition (static_cast <std::size_t >(*repeat));
444447 } else {
448+ if (context.GetConnectionState ().NeedHardAdvance (*repeat)) {
449+ context.AdvanceRecord ();
450+ }
445451 EmitAscii (
446452 context, format_ + offset_, static_cast <std::size_t >(*repeat));
447453 }
@@ -487,6 +493,9 @@ RT_API_ATTRS int FormatControl<CONTEXT>::CueUpNextDataEdit(
487493 } else if (ch == ' \t ' || ch == ' \v ' ) {
488494 // Tabs (extension)
489495 // TODO: any other raw characters?
496+ if (context.GetConnectionState ().NeedHardAdvance (1 )) {
497+ context.AdvanceRecord ();
498+ }
490499 EmitAscii (context, format_ + offset_ - 1 , 1 );
491500 } else {
492501 ReportBadFormat (
Original file line number Diff line number Diff line change 1515#ifndef FLANG_RT_RUNTIME_IO_ERROR_H_
1616#define FLANG_RT_RUNTIME_IO_ERROR_H_
1717
18+ #include " iostat.h"
1819#include " memory.h"
1920#include " terminator.h"
20- #include " flang/Runtime/iostat.h"
2121#include < cinttypes>
2222
2323namespace Fortran ::runtime::io {
Original file line number Diff line number Diff line change 1- // ===-- include/flang/Runtime /iostat.h --- -----------------------*- C++ -*-===//
1+ // ===-- include/flang-rt/runtime /iostat.h -----------------------*- C++ -*-===//
22//
33// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44// See https://llvm.org/LICENSE.txt for license information.
Original file line number Diff line number Diff line change 66//
77// ===----------------------------------------------------------------------===//
88
9- #include " flang/Runtime /iostat.h"
9+ #include " flang-rt/runtime /iostat.h"
1010
1111namespace Fortran ::runtime::io {
1212RT_OFFLOAD_API_GROUP_BEGIN
Original file line number Diff line number Diff line change 99#ifndef FORTRAN_RUNTIME_IOSTAT_CONSTS_H_
1010#define FORTRAN_RUNTIME_IOSTAT_CONSTS_H_
1111
12- #include " flang/Common/api-attrs.h"
1312#include " flang/Runtime/magic-numbers.h"
1413
1514namespace Fortran ::runtime::io {
You can’t perform that action at this time.
0 commit comments