We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ae8398c commit 5085ac5Copy full SHA for 5085ac5
src/stdlib_strings.fypp
@@ -302,11 +302,17 @@ contains
302
303
last = len(string)
304
nsub = len(substring)
305
- if (nsub > 0) then
306
- 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)
307
last = last - nsub
308
end do
309
end if
310
+
311
+ if (last <= 0) then
312
+ chomped_string = ''
313
+ return
314
+ end if
315
316
chomped_string = string(1:last)
317
318
end function chomp_substring_char_char
0 commit comments