longest_line Function

private pure function longest_line(text) result(width)

Width of the longest line of text, in characters (as utf8_width counts them).

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: text

text whose lines end with LF

Return Value integer


Called by

proc~~longest_line~~CalledByGraph proc~longest_line longest_line proc~limit_diagnostics limit_diagnostics proc~limit_diagnostics->proc~longest_line proc~format_text format_text proc~format_text->proc~limit_diagnostics proc~process_text process_text proc~process_text->proc~format_text proc~process_file process_file proc~process_file->proc~process_text proc~process_stdin process_stdin proc~process_stdin->proc~process_text proc~run run proc~run->proc~process_file proc~run->proc~process_stdin

Source Code

pure integer function longest_line(text) result(width)
    !! Width of the longest line of `text`, in characters (as [[utf8_width]] counts them).
    character(len=*), intent(in) :: text   !! text whose lines end with LF
    integer :: k, c, w
    width = 0
    w = 0
    do k = 1, len(text)
        c = iand(ichar(text(k:k)), 255)
        if (c == 10) then
            w = 0
        else if (c < 128 .or. c >= 192) then
            w = w + 1
            width = max(width, w)
        end if
    end do
end function longest_line