diff --git a/flang/runtime/edit-input.cpp b/flang/runtime/edit-input.cpp index 5be6b07604181..f2ee328c3b478 100644 --- a/flang/runtime/edit-input.cpp +++ b/flang/runtime/edit-input.cpp @@ -654,15 +654,25 @@ static bool EditListDirectedCharacterInput( // in NextInField. std::optional remaining{length > 0 ? maxUTF8Bytes : 0}; while (std::optional next{io.NextInField(remaining, edit)}) { + bool isSep{false}; switch (*next) { case ' ': case '\t': + case '/': + isSep = true; + break; case ',': + isSep = !(edit.modes.editingFlags & decimalComma); + break; case ';': - case '/': - remaining = 0; // value separator: stop + isSep = !!(edit.modes.editingFlags & decimalComma); break; default: + break; + } + if (isSep) { + remaining = 0; + } else { *x++ = *next; remaining = --length > 0 ? maxUTF8Bytes : 0; } diff --git a/flang/runtime/io-stmt.cpp b/flang/runtime/io-stmt.cpp index 96f5bb9eb8c3b..66b5e9c30d627 100644 --- a/flang/runtime/io-stmt.cpp +++ b/flang/runtime/io-stmt.cpp @@ -630,7 +630,6 @@ std::optional IoStatementState::NextInField( switch (*next) { case ' ': case '\t': - case ';': case '/': case '(': case ')': @@ -640,11 +639,15 @@ std::optional IoStatementState::NextInField( case '\n': // for stream access return std::nullopt; case ',': + if (!(edit.modes.editingFlags & decimalComma)) { + return std::nullopt; + } + break; + case ';': if (edit.modes.editingFlags & decimalComma) { - break; - } else { return std::nullopt; } + break; default: break; }