clip_head Function

private pure function clip_head(location) result(clipped)

Fit a location into MAX_LOCATION_LEN keeping its TAIL, marking any truncation with a leading TRUNCATION_MARKER.

Arguments

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

Return Value character(len=MAX_LOCATION_LEN)


Called by

proc~~clip_head~~CalledByGraph proc~clip_head clip_head proc~error_add_context error_t%error_add_context proc~error_add_context->proc~clip_head

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private :: first
integer(kind=default_int), private :: loc_len

Source Code

   pure function clip_head(location) result(clipped)
      !! Fit a location into MAX_LOCATION_LEN keeping its TAIL, marking any
      !! truncation with a leading TRUNCATION_MARKER.
      character(len=*), intent(in) :: location
      character(len=MAX_LOCATION_LEN) :: clipped
      integer(default_int) :: loc_len, first

      loc_len = int(len_trim(location), default_int)
      if (loc_len <= MAX_LOCATION_LEN) then
         clipped = location
      else
         first = loc_len - MAX_LOCATION_LEN + int(len(TRUNCATION_MARKER), default_int) + 1
         clipped = TRUNCATION_MARKER//location(first:loc_len)
      end if
   end function clip_head