read_stdin Subroutine

public subroutine read_stdin(text)

Uses

  • proc~~read_stdin~~UsesGraph proc~read_stdin read_stdin iso_fortran_env iso_fortran_env proc~read_stdin->iso_fortran_env module~ffmt_strings ffmt_strings proc~read_stdin->module~ffmt_strings

All of standard input. Lines are read as text, so each line ends with a line feed, except a last line without one; carriage returns of CRLF line endings are kept as part of the line.

Arguments

Type IntentOptional Attributes Name
character(len=:), intent(out), allocatable :: text

the input


Calls

proc~~read_stdin~~CallsGraph proc~read_stdin read_stdin proc~builder_append string_builder_t%builder_append proc~read_stdin->proc~builder_append proc~builder_get string_builder_t%builder_get proc~read_stdin->proc~builder_get

Called by

proc~~read_stdin~~CalledByGraph proc~read_stdin read_stdin proc~process_stdin process_stdin proc~process_stdin->proc~read_stdin proc~run run proc~run->proc~process_stdin

Source Code

subroutine read_stdin(text)
    !! All of standard input. Lines are read as text, so each line ends with a line feed, except a
    !! last line without one; carriage returns of CRLF line endings are kept as part of the line.
    use, intrinsic :: iso_fortran_env, only: input_unit
    use ffmt_strings, only: string_builder_t
    character(len=:), allocatable, intent(out) :: text      !! the input
    type(string_builder_t) :: buf
    character(len=4096) :: chunk
    integer :: ios, n

    do
        read (input_unit, '(a)', advance='no', iostat=ios, size=n) chunk
        call buf%append(chunk(1:n))
        if (is_iostat_eor(ios)) then
            call buf%append(achar(10))
        else if (ios /= 0) then
            exit                                ! end of input
        end if
    end do
    text = buf%get()
end subroutine read_stdin