fdoc

functionglob_matchesprivate

logical function glob_matches(pattern, path) result(matches)

True if path matches exclusion pattern, like Python's fnmatch: a * crosses /. A pattern that is not absolute may match the end of the path.

Arguments

NameTypeIntentAttributesDescription
patterncharacter(len=*)in

the pattern

pathcharacter(len=*)in

the path

Result

NameTypeAttributesDescription
matcheslogicalprivate

Calls

Source

Show the code
function glob_matches(pattern, path) result(matches)
    character(len=*), intent(in) :: pattern     !! the pattern
    character(len=*), intent(in) :: path        !! the path
    logical :: matches
    character(len=:), allocatable :: bare, re
    type(regex_t) :: compiled
    integer :: k

    bare = pattern
    if (starts_with(bare, '**/')) bare = bare(4:)
    re = '(.*/)?'
    do k = 1, len(bare)
        select case (bare(k:k))
        case ('*'); re = re//'.*'
        case ('?'); re = re//'.'
        case default; re = re//re_escape(bare(k:k))
        end select
    end do
    compiled = regex(re)
    matches = compiled%fullmatch(path)
end function glob_matches

Graphs

Calls

Called by