Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions flang-rt/include/flang-rt/runtime/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ struct ConnectionState : public ConnectionAttributes {
RT_API_ATTRS bool NeedAdvance(std::size_t width) const {
return positionInRecord > 0 && width > RemainingSpaceInRecord();
}
RT_API_ATTRS bool NeedHardAdvance(std::size_t width) const {
auto recl{recordLength};
if (!recl) {
recl = openRecl;
}
return recl && positionInRecord > 0 &&
static_cast<std::int64_t>(positionInRecord + width) > *recl;
}
RT_API_ATTRS void HandleAbsolutePosition(std::int64_t n) {
positionInRecord = (n < 0 ? 0 : n) + leftTabLimit.value_or(0);
}
Expand Down
9 changes: 9 additions & 0 deletions flang-rt/include/flang-rt/runtime/format-implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ RT_API_ATTRS int FormatControl<CONTEXT>::CueUpNextDataEdit(
if constexpr (std::is_base_of_v<InputStatementState, CONTEXT>) {
context.HandleRelativePosition(chars);
} else {
if (context.GetConnectionState().NeedHardAdvance(chars)) {
context.AdvanceRecord();
}
EmitAscii(context, format_ + start, chars);
}
} else if (ch == 'H') {
Expand All @@ -442,6 +445,9 @@ RT_API_ATTRS int FormatControl<CONTEXT>::CueUpNextDataEdit(
if constexpr (std::is_base_of_v<InputStatementState, CONTEXT>) {
context.HandleRelativePosition(static_cast<std::size_t>(*repeat));
} else {
if (context.GetConnectionState().NeedHardAdvance(*repeat)) {
context.AdvanceRecord();
}
EmitAscii(
context, format_ + offset_, static_cast<std::size_t>(*repeat));
}
Expand Down Expand Up @@ -487,6 +493,9 @@ RT_API_ATTRS int FormatControl<CONTEXT>::CueUpNextDataEdit(
} else if (ch == '\t' || ch == '\v') {
// Tabs (extension)
// TODO: any other raw characters?
if (context.GetConnectionState().NeedHardAdvance(1)) {
context.AdvanceRecord();
}
EmitAscii(context, format_ + offset_ - 1, 1);
} else {
ReportBadFormat(
Expand Down
2 changes: 1 addition & 1 deletion flang-rt/include/flang-rt/runtime/io-error.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#ifndef FLANG_RT_RUNTIME_IO_ERROR_H_
#define FLANG_RT_RUNTIME_IO_ERROR_H_

#include "iostat.h"
#include "memory.h"
#include "terminator.h"
#include "flang/Runtime/iostat.h"
#include <cinttypes>

namespace Fortran::runtime::io {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- include/flang/Runtime/iostat.h --------------------------*- C++ -*-===//
//===-- include/flang-rt/runtime/iostat.h -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion flang-rt/lib/runtime/iostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

#include "flang/Runtime/iostat.h"
#include "flang-rt/runtime/iostat.h"

namespace Fortran::runtime::io {
RT_OFFLOAD_API_GROUP_BEGIN
Expand Down
1 change: 0 additions & 1 deletion flang/include/flang/Runtime/iostat-consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifndef FORTRAN_RUNTIME_IOSTAT_CONSTS_H_
#define FORTRAN_RUNTIME_IOSTAT_CONSTS_H_

#include "flang/Common/api-attrs.h"
#include "flang/Runtime/magic-numbers.h"

namespace Fortran::runtime::io {
Expand Down
Loading