to_case Function

private pure function to_case(text, upper) result(t)

text in ASCII upper or lower case.

Arguments

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

the text to convert

logical, intent(in) :: upper

true for upper case, false for lower case

Return Value character(len=len)


Called by

proc~~to_case~~CalledByGraph proc~to_case to_case proc~emit_body emit_body proc~emit_body->proc~to_case proc~emit_continuation emit_continuation proc~emit_continuation->proc~emit_body proc~emit_statement emit_statement proc~emit_statement->proc~emit_body proc~emit_statement->proc~emit_continuation proc~layout layout proc~layout->proc~emit_statement proc~format_pass format_pass proc~format_pass->proc~layout proc~format_text format_text proc~format_text->proc~format_pass proc~relayout relayout proc~format_text->proc~relayout proc~relayout->proc~format_pass 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 function to_case(text, upper) result(t)
    !! `text` in ASCII upper or lower case.
    character(len=*), intent(in) :: text   !! the text to convert
    logical, intent(in) :: upper           !! true for upper case, false for lower case
    character(len=len(text)) :: t
    integer :: k, c
    t = text
    do k = 1, len(t)
        c = iachar(t(k:k))
        if (upper .and. c >= iachar('a') .and. c <= iachar('z')) t(k:k) = achar(c - 32)
        if (.not. upper .and. c >= iachar('A') .and. c <= iachar('Z')) t(k:k) = achar(c + 32)
    end do
end function to_case