subroutinefind_hash_headerpureprivate
pure subroutine find_hash_header(block, at, stop_at)
Find the first # header line of block.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| block | character(len=*) | in | the chunk | |
| at | integer | out | where it starts, or 0 | |
| stop_at | integer | out | where it ends, before its line feed |
Source
Show the code
pure subroutine find_hash_header(block, at, stop_at)
character(len=*), intent(in) :: block !! the chunk
integer, intent(out) :: at !! where it starts, or 0
integer, intent(out) :: stop_at !! where it ends, before its line feed
integer :: i, j
at = 0
stop_at = 0
i = 1
do while (i <= len(block))
if (block(i:i) == '#') then
at = i
j = index(block(i:), NL)
stop_at = merge(len(block), i + j - 2, j == 0)
return
end if
j = index(block(i:), NL)
if (j == 0) return
i = i + j
end do
end subroutine find_hash_header