104
104
NAT_VAR_REGEX ,
105
105
NON_DEF_REGEX ,
106
106
PARAMETER_VAL_REGEX ,
107
+ PP_ANY_REGEX ,
107
108
PP_DEF_REGEX ,
108
109
PP_INCLUDE_REGEX ,
109
110
PP_REGEX ,
@@ -978,7 +979,7 @@ def get_code_line(
978
979
line_ind -= 1
979
980
else : # Free format file
980
981
opt_cont_match = FREE_CONT_REGEX .match (curr_line )
981
- if opt_cont_match is not None :
982
+ if opt_cont_match :
982
983
curr_line = (
983
984
" " * opt_cont_match .end (0 ) + curr_line [opt_cont_match .end (0 ) :]
984
985
)
@@ -989,7 +990,7 @@ def get_code_line(
989
990
tmp_no_comm = tmp_line .split ("!" )[0 ]
990
991
cont_ind = tmp_no_comm .rfind ("&" )
991
992
opt_cont_match = FREE_CONT_REGEX .match (tmp_no_comm )
992
- if opt_cont_match is not None :
993
+ if opt_cont_match :
993
994
if cont_ind == opt_cont_match .end (0 ) - 1 :
994
995
break
995
996
tmp_no_comm = (
@@ -1022,21 +1023,27 @@ def get_code_line(
1022
1023
if iComm < 0 :
1023
1024
iComm = iAmper + 1
1024
1025
next_line = ""
1026
+ # Read the next line if needed
1025
1027
while (iAmper >= 0 ) and (iAmper < iComm ):
1026
1028
if line_ind == line_number + 1 :
1027
1029
curr_line = curr_line [:iAmper ]
1028
1030
elif next_line != "" :
1029
1031
post_lines [- 1 ] = next_line [:iAmper ]
1030
1032
next_line = self .get_line (line_ind , pp_content )
1031
1033
line_ind += 1
1034
+ # Skip any preprocessor statements when seeking the next line
1035
+ if PP_ANY_REGEX .match (next_line ):
1036
+ next_line = ""
1037
+ post_lines .append ("" )
1038
+ continue
1032
1039
# Skip empty or comment lines
1033
1040
match = FREE_COMMENT_LINE_MATCH .match (next_line )
1034
- if ( next_line .rstrip () == "" ) or ( match is not None ) :
1041
+ if next_line .rstrip () == "" or match :
1035
1042
next_line = ""
1036
1043
post_lines .append ("" )
1037
1044
continue
1038
1045
opt_cont_match = FREE_CONT_REGEX .match (next_line )
1039
- if opt_cont_match is not None :
1046
+ if opt_cont_match :
1040
1047
next_line = (
1041
1048
" " * opt_cont_match .end (0 )
1042
1049
+ next_line [opt_cont_match .end (0 ) :]
@@ -1056,9 +1063,7 @@ def get_code_line(
1056
1063
def strip_comment (self , line : str ) -> str :
1057
1064
"""Strip comment from line"""
1058
1065
if self .fixed :
1059
- if (FIXED_COMMENT_LINE_MATCH .match (line ) is not None ) and (
1060
- FIXED_OPENMP_MATCH .match (line ) is not None
1061
- ):
1066
+ if FIXED_COMMENT_LINE_MATCH .match (line ) and FIXED_OPENMP_MATCH .match (line ):
1062
1067
return ""
1063
1068
else :
1064
1069
if FREE_OPENMP_MATCH .match (line ) is None :
0 commit comments