functionbracket_endpureprivate
pure integer function bracket_end(text, i)
The end of the [...] that opens at i, or 0.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| text | character(len=*) | in | the text | |
| i | integer | in | where it opens |
Result
| Name | Type | Attributes | Description |
|---|---|---|---|
| bracket_end | integer |
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