@@ -79,7 +79,7 @@ function parse_f_source(f_filename,error) result(f_source)
79
79
integer :: stat
80
80
integer :: fh, n_use, n_include, n_mod, i, j, ic, pass
81
81
type (string_t), allocatable :: file_lines(:)
82
- character (:), allocatable :: temp_string, mod_name
82
+ character (:), allocatable :: temp_string, mod_name, string_parts(:)
83
83
84
84
f_source% file_name = f_filename
85
85
@@ -191,22 +191,25 @@ function parse_f_source(f_filename,error) result(f_source)
191
191
! Extract name of module if is module
192
192
if (index (adjustl (lower(file_lines(i)% s)),' module ' ) == 1 ) then
193
193
194
- mod_name = lower(split_n(file_lines(i)% s,n= 2 ,delims= ' ' ,stat= stat))
195
- if (stat /= 0 ) then
196
- call file_parse_error(error,f_filename, &
197
- ' unable to find module name' ,i, &
198
- file_lines(i)% s)
199
- return
194
+ ! Remove any trailing comments
195
+ ic = index (file_lines(i)% s,' !' )- 1
196
+ if (ic < 1 ) then
197
+ ic = len (file_lines(i)% s)
198
+ end if
199
+ temp_string = trim (file_lines(i)% s(1 :ic))
200
+
201
+ ! R1405 module-stmt := "MODULE" module-name
202
+ ! module-stmt has two space-delimited parts only
203
+ ! (no line continuations)
204
+ call split(temp_string,string_parts,' ' )
205
+ if (size (string_parts) /= 2 ) then
206
+ cycle
200
207
end if
201
208
202
- if (mod_name == ' procedure' .or. &
203
- mod_name == ' subroutine' .or. &
204
- mod_name == ' function' .or. &
205
- scan (mod_name,' =(' )>0 ) then
209
+ mod_name = lower(trim (adjustl (string_parts(2 ))))
210
+ if (scan (mod_name,' =(&' )>0 ) then
206
211
! Ignore these cases:
207
- ! module procedure *
208
- ! module function *
209
- ! module subroutine *
212
+ ! module <something>&
210
213
! module =*
211
214
! module (i)
212
215
cycle
0 commit comments