Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/stdlib_strings.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,17 @@ contains

last = len(string)
nsub = len(substring)
if (nsub > 0) then
do while(string(last-nsub+1:last) == substring)
if (nsub > 0 .and. nsub <= last) then
do while(last >= nsub .and. string(last-nsub+1:last) == substring)
last = last - nsub
end do
end if

if (last <= 0) then
chomped_string = ''
return
end if

chomped_string = string(1:last)

end function chomp_substring_char_char
Expand Down
Loading