fdoc

subroutinepreprocessprivate

subroutine preprocess(s, path, text)

Replace text by the output of the preprocessor for path, or keep it if that fails.

Arguments

NameTypeIntentAttributesDescription
stype(settings_t)in

the settings

pathcharacter(len=*)in

the file

textcharacter(len=:)inoutallocatable

the text

Calls

Source

Show the code
subroutine preprocess(s, path, text)
    type(settings_t), intent(in) :: s                   !! the settings
    character(len=*), intent(in) :: path                !! the file
    character(len=:), allocatable, intent(inout) :: text  !! the text
    character(len=:), allocatable :: output, errors, command, directory, result, msg
    character(len=32) :: tag
    integer :: exit_code, stat

    call temporary_directory(directory)
    call unique_tag(tag)
    output = join_path(directory, 'fdoc-'//trim(tag)//'.out')
    errors = join_path(directory, 'fdoc-'//trim(tag)//'.err')
    command = preprocessor_command(s, path)
    call run_command(command//' > '//quoted_path(output)//' 2> '//quoted_path(errors), exit_code)
    if (exit_code == 0) then
        call read_whole_file(output, result, stat, msg)
        if (stat == 0) call move_alloc(result, text)
    else
        call warn('preprocessing failed, reverting to the file itself: '//command)
    end if
    call remove_file(output)
    call remove_file(errors)
end subroutine preprocess

Graphs

Calls

Called by