Skip to content

Commit 83c1a09

Browse files
authored
Merge pull request #3526 from masatake/fortran--reset-newline-state-for-new-input
Fortran: reset "newline" state when processing a new input file
2 parents 4da9290 + 2295541 commit 83c1a09

File tree

6 files changed

+25
-6
lines changed

6 files changed

+25
-6
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--sort=no
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mod1 input-1.f90 /^ MODULE mod1$/;" m
2+
var1 input-1.f90 /^ integer :: var1$/;" v module:mod1
3+
mod2 input-2.f90 /^ MODULE mod2$/;" m
4+
var2 input-2.f90 /^ integer :: var2$/;" v module:mod2
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "in.fpp"
2+
3+
MODULE mod1
4+
implicit none
5+
integer :: var1
6+
END MODULE mod1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "in.fpp"
2+
3+
MODULE mod2
4+
implicit none
5+
integer :: var2
6+
END MODULE
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
! Dummy file

parsers/fortran.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ static unsigned int Column;
224224
static bool FreeSourceForm;
225225
static bool FreeSourceFormFound = false;
226226
static bool ParsingString;
227+
static bool Newline;
227228

228229
/* indexed by tagType */
229230
static kindDefinition FortranKinds [] = {
@@ -781,7 +782,6 @@ static int skipToNextLine (void)
781782

782783
static int getFreeFormChar (void)
783784
{
784-
static bool newline = true;
785785
bool advanceLine = false;
786786
int c = getcFromInputFile ();
787787

@@ -796,7 +796,7 @@ static int getFreeFormChar (void)
796796
while (isspace (c) && c != '\n');
797797
if (c == '\n')
798798
{
799-
newline = true;
799+
Newline = true;
800800
advanceLine = true;
801801
}
802802
else if (c == '!')
@@ -807,24 +807,24 @@ static int getFreeFormChar (void)
807807
c = '&';
808808
}
809809
}
810-
else if (newline && (c == '!' || c == '#'))
810+
else if (Newline && (c == '!' || c == '#'))
811811
advanceLine = true;
812812
while (advanceLine)
813813
{
814814
while (isspace (c))
815815
c = getcFromInputFile ();
816-
if (c == '!' || (newline && c == '#'))
816+
if (c == '!' || (Newline && c == '#'))
817817
{
818818
c = skipToNextLine ();
819-
newline = true;
819+
Newline = true;
820820
continue;
821821
}
822822
if (c == '&')
823823
c = getcFromInputFile ();
824824
else
825825
advanceLine = false;
826826
}
827-
newline = (bool) (c == '\n');
827+
Newline = (bool) (c == '\n');
828828
return c;
829829
}
830830

@@ -2653,6 +2653,7 @@ static rescanReason findFortranTags (const unsigned int passCount)
26532653
token = newToken ();
26542654

26552655
FreeSourceForm = (bool) (passCount > 1);
2656+
Newline = (passCount == 1)? true: Newline;
26562657
Column = 0;
26572658
parseProgramUnit (token);
26582659
if (FreeSourceFormFound && ! FreeSourceForm)

0 commit comments

Comments
 (0)