Skip to content

Commit f6e70c7

Browse files
authored
[flang][runtime] Handle ';' in fixed-width input field (#150512)
Formatted input of real values can handle a ',' field separator when one appears in an fixed-width input field, but can't cope with a semicolon under DECIMAL='COMMA'. Fix. Fixes #150047.
1 parent 918d6db commit f6e70c7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

flang-rt/lib/runtime/edit-input.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ static RT_API_ATTRS ScannedRealInput ScanRealInput(
344344
}
345345
bool bzMode{(edit.modes.editingFlags & blankZero) != 0};
346346
int exponent{0};
347-
if (!next || (!bzMode && *next == ' ') ||
348-
(!(edit.modes.editingFlags & decimalComma) && *next == ',')) {
347+
const char32_t comma{GetSeparatorChar(edit)};
348+
if (!next || (!bzMode && *next == ' ') || *next == comma) {
349349
if (!edit.IsListDirected() && !io.GetConnectionState().IsAtEOF()) {
350350
// An empty/blank field means zero when not list-directed.
351351
// A fixed-width field containing only a sign is also zero;
@@ -545,7 +545,7 @@ static RT_API_ATTRS ScannedRealInput ScanRealInput(
545545
while (next && (*next == ' ' || *next == '\t')) {
546546
next = io.NextInField(remaining, edit);
547547
}
548-
if (next && (*next != ',' || (edit.modes.editingFlags & decimalComma))) {
548+
if (next && *next != comma) {
549549
return {}; // error: unused nonblank character in fixed-width field
550550
}
551551
}

flang-rt/unittests/Runtime/NumericalFormatTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ TEST(IOApiTests, EditDoubleInputValues) {
921921
{"(BZ,F18.0)", " . ", 0x0, 0},
922922
{"(BZ,F18.0)", " . e +1 ", 0x0, 0},
923923
{"(DC,F18.0)", " 12,5", 0x4029000000000000, 0},
924+
{"(DC,F18.0)", " 12,5;", 0x4029000000000000, 0},
924925
{"(EX22.0)", "0X0P0 ", 0x0, 0}, // +0.
925926
{"(EX22.0)", "-0X0P0 ", 0x8000000000000000, 0}, // -0.
926927
{"(EX22.0)", "0X.8P1 ", 0x3ff0000000000000, 0}, // 1.0

0 commit comments

Comments
 (0)