[PATCH] D83810: [flang] Fix list-directed input (repeated nulls and LOGICAL)
Peter Klausler via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 14 17:00:39 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8dbc86adf3e4: [flang] Fix list-directed input (repeated nulls and LOGICAL) (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83810/new/
https://reviews.llvm.org/D83810
Files:
flang/runtime/edit-input.cpp
flang/runtime/io-stmt.cpp
flang/unittests/Runtime/list-input.cpp
Index: flang/unittests/Runtime/list-input.cpp
===================================================================
--- flang/unittests/Runtime/list-input.cpp
+++ flang/unittests/Runtime/list-input.cpp
@@ -15,7 +15,7 @@
char buffer[4][32];
int j{0};
- for (const char *p : {"1 2 2*3 ,", ",6,,8,123*",
+ for (const char *p : {"1 2 2*3 ,", ",6,,8,1*",
"2*'abcdefghijklmnopqrstuvwxyzABC", "DEFGHIJKLMNOPQRSTUVWXYZ'"}) {
SetCharacter(buffer[j++], sizeof buffer[0], p);
}
Index: flang/runtime/io-stmt.cpp
===================================================================
--- flang/runtime/io-stmt.cpp
+++ flang/runtime/io-stmt.cpp
@@ -472,6 +472,10 @@
edit.descriptor = DataEdit::ListDirectedNullValue;
return edit;
}
+ char32_t comma{','};
+ if (io.mutableModes().editingFlags & decimalComma) {
+ comma = ';';
+ }
if (remaining_ > 0 && !realPart_) { // "r*c" repetition in progress
while (connection.currentRecordNumber > initialRecordNumber_) {
io.BackspaceRecord();
@@ -479,6 +483,10 @@
connection.HandleAbsolutePosition(initialPositionInRecord_);
if (!imaginaryPart_) {
edit.repeat = std::min<int>(remaining_, maxRepeat);
+ auto ch{io.GetNextNonBlank()};
+ if (!ch || *ch == ' ' || *ch == comma) { // "r*" repeated null
+ edit.descriptor = DataEdit::ListDirectedNullValue;
+ }
}
remaining_ -= edit.repeat;
return edit;
@@ -503,10 +511,6 @@
edit.descriptor = DataEdit::ListDirectedNullValue;
return edit;
}
- char32_t comma{','};
- if (io.mutableModes().editingFlags & decimalComma) {
- comma = ';';
- }
bool isFirstItem{isFirstItem_};
isFirstItem_ = false;
if (*ch == comma) {
@@ -544,10 +548,14 @@
if (r > 0 && ch && *ch == '*') { // subtle: r must be nonzero
io.HandleRelativePosition(1);
ch = io.GetCurrentChar();
- if (!ch || *ch == ' ' || *ch == comma || *ch == '/') { // "r*" null
+ if (ch && *ch == '/') { // r*/
+ hitSlash_ = true;
edit.descriptor = DataEdit::ListDirectedNullValue;
return edit;
}
+ if (!ch || *ch == ' ' || *ch == comma) { // "r*" null
+ edit.descriptor = DataEdit::ListDirectedNullValue;
+ }
edit.repeat = std::min<int>(r, maxRepeat);
remaining_ = r - edit.repeat;
initialRecordNumber_ = connection.currentRecordNumber;
Index: flang/runtime/edit-input.cpp
===================================================================
--- flang/runtime/edit-input.cpp
+++ flang/runtime/edit-input.cpp
@@ -337,6 +337,9 @@
}
if (remaining) { // ignore the rest of the field
io.HandleRelativePosition(*remaining);
+ } else if (edit.descriptor == DataEdit::ListDirected) {
+ while (io.NextInField(remaining)) { // discard rest of field
+ }
}
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83810.278024.patch
Type: text/x-patch
Size: 2840 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200715/60c59520/attachment.bin>
More information about the llvm-commits
mailing list