Replace str_index function with intrinsic index

This commit is contained in:
Lorenzo Figini 2022-11-14 16:57:57 +00:00
parent 91fa6d84e0
commit 5ff1d8cd10
2 changed files with 3 additions and 20 deletions

View File

@ -237,7 +237,7 @@ contains
call get_command_string(i + 1, temp)
! split at "=" (id=value)
sep = findloc([(temp(i:i) == '=', i = 1, len(temp))], .true., 1)
sep = index(temp, '=')
id = temp(1:sep - 1)
val = temp(sep + 1:)

View File

@ -98,7 +98,7 @@ contains
! parse section header
if (line(1:1) == section_start) then
! split at section stop (ex. [section<here>])
sep = str_index(line, section_stop)
sep = index(line, section_stop)
if (sep == 0) then
write (msg, '("invalid section header at line ",g0,": ",a)') n, line
@ -113,7 +113,7 @@ contains
end if
! split line at separator (ex. name<here>=value)
sep = str_index(line, property_sep)
sep = index(line, property_sep)
if (sep == 0) then
write (msg, '("invalid property definition at line ",g0,": ",a)') n, line
call log_error(msg, proc='parse_ini', mod='ini_parser')
@ -173,21 +173,4 @@ contains
end do
end subroutine getline
pure function str_index(str, char) result(n)
! Returns the index of the first occurence of `char` within `str`
! If not `char` is not found returns 0
implicit none
! function arguments
character(*), intent(in) :: str
character, intent(in) :: char
! local variables
integer i, n
n = findloc([(str(i:i) == char, i = 1, len(str))], .true., 1)
end function str_index
end module ini_parser