@@ -54,6 +54,10 @@ static RT_API_ATTRS bool CheckCompleteListDirectedField(
54
54
}
55
55
}
56
56
57
+ static inline RT_API_ATTRS char32_t GetSeparatorChar (const DataEdit &edit) {
58
+ return edit.modes .editingFlags & decimalComma ? char32_t {' ;' } : char32_t {' ,' };
59
+ }
60
+
57
61
template <int LOG2_BASE>
58
62
static RT_API_ATTRS bool EditBOZInput (
59
63
IoStatementState &io, const DataEdit &edit, void *n, std::size_t bytes) {
@@ -70,6 +74,7 @@ static RT_API_ATTRS bool EditBOZInput(
70
74
// Count significant digits after any leading white space & zeroes
71
75
int digits{0 };
72
76
int significantBits{0 };
77
+ const char32_t comma{GetSeparatorChar (edit)};
73
78
for (; next; next = io.NextInField (remaining, edit)) {
74
79
char32_t ch{*next};
75
80
if (ch == ' ' || ch == ' \t ' ) {
@@ -84,7 +89,7 @@ static RT_API_ATTRS bool EditBOZInput(
84
89
} else if (LOG2_BASE >= 4 && ch >= ' 8' && ch <= ' 9' ) {
85
90
} else if (LOG2_BASE >= 4 && ch >= ' A' && ch <= ' F' ) {
86
91
} else if (LOG2_BASE >= 4 && ch >= ' a' && ch <= ' f' ) {
87
- } else if (ch == ' , ' ) {
92
+ } else if (ch == comma ) {
88
93
break ; // end non-list-directed field early
89
94
} else {
90
95
io.GetIoErrorHandler ().SignalError (
@@ -209,6 +214,7 @@ RT_API_ATTRS bool EditIntegerInput(
209
214
common::UnsignedInt128 value{0 };
210
215
bool any{!!sign};
211
216
bool overflow{false };
217
+ const char32_t comma{GetSeparatorChar (edit)};
212
218
for (; next; next = io.NextInField (remaining, edit)) {
213
219
char32_t ch{*next};
214
220
if (ch == ' ' || ch == ' \t ' ) {
@@ -221,9 +227,23 @@ RT_API_ATTRS bool EditIntegerInput(
221
227
int digit{0 };
222
228
if (ch >= ' 0' && ch <= ' 9' ) {
223
229
digit = ch - ' 0' ;
224
- } else if (ch == ' , ' ) {
230
+ } else if (ch == comma ) {
225
231
break ; // end non-list-directed field early
226
232
} else {
233
+ if (edit.modes .inNamelist && ch == GetRadixPointChar (edit)) {
234
+ // Ignore any fractional part that might appear in NAMELIST integer
235
+ // input, like a few other Fortran compilers do.
236
+ // TODO: also process exponents? Some compilers do, but they obviously
237
+ // can't just be ignored.
238
+ while ((next = io.NextInField (remaining, edit))) {
239
+ if (*next < ' 0' || *next > ' 9' ) {
240
+ break ;
241
+ }
242
+ }
243
+ if (!next || *next == comma) {
244
+ break ;
245
+ }
246
+ }
227
247
io.GetIoErrorHandler ().SignalError (
228
248
" Bad character '%lc' in INTEGER input field" , ch);
229
249
return false ;
0 commit comments