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
1 change: 0 additions & 1 deletion flang-rt/include/flang-rt/runtime/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ struct ConnectionState : public ConnectionAttributes {
auto least{leftTabLimit.value_or(0)};
auto newPos{positionInRecord + n};
positionInRecord = newPos < least ? least : newPos;
;
}

RT_API_ATTRS void BeginRecord() {
Expand Down
44 changes: 32 additions & 12 deletions flang-rt/include/flang-rt/runtime/io-stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ class IoStatementState {
}
connection_.HandleRelativePosition(bytes);
}
RT_API_ATTRS bool SkipBlanks() {
if (at_) {
const char *start{at_};
while (at_ < limit_ && (*at_ == ' ' || *at_ == '\t' || *at_ == '\n')) {
++at_;
}
connection_.HandleRelativePosition(at_ - start);
return true;
} else {
return false;
}
}

// Could there be a list-directed repetition count here?
RT_API_ATTRS bool MightBeRepetitionCount() const {
Expand Down Expand Up @@ -289,24 +301,32 @@ class IoStatementState {
// Skips spaces, advances records, and ignores NAMELIST comments
RT_API_ATTRS common::optional<char32_t> GetNextNonBlank(
std::size_t &byteCount, FastAsciiField *fastField = nullptr) {
auto ch{GetCurrentChar(byteCount, fastField)};
bool inNamelist{mutableModes().inNamelist};
if (fastField) {
while (fastField->SkipBlanks()) {
if (auto ch{fastField->Next()}) {
if (inNamelist && *ch == '!') {
// skip namelist comment
} else {
byteCount = 1;
return ch;
}
}
if (!AdvanceRecord()) {
break;
}
fastField->NextRecord(*this);
}
}
auto ch{GetCurrentCharSlow(byteCount)};
while (!ch || *ch == ' ' || *ch == '\t' || *ch == '\n' ||
(inNamelist && *ch == '!')) {
if (ch && (*ch == ' ' || *ch == '\t' || *ch == '\n')) {
if (fastField) {
fastField->Advance(0, byteCount);
} else {
HandleRelativePosition(byteCount);
}
} else if (AdvanceRecord()) {
if (fastField) {
fastField->NextRecord(*this);
}
} else {
HandleRelativePosition(byteCount);
} else if (!AdvanceRecord()) {
return common::nullopt;
}
ch = GetCurrentChar(byteCount, fastField);
ch = GetCurrentCharSlow(byteCount);
}
return ch;
}
Expand Down
Loading