1919namespace Fortran ::runtime::io {
2020RT_OFFLOAD_API_GROUP_BEGIN
2121
22- // Checks that a list-directed input value has been entirely consumed and
23- // doesn't contain unparsed characters before the next value separator.
22+ // Handle DC or DECIMAL='COMMA' and determine the active separator character
23+ static inline RT_API_ATTRS char32_t GetSeparatorChar (const DataEdit &edit) {
24+ return edit.modes .editingFlags & decimalComma ? char32_t {' ;' } : char32_t {' ,' };
25+ }
26+
2427static inline RT_API_ATTRS bool IsCharValueSeparator (
2528 const DataEdit &edit, char32_t ch) {
26- char32_t comma{
27- edit.modes .editingFlags & decimalComma ? char32_t {' ;' } : char32_t {' ,' }};
28- return ch == ' ' || ch == ' \t ' || ch == comma || ch == ' /' ||
29+ return ch == ' ' || ch == ' \t ' || ch == ' /' || ch == GetSeparatorChar (edit) ||
2930 (edit.IsNamelist () && (ch == ' &' || ch == ' $' ));
3031}
3132
33+ // Checks that a list-directed input value has been entirely consumed and
34+ // doesn't contain unparsed characters before the next value separator.
3235static RT_API_ATTRS bool CheckCompleteListDirectedField (
3336 IoStatementState &io, const DataEdit &edit) {
3437 if (edit.IsListDirected ()) {
@@ -54,10 +57,6 @@ static RT_API_ATTRS bool CheckCompleteListDirectedField(
5457 }
5558}
5659
57- static inline RT_API_ATTRS char32_t GetSeparatorChar (const DataEdit &edit) {
58- return edit.modes .editingFlags & decimalComma ? char32_t {' ;' } : char32_t {' ,' };
59- }
60-
6160template <int LOG2_BASE>
6261static RT_API_ATTRS bool EditBOZInput (
6362 IoStatementState &io, const DataEdit &edit, void *n, std::size_t bytes) {
@@ -518,7 +517,7 @@ static RT_API_ATTRS ScannedRealInput ScanRealInput(
518517 // Consume the trailing ')' of a list-directed or NAMELIST complex
519518 // input value.
520519 if (edit.descriptor == DataEdit::ListDirectedImaginaryPart) {
521- if (next && ( *next == ' ' || *next == ' \t ' ) ) {
520+ if (! next || *next == ' ' || *next == ' \t ' ) {
522521 io.SkipSpaces (remaining);
523522 next = io.NextInField (remaining, edit);
524523 }
@@ -1006,27 +1005,7 @@ static RT_API_ATTRS bool EditListDirectedCharacterInput(
10061005 // Undelimited list-directed character input: stop at a value separator
10071006 // or the end of the current record.
10081007 while (auto ch{io.GetCurrentChar (byteCount)}) {
1009- bool isSep{false };
1010- switch (*ch) {
1011- case ' ' :
1012- case ' \t ' :
1013- case ' /' :
1014- isSep = true ;
1015- break ;
1016- case ' &' :
1017- case ' $' :
1018- isSep = edit.IsNamelist ();
1019- break ;
1020- case ' ,' :
1021- isSep = !(edit.modes .editingFlags & decimalComma);
1022- break ;
1023- case ' ;' :
1024- isSep = !!(edit.modes .editingFlags & decimalComma);
1025- break ;
1026- default :
1027- break ;
1028- }
1029- if (isSep) {
1008+ if (IsCharValueSeparator (edit, *ch)) {
10301009 break ;
10311010 }
10321011 if (length > 0 ) {
0 commit comments