19
19
namespace Fortran ::runtime::io {
20
20
RT_OFFLOAD_API_GROUP_BEGIN
21
21
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
+
24
27
static inline RT_API_ATTRS bool IsCharValueSeparator (
25
28
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) ||
29
30
(edit.IsNamelist () && (ch == ' &' || ch == ' $' ));
30
31
}
31
32
33
+ // Checks that a list-directed input value has been entirely consumed and
34
+ // doesn't contain unparsed characters before the next value separator.
32
35
static RT_API_ATTRS bool CheckCompleteListDirectedField (
33
36
IoStatementState &io, const DataEdit &edit) {
34
37
if (edit.IsListDirected ()) {
@@ -54,10 +57,6 @@ static RT_API_ATTRS bool CheckCompleteListDirectedField(
54
57
}
55
58
}
56
59
57
- static inline RT_API_ATTRS char32_t GetSeparatorChar (const DataEdit &edit) {
58
- return edit.modes .editingFlags & decimalComma ? char32_t {' ;' } : char32_t {' ,' };
59
- }
60
-
61
60
template <int LOG2_BASE>
62
61
static RT_API_ATTRS bool EditBOZInput (
63
62
IoStatementState &io, const DataEdit &edit, void *n, std::size_t bytes) {
@@ -518,7 +517,7 @@ static RT_API_ATTRS ScannedRealInput ScanRealInput(
518
517
// Consume the trailing ')' of a list-directed or NAMELIST complex
519
518
// input value.
520
519
if (edit.descriptor == DataEdit::ListDirectedImaginaryPart) {
521
- if (next && ( *next == ' ' || *next == ' \t ' ) ) {
520
+ if (! next || *next == ' ' || *next == ' \t ' ) {
522
521
io.SkipSpaces (remaining);
523
522
next = io.NextInField (remaining, edit);
524
523
}
@@ -1006,27 +1005,7 @@ static RT_API_ATTRS bool EditListDirectedCharacterInput(
1006
1005
// Undelimited list-directed character input: stop at a value separator
1007
1006
// or the end of the current record.
1008
1007
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)) {
1030
1009
break ;
1031
1010
}
1032
1011
if (length > 0 ) {
0 commit comments