[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
This commit is contained in:
Peter Klausler 2022-07-08 15:25:01 -07:00
parent 0406c0cda6
commit cb193931fa
2 changed files with 20 additions and 7 deletions

View File

@ -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 ',':
case ';':
case '/':
remaining = 0; // value separator: stop
isSep = true;
break;
case ',':
isSep = !(edit.modes.editingFlags & decimalComma);
break;
case ';':
isSep = !!(edit.modes.editingFlags & decimalComma);
break;
default:
break;
}
if (isSep) {
remaining = 0;
} else {
*x++ = *next;
remaining = --length > 0 ? maxUTF8Bytes : 0;
}

View File

@ -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) {
break;
} else {
if (!(edit.modes.editingFlags & decimalComma)) {
return std::nullopt;
}
break;
case ';':
if (edit.modes.editingFlags & decimalComma) {
return std::nullopt;
}
break;
default:
break;
}