Skip to content

Commit

Permalink
improved aesthetics to make code consistent with stdlib's format
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-godara committed Jun 27, 2021
1 parent e7ce1e7 commit 65ab05d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
15 changes: 8 additions & 7 deletions src/stdlib_strings.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ module stdlib_strings
public :: starts_with, ends_with
public :: slice, find

!> Format other types as character sequence.
!> ([Specification](../page/specs/stdlib_strings.html#description))
!> version: experimental
interface format_string
!! version: experimental
!!
!! Format other types as character sequence.
!! ([Specification](../page/specs/stdlib_strings.html#description))
#:for kind, type in KINDS_TYPES
pure module function format_string_${type[0]}$${kind}$(val, fmt) result(string)
character(len=:), allocatable :: string
!> Format ${type}$ variable as character sequence
pure module function format_string_${type[0]}$_${kind}$(val, fmt) result(string)
${type}$, intent(in) :: val
character(len=*), intent(in), optional :: fmt
end function format_string_${type[0]}$${kind}$
character(len=:), allocatable :: string
end function format_string_${type[0]}$_${kind}$

#:endfor
end interface format_string

Expand Down
28 changes: 16 additions & 12 deletions src/stdlib_strings_format_string.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ submodule (stdlib_strings) stdlib_strings_format_string

contains

#:for kind, type in RIL_KINDS_TYPES
module procedure format_string_${type[0]}$${kind}$
!! Format ${type}$ variable as character sequence

#:for kind, type in RIL_KINDS_TYPES
!> Format ${type}$ variable as character sequence
module procedure format_string_${type[0]}$_${kind}$

character(len=buffer_len) :: buffer
integer :: stat

Expand All @@ -21,17 +23,19 @@ contains
!!\TODO: *?
end if

end procedure format_string_${type[0]}$${kind}$
#:endfor
end procedure format_string_${type[0]}$_${kind}$

#:endfor

#:for kind, type in CMPLX_KINDS_TYPES
!> Format ${type}$ variable as character sequence
module procedure format_string_${type[0]}$_${kind}$

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

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

end procedure format_string_${type[0]}$${kind}$
#:endfor
#:endfor

end submodule stdlib_strings_format_string

0 comments on commit 65ab05d

Please sign in to comment.