From 57b5636f5f573f06326fdecd24057a6297a53501 Mon Sep 17 00:00:00 2001 From: Joel <5474278+noisegul@users.noreply.github.com> Date: Sat, 12 Feb 2022 13:33:36 +0100 Subject: Ignore hidden source files (#654) * Add str_begins_with_str function * Add function to test if a single file is hidden * Exclude hidden files when finding source files --- src/fpm_strings.f90 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/fpm_strings.f90') diff --git a/src/fpm_strings.f90 b/src/fpm_strings.f90 index 4650ebd..aceb01a 100644 --- a/src/fpm_strings.f90 +++ b/src/fpm_strings.f90 @@ -39,7 +39,7 @@ use iso_c_binding, only: c_char, c_ptr, c_int, c_null_char, c_associated, c_f_po implicit none private -public :: f_string, lower, split, str_ends_with, string_t +public :: f_string, lower, split, str_ends_with, string_t, str_begins_with_str public :: to_fortran_name, is_fortran_name public :: string_array_contains, string_cat, len_trim, operator(.in.), fnv_1a public :: replace, resize, str, join, glob @@ -115,6 +115,19 @@ pure logical function str_ends_with_any(s, e) result(r) end function str_ends_with_any +!> test if a CHARACTER string begins with a specified prefix +pure logical function str_begins_with_str(s, e) result(r) + character(*), intent(in) :: s, e + integer :: n1, n2 + n1 = 1 + n2 = 1 + len(e)-1 + if (n2 > len(s)) then + r = .false. + else + r = (s(n1:n2) == e) + end if +end function str_begins_with_str + !> return Fortran character variable when given a C-like array of !! single characters terminated with a C_NULL_CHAR character function f_string(c_string) -- cgit v1.2.3