Skip to content

Commit 1351a61

Browse files
committed
change result name to joined
1 parent f269996 commit 1351a61

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/stdlib_strings.fypp

+12-13
Original file line numberDiff line numberDiff line change
@@ -995,12 +995,11 @@ contains
995995

996996
!> Joins a list of strings with a separator (default: space).
997997
!> Returns a new string
998-
pure function join_string(strings, separator) result(cmd)
998+
pure type(string_type) function join_string(strings, separator)
999999
type(string_type), intent(in) :: strings(:)
10001000
character(len=*), intent(in), optional :: separator
1001-
type(string_type) :: cmd
10021001
integer :: ltot, i, lt, pos
1003-
character(len=:), allocatable :: sep,cmd_char
1002+
character(len=:), allocatable :: sep,joined
10041003
! Determine separator: use user-provided separator or default space
10051004
if (present(separator)) then
10061005
sep = separator
@@ -1009,30 +1008,30 @@ contains
10091008
end if
10101009
! Calculate the total length required, including separators
10111010
ltot = sum(len_trim(strings)) + (size(strings) - 1) * len(sep)
1012-
allocate(character(len=ltot) :: cmd_char)
1011+
allocate(character(len=ltot) :: joined)
10131012

10141013
! Concatenate strings with separator
10151014
pos = 0
10161015
do i = 1, size(strings)
10171016
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)
10191018
pos = pos + lt
10201019
if (i < size(strings)) then
1021-
cmd_char(pos+1:pos+len(sep)) = sep
1020+
joined(pos+1:pos+len(sep)) = sep
10221021
pos = pos + len(sep)
10231022
end if
10241023
end do
10251024

1026-
call move(from=cmd_char,to=cmd)
1025+
call move(from=joined,to=join_string)
10271026

10281027
end function join_string
10291028

10301029
!> Joins a list of strings with a separator (default: space).
10311030
!> Returns a new string
1032-
pure function join_char(strings, separator) result(cmd)
1031+
pure function join_char(strings, separator) result(joined)
10331032
character(*), intent(in) :: strings(:)
10341033
character(len=*), intent(in), optional :: separator
1035-
character(len=:), allocatable :: cmd
1034+
character(len=:), allocatable :: joined
10361035
integer :: ltot, i, lt, pos
10371036
character(len=:), allocatable :: sep
10381037
! Determine separator: use user-provided separator or default space
@@ -1043,17 +1042,17 @@ contains
10431042
end if
10441043
! Calculate the total length required, including separators
10451044
ltot = sum(len_trim(strings)) + (size(strings) - 1) * len(sep)
1046-
allocate(character(len=ltot) :: cmd)
1045+
allocate(character(len=ltot) :: joined)
10471046

1048-
cmd = repeat(' ',ltot)
1047+
joined = repeat(' ',ltot)
10491048
! Concatenate strings with separator
10501049
pos = 0
10511050
do i = 1, size(strings)
10521051
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)
10541053
pos = pos + lt
10551054
if (i < size(strings)) then
1056-
cmd(pos+1:pos+len(sep)) = sep
1055+
joined(pos+1:pos+len(sep)) = sep
10571056
pos = pos + len(sep)
10581057
end if
10591058
end do

0 commit comments

Comments
 (0)