The lines of text, each with its line ending (the last one may have none).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
the text |
function split_lines(text) result(lines) !! The lines of `text`, each with its line ending (the last one may have none). character(len=*), intent(in) :: text !! the text type(string_t), allocatable :: lines(:) integer :: i, j, n n = count([(text(i:i) == achar(10), i=1, len(text))]) if (len(text) > 0) then if (text(len(text):len(text)) /= achar(10)) n = n + 1 end if allocate (lines(n)) i = 1 do j = 1, n n = index(text(i:), achar(10)) if (n == 0) then lines(j)%s = text(i:) else lines(j)%s = text(i:i + n - 1) i = i + n end if end do end function split_lines