subroutinelist_itemsprivate
subroutine list_items(block, items)
The items of a list chunk.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| block | character(len=*) | in | the chunk | |
| items | type(string_t) | out | allocatabledimension(:) | the items |
Calls
Source
Show the code
subroutine list_items(block, items)
character(len=*), intent(in) :: block !! the chunk
type(string_t), allocatable, intent(out) :: items(:) !! the items
type(string_t), allocatable :: lines(:)
integer :: k, at, spaces, n
lines = split_on(block, NL)
allocate (items(0))
do k = 1, size(lines)
associate (line => lines(k)%s)
at = item_text(line, .true., .true.)
n = size(items)
spaces = verify(line//'x', ' ') - 1
if (at > 0) then
call push(items, line(at:))
else if (spaces >= 4 .and. spaces <= 7 .and. item_text(line(5:), .true., .true.) > 0 .and. n > 0) then
if (starts_with(items(n)%s, ' ')) then
items(n)%s = items(n)%s//NL//line
else
call push(items, line)
end if
else if (n > 0) then
items(n)%s = items(n)%s//NL//line
end if
end associate
end do
end subroutine list_items