subroutinefold_outputprivate
subroutine fold_output(c, text, out)
Fold the long lines of text that hold results of evaluation. Others stay as they are.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| c | type(fypp_t) | in | the state | |
| text | character(len=*) | in | the text | |
| out | character(len=:) | out | allocatable | the result |
Calls
Source
Show the code
subroutine fold_output(c, text, out)
type(fypp_t), intent(in) :: c !! the state
character(len=*), intent(in) :: text !! the text
character(len=:), allocatable, intent(out) :: out !! the result
type(buffer_t) :: b
integer :: k, done, first, last, found
done = 0
do k = 1, c%num_spans
if (c%spans(k)%first < done) cycle
found = index(text(done + 1:c%spans(k)%first), NL, back=.true.)
first = done + 1
if (found > 0) first = done + found + 1
found = index(text(c%spans(k)%last + 1:), NL)
last = merge(c%spans(k)%last + found, len(text), found > 0)
call add(b, text(done + 1:first - 1))
call fold_region(text(first:last), b)
done = last
end do
call add(b, text(done + 1:))
call take(b, out)
end subroutine fold_output