[flang-commits] [flang] cb19393 - [flang][runtime] Complete list-directed character input with DECIMAL='COMMA'
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Wed Jul 13 16:42:58 PDT 2022
Author: Peter Klausler
Date: 2022-07-13T16:37:44-07:00
New Revision: cb193931fa05c5f51e4779c80ae8d2fe0c1c3ea9
URL: https://github.com/llvm/llvm-project/commit/cb193931fa05c5f51e4779c80ae8d2fe0c1c3ea9
DIFF: https://github.com/llvm/llvm-project/commit/cb193931fa05c5f51e4779c80ae8d2fe0c1c3ea9.diff
LOG: [flang][runtime] Complete list-directed character input with DECIMAL='COMMA'
Most of the infrastructure for DECIMAL='COMMA' mode was in place
in the I/O runtime support library, but I dropped the ball for
list-directed character input, which has its own detection of
input separators. Finish the job.
Differential Revision: https://reviews.llvm.org/D129679
Added:
Modified:
flang/runtime/edit-input.cpp
flang/runtime/io-stmt.cpp
Removed:
################################################################################
diff --git a/flang/runtime/edit-input.cpp b/flang/runtime/edit-input.cpp
index 5be6b0760418..f2ee328c3b47 100644
--- a/flang/runtime/edit-input.cpp
+++ b/flang/runtime/edit-input.cpp
@@ -654,15 +654,25 @@ static bool EditListDirectedCharacterInput(
// in NextInField.
std::optional<int> remaining{length > 0 ? maxUTF8Bytes : 0};
while (std::optional<char32_t> 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 96f5bb9eb8c3..66b5e9c30d62 100644
--- a/flang/runtime/io-stmt.cpp
+++ b/flang/runtime/io-stmt.cpp
@@ -630,7 +630,6 @@ std::optional<char32_t> IoStatementState::NextInField(
switch (*next) {
case ' ':
case '\t':
- case ';':
case '/':
case '(':
case ')':
@@ -640,11 +639,15 @@ std::optional<char32_t> 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;
}
More information about the flang-commits
mailing list