Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | a | |||
character(len=*), | intent(in) | :: | b |
pure function extract_same_part_suffix (a, b) result(res) use :: forgex_utf8_m implicit none character(*), intent(in) :: a, b character(:), allocatable :: res character(:), allocatable :: buf integer :: i, ii, n, diff, ie character(:), allocatable :: short_s, long_s res = '' buf = '' if (len(a) < len(b)) then short_s = a long_s = b else short_s = b long_s = a end if n = min(len(a), len(b)) diff = max(len(a), len(b)) - n do i = n, 1, -1 ii = i + diff if (short_s(i:i) == long_s(ii:ii)) then buf = a(i:i)//buf else exit end if end do n = len(buf) i= 1 do while (i <= n) ie = idxutf8(buf, i) if (n < ie) exit if (is_valid_multiple_byte_character(buf(i:ie))) then res = res//adjustl_multi_byte(buf(i:ie)) end if i = ie + 1 end do end function extract_same_part_suffix