diff --git a/src/api_internal_m.f90 b/src/api_internal_m.f90 index 263f5a72..3220652e 100644 --- a/src/api_internal_m.f90 +++ b/src/api_internal_m.f90 @@ -177,7 +177,7 @@ pure subroutine do_matching_exactly(automaton, string, res, prefix, suffix, runs integer :: max_match ! character(:), allocatable :: str - integer :: len_pre, len_post, n + integer :: len_pre, len_suf, n logical :: empty_pre, empty_post, matches_pre, matches_post runs_engine = .false. @@ -190,7 +190,7 @@ pure subroutine do_matching_exactly(automaton, string, res, prefix, suffix, runs end if len_pre = len(prefix) - len_post = len(suffix) + len_suf = len(suffix) n = len(string) matches_pre = .true. matches_post = .true. @@ -202,11 +202,18 @@ pure subroutine do_matching_exactly(automaton, string, res, prefix, suffix, runs return end if end if - + + ! Returns false if the prefix or suffix is ​​longer than the input string. + if (len_pre > len(string) .or. len_suf > len(string)) then + res = .false. + return + end if + empty_pre = prefix == '' empty_post = suffix == '' - if (.not. empty_pre) matches_pre = string(1:len_pre) == prefix - if (.not. empty_post) matches_post = string(n-len_post+1:n) == suffix + + if (.not. empty_pre) matches_pre = string(1:len_pre) == prefix + if (.not. empty_post) matches_post = string(n-len_suf+1:n) == suffix runs_engine = any([(matches_pre .and. matches_post), & (empty_pre .and. matches_post), & diff --git a/src/forgex_cli/cli_qpc_qpf.c b/src/forgex_cli/cli_qpc_qpf.c deleted file mode 100644 index 4dfc036e..00000000 --- a/src/forgex_cli/cli_qpc_qpf.c +++ /dev/null @@ -1,11 +0,0 @@ -// This file is a stub to building on Unix-like systems. -#if defined(_WIN32) || defined(_WIN64) -#else -#include -bool QueryPerformanceCounter(long long PerformanceCount_count) { - return false; -} -bool QueryPerformanceFrequency(long long Frequency_countPerSec) { - return false; -} -#endif \ No newline at end of file diff --git a/src/forgex_cli/cli_time_measurement_m.F90 b/src/forgex_cli/cli_time_measurement_m.F90 index f89ebec6..15924cc6 100644 --- a/src/forgex_cli/cli_time_measurement_m.F90 +++ b/src/forgex_cli/cli_time_measurement_m.F90 @@ -29,6 +29,7 @@ module forgex_cli_time_measurement_m logical(c_bool) :: is_succeeded = .false. !> For Windows, use high-resolution system call for timing. +#if defined(_WIN32) || defined(_WIN64) interface function QueryPerformanceCounter(PerformanceCount_count) result(is_succeeded_c) & bind(c, name="QueryPerformanceCounter") @@ -45,11 +46,36 @@ function QueryPerformanceFrequency(Frequency_countPerSec) result(is_supported_c) logical(c_bool) :: is_supported_c end function QueryPerformanceFrequency end interface +#endif !! cf. https://qiita.com/implicit_none/items/86c9117990798c1e8b3b contains +#if defined(_WIN32) || defined(_WIN64) +#else + function QueryPerformanceCounter(PerformanceCount) result(res) + use, intrinsic :: iso_c_binding + implicit none + integer(c_long_long), intent(inout) :: PerformanceCount + logical(c_bool):: res + PerformanceCount = 1 + res = .false. + + end function QueryPerformanceCounter + + + function QueryPerformanceFrequency(PerformanceCountPerSec) result(res) + use, intrinsic :: iso_c_binding + implicit none + integer(c_long_long), intent(inout) :: PerformanceCountPerSec + logical(c_bool) :: res + PerformanceCountPerSec = 1 + res = .false. + + end function QueryPerformanceFrequency +#endif + !> This subroutine is for timing purpose and starts a stopwatch. subroutine time_begin()