Skip to content

Commit 65ab05d

Browse files
committed
improved aesthetics to make code consistent with stdlib's format
1 parent e7ce1e7 commit 65ab05d

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

src/stdlib_strings.fypp

+8-7
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@ module stdlib_strings
1818
public :: starts_with, ends_with
1919
public :: slice, find
2020

21+
!> Format other types as character sequence.
22+
!> ([Specification](../page/specs/stdlib_strings.html#description))
23+
!> version: experimental
2124
interface format_string
22-
!! version: experimental
23-
!!
24-
!! Format other types as character sequence.
25-
!! ([Specification](../page/specs/stdlib_strings.html#description))
2625
#:for kind, type in KINDS_TYPES
27-
pure module function format_string_${type[0]}$${kind}$(val, fmt) result(string)
28-
character(len=:), allocatable :: string
26+
!> Format ${type}$ variable as character sequence
27+
pure module function format_string_${type[0]}$_${kind}$(val, fmt) result(string)
2928
${type}$, intent(in) :: val
3029
character(len=*), intent(in), optional :: fmt
31-
end function format_string_${type[0]}$${kind}$
30+
character(len=:), allocatable :: string
31+
end function format_string_${type[0]}$_${kind}$
32+
3233
#:endfor
3334
end interface format_string
3435

src/stdlib_strings_format_string.fypp

+16-12
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ submodule (stdlib_strings) stdlib_strings_format_string
77

88
contains
99

10-
#:for kind, type in RIL_KINDS_TYPES
11-
module procedure format_string_${type[0]}$${kind}$
12-
!! Format ${type}$ variable as character sequence
10+
11+
#:for kind, type in RIL_KINDS_TYPES
12+
!> Format ${type}$ variable as character sequence
13+
module procedure format_string_${type[0]}$_${kind}$
14+
1315
character(len=buffer_len) :: buffer
1416
integer :: stat
1517

@@ -21,17 +23,19 @@ contains
2123
!!\TODO: *?
2224
end if
2325

24-
end procedure format_string_${type[0]}$${kind}$
25-
#:endfor
26+
end procedure format_string_${type[0]}$_${kind}$
27+
28+
#:endfor
29+
30+
#:for kind, type in CMPLX_KINDS_TYPES
31+
!> Format ${type}$ variable as character sequence
32+
module procedure format_string_${type[0]}$_${kind}$
2633

27-
#:for kind, type in CMPLX_KINDS_TYPES
28-
module procedure format_string_${type[0]}$${kind}$
29-
!! Format ${type}$ variable as character sequence
34+
string = '(' // format_string_r_${kind}$(val%re, fmt) // ',' // &
35+
& format_string_r_${kind}$(val%im, fmt) // ')'
3036

31-
string = '('//format_string_r${kind}$(val%re, fmt)//','// &
32-
format_string_r${kind}$(val%im, fmt)//')'
37+
end procedure format_string_${type[0]}$_${kind}$
3338

34-
end procedure format_string_${type[0]}$${kind}$
35-
#:endfor
39+
#:endfor
3640

3741
end submodule stdlib_strings_format_string

0 commit comments

Comments
 (0)