diff options
author | Peter Klausler <pklausler@nvidia.com> | 2022-07-08 15:25:01 -0700 |
---|---|---|
committer | Peter Klausler <pklausler@nvidia.com> | 2022-07-13 16:37:44 -0700 |
commit | cb193931fa05c5f51e4779c80ae8d2fe0c1c3ea9 (patch) | |
tree | c8e27009314766846088549a63ce3aca4fbfe357 | |
parent | 0406c0cda675f3cb7d294a3e65eb4f19c9efe98b (diff) | |
download | llvm-cb193931fa05c5f51e4779c80ae8d2fe0c1c3ea9.zip llvm-cb193931fa05c5f51e4779c80ae8d2fe0c1c3ea9.tar.gz llvm-cb193931fa05c5f51e4779c80ae8d2fe0c1c3ea9.tar.bz2 |
[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
-rw-r--r-- | flang/runtime/edit-input.cpp | 14 | ||||
-rw-r--r-- | flang/runtime/io-stmt.cpp | 9 |
2 files changed, 18 insertions, 5 deletions
diff --git a/flang/runtime/edit-input.cpp b/flang/runtime/edit-input.cpp index 5be6b07..f2ee328 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 96f5bb9..66b5e9c 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; } |