fdoc

functionsplit_words

type(string_t) function split_words(text) result(words)

The blank-separated words of text.

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)in

the text

Result

NameTypeAttributesDescription
wordstype(string_t)privateallocatabledimension(:)

Calls

Source

Show the code
function split_words(text) result(words)
    character(len=*), intent(in) :: text    !! the text
    type(string_t), allocatable :: words(:)
    integer :: i, j

    allocate (words(0))
    i = 1
    do
        j = verify(text(i:), WHITESPACE)
        if (j == 0) exit
        i = i + j - 1
        j = scan(text(i:), WHITESPACE)
        if (j == 0) then
            call push(words, text(i:))
            exit
        end if
        call push(words, text(i:i + j - 2))
        i = i + j
    end do
end function split_words

Graphs

Calls

Called by