1 //===-- runtime/connection.cpp ----------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "connection.h" 10 #include "environment.h" 11 #include <algorithm> 12 13 namespace Fortran::runtime::io { 14 RemainingSpaceInRecord() const15std::size_t ConnectionState::RemainingSpaceInRecord() const { 16 auto recl{recordLength.value_or( 17 executionEnvironment.listDirectedOutputLineLengthLimit)}; 18 return positionInRecord >= recl ? 0 : recl - positionInRecord; 19 } 20 IsAtEOF() const21bool ConnectionState::IsAtEOF() const { 22 return endfileRecordNumber && currentRecordNumber >= *endfileRecordNumber; 23 } 24 HandleAbsolutePosition(std::int64_t n)25void ConnectionState::HandleAbsolutePosition(std::int64_t n) { 26 positionInRecord = std::max(n, std::int64_t{0}) + leftTabLimit.value_or(0); 27 } 28 HandleRelativePosition(std::int64_t n)29void ConnectionState::HandleRelativePosition(std::int64_t n) { 30 positionInRecord = std::max(leftTabLimit.value_or(0), positionInRecord + n); 31 } 32 } // namespace Fortran::runtime::io 33