@@ -995,12 +995,11 @@ contains
995
995
996
996
!> Joins a list of strings with a separator (default: space).
997
997
!> Returns a new string
998
- pure function join_string(strings, separator) result(cmd)
998
+ pure type(string_type) function join_string(strings, separator)
999
999
type(string_type), intent(in) :: strings(:)
1000
1000
character(len=*), intent(in), optional :: separator
1001
- type(string_type) :: cmd
1002
1001
integer :: ltot, i, lt, pos
1003
- character(len=:), allocatable :: sep,cmd_char
1002
+ character(len=:), allocatable :: sep,joined
1004
1003
! Determine separator: use user-provided separator or default space
1005
1004
if (present(separator)) then
1006
1005
sep = separator
@@ -1009,30 +1008,30 @@ contains
1009
1008
end if
1010
1009
! Calculate the total length required, including separators
1011
1010
ltot = sum(len_trim(strings)) + (size(strings) - 1) * len(sep)
1012
- allocate(character(len=ltot) :: cmd_char )
1011
+ allocate(character(len=ltot) :: joined )
1013
1012
1014
1013
! Concatenate strings with separator
1015
1014
pos = 0
1016
1015
do i = 1, size(strings)
1017
1016
lt = len_trim(strings(i))
1018
- cmd_char (pos+1:pos+lt) = char(strings(i),1,lt)
1017
+ joined (pos+1:pos+lt) = char(strings(i),1,lt)
1019
1018
pos = pos + lt
1020
1019
if (i < size(strings)) then
1021
- cmd_char (pos+1:pos+len(sep)) = sep
1020
+ joined (pos+1:pos+len(sep)) = sep
1022
1021
pos = pos + len(sep)
1023
1022
end if
1024
1023
end do
1025
1024
1026
- call move(from=cmd_char ,to=cmd )
1025
+ call move(from=joined ,to=join_string )
1027
1026
1028
1027
end function join_string
1029
1028
1030
1029
!> Joins a list of strings with a separator (default: space).
1031
1030
!> Returns a new string
1032
- pure function join_char(strings, separator) result(cmd )
1031
+ pure function join_char(strings, separator) result(joined )
1033
1032
character(*), intent(in) :: strings(:)
1034
1033
character(len=*), intent(in), optional :: separator
1035
- character(len=:), allocatable :: cmd
1034
+ character(len=:), allocatable :: joined
1036
1035
integer :: ltot, i, lt, pos
1037
1036
character(len=:), allocatable :: sep
1038
1037
! Determine separator: use user-provided separator or default space
@@ -1043,17 +1042,17 @@ contains
1043
1042
end if
1044
1043
! Calculate the total length required, including separators
1045
1044
ltot = sum(len_trim(strings)) + (size(strings) - 1) * len(sep)
1046
- allocate(character(len=ltot) :: cmd )
1045
+ allocate(character(len=ltot) :: joined )
1047
1046
1048
- cmd = repeat(' ',ltot)
1047
+ joined = repeat(' ',ltot)
1049
1048
! Concatenate strings with separator
1050
1049
pos = 0
1051
1050
do i = 1, size(strings)
1052
1051
lt = len_trim(strings(i))
1053
- cmd (pos+1:pos+lt) = strings(i)(1:lt)
1052
+ joined (pos+1:pos+lt) = strings(i)(1:lt)
1054
1053
pos = pos + lt
1055
1054
if (i < size(strings)) then
1056
- cmd (pos+1:pos+len(sep)) = sep
1055
+ joined (pos+1:pos+len(sep)) = sep
1057
1056
pos = pos + len(sep)
1058
1057
end if
1059
1058
end do
0 commit comments