From 5ff1d8cd103775c5e0291e740c33a4ed99a17213 Mon Sep 17 00:00:00 2001 From: Lorenzo Figini Date: Mon, 14 Nov 2022 16:57:57 +0000 Subject: [PATCH] Replace str_index function with intrinsic index --- src/gray_cli.f90 | 2 +- src/ini_parser.f90 | 21 ++------------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/gray_cli.f90 b/src/gray_cli.f90 index f720bcd..482cbda 100644 --- a/src/gray_cli.f90 +++ b/src/gray_cli.f90 @@ -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:) diff --git a/src/ini_parser.f90 b/src/ini_parser.f90 index e717ee7..ddc93ec 100644 --- a/src/ini_parser.f90 +++ b/src/ini_parser.f90 @@ -98,7 +98,7 @@ contains ! parse section header if (line(1:1) == section_start) then ! split at section stop (ex. [section]) - 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=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