@@ -19,7 +19,7 @@ static bool EditBOZInput(IoStatementState &io, const DataEdit &edit, void *n,
19
19
std::optional<int > remaining;
20
20
std::optional<char32_t > next{io.PrepareInput (edit, remaining)};
21
21
common::UnsignedInt128 value{0 };
22
- for (; next; next = io.NextInField (remaining)) {
22
+ for (; next; next = io.NextInField (remaining, edit )) {
23
23
char32_t ch{*next};
24
24
if (ch == ' ' || ch == ' \t ' ) {
25
25
continue ;
@@ -63,7 +63,7 @@ static bool ScanNumericPrefix(IoStatementState &io, const DataEdit &edit,
63
63
if (negative || *next == ' +' ) {
64
64
io.GotChar ();
65
65
io.SkipSpaces (remaining);
66
- next = io.NextInField (remaining, GetDecimalPoint ( edit) );
66
+ next = io.NextInField (remaining, edit);
67
67
}
68
68
}
69
69
return negative;
@@ -101,7 +101,7 @@ bool EditIntegerInput(
101
101
bool negate{ScanNumericPrefix (io, edit, next, remaining)};
102
102
common::UnsignedInt128 value{0 };
103
103
bool any{negate};
104
- for (; next; next = io.NextInField (remaining)) {
104
+ for (; next; next = io.NextInField (remaining, edit )) {
105
105
char32_t ch{*next};
106
106
if (ch == ' ' || ch == ' \t ' ) {
107
107
if (edit.modes .editingFlags & blankZero) {
@@ -167,7 +167,7 @@ static int ScanRealInput(char *buffer, int bufferSize, IoStatementState &io,
167
167
// Subtle: a blank field of digits could be followed by 'E' or 'D',
168
168
for (; next &&
169
169
((*next >= ' a' && *next <= ' z' ) || (*next >= ' A' && *next <= ' Z' ));
170
- next = io.NextInField (remaining)) {
170
+ next = io.NextInField (remaining, edit )) {
171
171
if (*next >= ' a' && *next <= ' z' ) {
172
172
Put (*next - ' a' + ' A' );
173
173
} else {
@@ -176,7 +176,7 @@ static int ScanRealInput(char *buffer, int bufferSize, IoStatementState &io,
176
176
}
177
177
if (next && *next == ' (' ) { // NaN(...)
178
178
while (next && *next != ' )' ) {
179
- next = io.NextInField (remaining);
179
+ next = io.NextInField (remaining, edit );
180
180
}
181
181
}
182
182
exponent = 0 ;
@@ -185,7 +185,7 @@ static int ScanRealInput(char *buffer, int bufferSize, IoStatementState &io,
185
185
Put (' .' ); // input field is normalized to a fraction
186
186
auto start{got};
187
187
bool bzMode{(edit.modes .editingFlags & blankZero) != 0 };
188
- for (; next; next = io.NextInField (remaining, decimal )) {
188
+ for (; next; next = io.NextInField (remaining, edit )) {
189
189
char32_t ch{*next};
190
190
if (ch == ' ' || ch == ' \t ' ) {
191
191
if (bzMode) {
@@ -214,7 +214,7 @@ static int ScanRealInput(char *buffer, int bufferSize, IoStatementState &io,
214
214
// Optional exponent letter. Blanks are allowed between the
215
215
// optional exponent letter and the exponent value.
216
216
io.SkipSpaces (remaining);
217
- next = io.NextInField (remaining);
217
+ next = io.NextInField (remaining, edit );
218
218
}
219
219
// The default exponent is -kP, but the scale factor doesn't affect
220
220
// an explicit exponent.
@@ -224,9 +224,9 @@ static int ScanRealInput(char *buffer, int bufferSize, IoStatementState &io,
224
224
(bzMode && (*next == ' ' || *next == ' \t ' )))) {
225
225
bool negExpo{*next == ' -' };
226
226
if (negExpo || *next == ' +' ) {
227
- next = io.NextInField (remaining);
227
+ next = io.NextInField (remaining, edit );
228
228
}
229
- for (exponent = 0 ; next; next = io.NextInField (remaining)) {
229
+ for (exponent = 0 ; next; next = io.NextInField (remaining, edit )) {
230
230
if (*next >= ' 0' && *next <= ' 9' ) {
231
231
exponent = 10 * exponent + *next - ' 0' ;
232
232
} else if (bzMode && (*next == ' ' || *next == ' \t ' )) {
@@ -257,7 +257,7 @@ static int ScanRealInput(char *buffer, int bufferSize, IoStatementState &io,
257
257
// input value.
258
258
if (edit.descriptor == DataEdit::ListDirectedImaginaryPart) {
259
259
if (next && (*next == ' ' || *next == ' \t ' )) {
260
- next = io.NextInField (remaining);
260
+ next = io.NextInField (remaining, edit );
261
261
}
262
262
if (!next) { // NextInField fails on separators like ')'
263
263
next = io.GetCurrentChar ();
@@ -267,7 +267,7 @@ static int ScanRealInput(char *buffer, int bufferSize, IoStatementState &io,
267
267
}
268
268
} else if (remaining) {
269
269
while (next && (*next == ' ' || *next == ' \t ' )) {
270
- next = io.NextInField (remaining);
270
+ next = io.NextInField (remaining, edit );
271
271
}
272
272
if (next) {
273
273
return 0 ; // error: unused nonblank character in fixed-width field
@@ -457,7 +457,7 @@ bool EditLogicalInput(IoStatementState &io, const DataEdit &edit, bool &x) {
457
457
std::optional<int > remaining;
458
458
std::optional<char32_t > next{io.PrepareInput (edit, remaining)};
459
459
if (next && *next == ' .' ) { // skip optional period
460
- next = io.NextInField (remaining);
460
+ next = io.NextInField (remaining, edit );
461
461
}
462
462
if (!next) {
463
463
io.GetIoErrorHandler ().SignalError (" Empty LOGICAL input field" );
@@ -480,7 +480,7 @@ bool EditLogicalInput(IoStatementState &io, const DataEdit &edit, bool &x) {
480
480
if (remaining) { // ignore the rest of the field
481
481
io.HandleRelativePosition (*remaining);
482
482
} else if (edit.descriptor == DataEdit::ListDirected) {
483
- while (io.NextInField (remaining)) { // discard rest of field
483
+ while (io.NextInField (remaining, edit )) { // discard rest of field
484
484
}
485
485
}
486
486
return true ;
@@ -520,7 +520,7 @@ static bool EditDelimitedCharacterInput(
520
520
}
521
521
522
522
static bool EditListDirectedDefaultCharacterInput (
523
- IoStatementState &io, char *x, std::size_t length) {
523
+ IoStatementState &io, char *x, std::size_t length, const DataEdit &edit ) {
524
524
auto ch{io.GetCurrentChar ()};
525
525
if (ch && (*ch == ' \' ' || *ch == ' "' )) {
526
526
io.HandleRelativePosition (1 );
@@ -532,8 +532,7 @@ static bool EditListDirectedDefaultCharacterInput(
532
532
// Undelimited list-directed character input: stop at a value separator
533
533
// or the end of the current record.
534
534
std::optional<int > remaining{length};
535
- for (std::optional<char32_t > next{io.NextInField (remaining)}; next;
536
- next = io.NextInField (remaining)) {
535
+ while (std::optional<char32_t > next{io.NextInField (remaining, edit)}) {
537
536
switch (*next) {
538
537
case ' ' :
539
538
case ' \t ' :
@@ -555,7 +554,7 @@ bool EditDefaultCharacterInput(
555
554
IoStatementState &io, const DataEdit &edit, char *x, std::size_t length) {
556
555
switch (edit.descriptor ) {
557
556
case DataEdit::ListDirected:
558
- return EditListDirectedDefaultCharacterInput (io, x, length);
557
+ return EditListDirectedDefaultCharacterInput (io, x, length, edit );
559
558
case ' A' :
560
559
case ' G' :
561
560
break ;
@@ -576,8 +575,7 @@ bool EditDefaultCharacterInput(
576
575
// characters. When the variable is wider than the field, there's
577
576
// trailing padding.
578
577
std::int64_t skip{*remaining - static_cast <std::int64_t >(length)};
579
- for (std::optional<char32_t > next{io.NextInField (remaining)}; next;
580
- next = io.NextInField (remaining)) {
578
+ while (std::optional<char32_t > next{io.NextInField (remaining, edit)}) {
581
579
if (skip > 0 ) {
582
580
--skip;
583
581
io.GotChar (-1 );
0 commit comments