fdoc

functionbracket_endpureprivate

pure integer function bracket_end(text, i)

The end of the [...] that opens at i, or 0.

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)in

the text

iintegerin

where it opens

Result

NameTypeAttributesDescription
bracket_endinteger

Source

Show the code
pure integer function bracket_end(text, i)
    character(len=*), intent(in) :: text    !! the text
    integer, intent(in) :: i                !! where it opens
    integer :: k, depth

    bracket_end = 0
    depth = 0
    k = i
    do while (k <= len(text))
        select case (text(k:k))
        case ('\')
            k = k + 1
        case ('[')
            depth = depth + 1
        case (']')
            depth = depth - 1
            if (depth == 0) then
                bracket_end = k
                return
            end if
        end select
        k = k + 1
    end do
end function bracket_end

Graphs

Called by