@@ -748,6 +748,10 @@ pure function padr_string_default(string, output_length) result(res)
748
748
character (len= max (len (string), output_length)) :: char_output
749
749
type (string_type) :: res
750
750
751
+ ! We're taking advantage of `char_output` being longer than `string` and
752
+ ! initialized with whitespaces. By casting `string` to a `character`
753
+ ! type and back to `string_type`, we're effectively right-padding
754
+ ! `string` with spaces, so we don't need to pad explicitly.
751
755
char_output = char (string)
752
756
res = string_type(char_output)
753
757
@@ -792,8 +796,8 @@ pure function padr_char_pad_with(string, output_length, pad_with) result(res)
792
796
793
797
res = string
794
798
if (string_length < output_length) then
795
- res(string_length + 1 : output_length) = repeat (pad_with, &
796
- & output_length - string_length)
799
+ res(string_length + 1 : output_length) = &
800
+ repeat (pad_with, output_length - string_length)
797
801
end if
798
802
799
803
end function padr_char_pad_with
0 commit comments