@@ -97,17 +97,7 @@ void Prescanner::Prescan(ProvenanceRange range) {
97
97
while (!IsAtEnd ()) {
98
98
Statement ();
99
99
}
100
- if (inFixedForm_ != beganInFixedForm) {
101
- std::string dir{" !dir$ " };
102
- if (beganInFixedForm) {
103
- dir += " fixed" ;
104
- } else {
105
- dir += " free" ;
106
- }
107
- dir += ' \n ' ;
108
- TokenSequence tokens{dir, allSources_.AddCompilerInsertion (dir).start ()};
109
- tokens.Emit (cooked_);
110
- }
100
+ inFixedForm_ = beganInFixedForm;
111
101
}
112
102
113
103
void Prescanner::Statement () {
@@ -324,10 +314,11 @@ void Prescanner::Statement() {
324
314
}
325
315
NormalizeCompilerDirectiveCommentMarker (*preprocessed);
326
316
preprocessed->ToLowerCase ();
327
- SourceFormChange (preprocessed->ToString ());
328
- CheckAndEmitLine (
329
- preprocessed->ClipComment (*this , true /* skip first ! */ ),
330
- newlineProvenance);
317
+ if (!SourceFormChange (preprocessed->ToString ())) {
318
+ CheckAndEmitLine (
319
+ preprocessed->ClipComment (*this , true /* skip first ! */ ),
320
+ newlineProvenance);
321
+ }
331
322
break ;
332
323
case LineClassification::Kind::Source:
333
324
if (inFixedForm_) {
@@ -370,14 +361,16 @@ void Prescanner::Statement() {
370
361
}
371
362
}
372
363
tokens.ToLowerCase ();
373
- SourceFormChange (tokens.ToString ());
364
+ if (!SourceFormChange (tokens.ToString ())) {
365
+ CheckAndEmitLine (tokens, newlineProvenance);
366
+ }
374
367
} else { // Kind::Source
375
368
tokens.ToLowerCase ();
376
369
if (inFixedForm_) {
377
370
EnforceStupidEndStatementRules (tokens);
378
371
}
372
+ CheckAndEmitLine (tokens, newlineProvenance);
379
373
}
380
- CheckAndEmitLine (tokens, newlineProvenance);
381
374
}
382
375
directiveSentinel_ = nullptr ;
383
376
}
@@ -1774,11 +1767,15 @@ Prescanner::LineClassification Prescanner::ClassifyLine(
1774
1767
return classification;
1775
1768
}
1776
1769
1777
- void Prescanner::SourceFormChange (std::string &&dir) {
1770
+ bool Prescanner::SourceFormChange (std::string &&dir) {
1778
1771
if (dir == " !dir$ free" ) {
1779
1772
inFixedForm_ = false ;
1773
+ return true ;
1780
1774
} else if (dir == " !dir$ fixed" ) {
1781
1775
inFixedForm_ = true ;
1776
+ return true ;
1777
+ } else {
1778
+ return false ;
1782
1779
}
1783
1780
}
1784
1781
0 commit comments