trim_or_default Function

public pure function trim_or_default(s, default) result(r)

Trim an allocatable string or return a default if empty/unallocated.

Arguments

Type IntentOptional Attributes Name
character(len=:), intent(in), allocatable :: s
character(len=*), intent(in) :: default

Return Value character(len=:), allocatable


Called by

proc~~trim_or_default~~CalledByGraph proc~trim_or_default trim_or_default proc~active_profile active_profile proc~active_profile->proc~trim_or_default proc~print_banner print_banner proc~print_banner->proc~trim_or_default proc~print_banner->proc~active_profile proc~rebuild_watch_list rebuild_watch_list proc~rebuild_watch_list->proc~print_banner proc~handle_manifest_change handle_manifest_change proc~handle_manifest_change->proc~rebuild_watch_list proc~watcher_init watcher_t%watcher_init proc~watcher_init->proc~rebuild_watch_list proc~watcher_run watcher_t%watcher_run proc~watcher_run->proc~rebuild_watch_list proc~watcher_run->proc~handle_manifest_change

Source Code

   pure function trim_or_default(s, default) result(r)
      character(len=:), allocatable, intent(in) :: s
      character(len=*), intent(in) :: default
      character(len=:), allocatable :: r
      if (allocated(s)) then
         if (len_trim(s) > 0) then
            r = trim(s)
         else
            r = default
         end if
      else
         r = default
      end if
   end function trim_or_default