too_long Function

private pure function too_long(text, limit)

True if a code line of text may be longer than limit characters (see longest_code). A line has no more characters than bytes, so the scan is only needed when a line has more bytes than that, which finding the line breaks shows quickly.

Arguments

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

the formatted text

integer, intent(in) :: limit

the line length

Return Value logical


Calls

proc~~too_long~~CallsGraph proc~too_long too_long proc~longest_code longest_code proc~too_long->proc~longest_code

Called by

proc~~too_long~~CalledByGraph proc~too_long too_long proc~format_text format_text proc~format_text->proc~too_long 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 logical function too_long(text, limit)
    !! True if a code line of `text` may be longer than `limit` characters (see [[longest_code]]).
    !! A line has no more characters than bytes, so the scan is only needed when a line has more
    !! bytes than that, which finding the line breaks shows quickly.
    character(len=*), intent(in) :: text   !! the formatted text
    integer, intent(in) :: limit           !! the line length
    integer :: p, q
    too_long = .false.
    p = 1
    do while (p <= len(text))
        q = index(text(p:), achar(10))
        if (q == 0) q = len(text) - p + 2
        if (q - 1 > limit) then
            too_long = longest_code(text) > limit
            return
        end if
        p = p + q
    end do
end function too_long