From 65ab05d7ffb476996e44a2a0d264c53f10930294 Mon Sep 17 00:00:00 2001 From: Aman-Godara Date: Sun, 27 Jun 2021 16:58:53 +0530 Subject: [PATCH] improved aesthetics to make code consistent with stdlib's format --- src/stdlib_strings.fypp | 15 +++++++------- src/stdlib_strings_format_string.fypp | 28 +++++++++++++++------------ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/stdlib_strings.fypp b/src/stdlib_strings.fypp index 6432d45df..e9bd7a1db 100644 --- a/src/stdlib_strings.fypp +++ b/src/stdlib_strings.fypp @@ -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 diff --git a/src/stdlib_strings_format_string.fypp b/src/stdlib_strings_format_string.fypp index 5486acfbe..702ad9fe5 100644 --- a/src/stdlib_strings_format_string.fypp +++ b/src/stdlib_strings_format_string.fypp @@ -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 @@ -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