From 1546ef34404baa8d01144be811f03651b170d4a4 Mon Sep 17 00:00:00 2001 From: Godara-aman Date: Sun, 14 Mar 2021 17:48:42 +0530 Subject: [PATCH 01/12] added interface for to_lower, to_upper, to_title, reverse functions --- src/stdlib_ascii.f90 | 30 ++++++++++++++++ src/stdlib_string_type.f90 | 70 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 98 insertions(+), 2 deletions(-) diff --git a/src/stdlib_ascii.f90 b/src/stdlib_ascii.f90 index a9111888a..1dc0cdc4f 100644 --- a/src/stdlib_ascii.f90 +++ b/src/stdlib_ascii.f90 @@ -64,6 +64,36 @@ module stdlib_ascii character(len=*), public, parameter :: lowercase = letters(27:) !! a .. z character(len=*), public, parameter :: whitespace = " "//TAB//VT//CR//LF//FF !! ASCII _whitespace + + !> Convert character variable to lower case + !> + !> This method is pure and returns a character sequence + interface to_lower + module procedure :: to_lower + end interface to_lower + + !> Convert character variable to upper case + !> + !> This method is pure and returns a character sequence + interface to_upper + module procedure :: to_upper + end interface to_upper + + !> Convert character variable to title case + !> + !> This method is pure and returns a character sequence + interface to_title + module procedure :: to_title + end interface to_title + + !> Reverse the character order in the input character variable + !> + !> This method is pure and returns a character sequence + interface reverse + module procedure :: reverse + end interface reverse + + contains !> Checks whether `c` is an ASCII letter (A .. Z, a .. z). diff --git a/src/stdlib_string_type.f90 b/src/stdlib_string_type.f90 index ebc5f1485..8eabc6b69 100644 --- a/src/stdlib_string_type.f90 +++ b/src/stdlib_string_type.f90 @@ -12,11 +12,13 @@ !> !> The specification of this module is available [here](../page/specs/stdlib_string_type.html). module stdlib_string_type + use stdlib_ascii, only: to_lower, to_upper, to_title, reverse + implicit none private - + public :: string_type - public :: len, len_trim, trim, index, scan, verify, repeat, adjustr, adjustl + public :: len, len_trim, trim, index, scan, verify, repeat, adjustr, adjustl, to_lower, to_upper, to_title, reverse public :: lgt, lge, llt, lle, char, ichar, iachar public :: assignment(=) public :: operator(>), operator(>=), operator(<), operator(<=) @@ -89,6 +91,34 @@ module stdlib_string_type module procedure :: repeat_string end interface repeat + !> + !> + !> + interface to_lower + module procedure :: to_lower_string + end interface to_lower + + !> + !> + !> + interface to_upper + module procedure :: to_upper_string + end interface to_upper + + !> + !> + !> + interface to_title + module procedure :: to_title_string + end interface to_title + + !> + !> + !> + interface reverse + module procedure :: reverse_string + end interface reverse + !> Return the character sequence represented by the string. !> !> This method is elemental and returns a scalar character value. @@ -447,6 +477,42 @@ elemental function repeat_string(string, ncopies) result(repeated_string) end function repeat_string + elemental function to_lower_string(string) result(lowered_string) + type(string_type), intent(in) :: string + type(string_type) :: lowered_string + + lowered_string%raw = to_lower(string%raw) + + end function to_lower_string + + + elemental function to_upper_string(string) result(uppered_string) + type(string_type), intent(in) :: string + type(string_type) :: uppered_string + + uppered_string%raw = to_upper(string%raw) + + end function to_upper_string + + + elemental function to_title_string(string) result(titled_string) + type(string_type), intent(in) :: string + type(string_type) :: titled_string + + titled_string%raw = to_title(string%raw) + + end function to_title_string + + + elemental function reverse_string(string) result(reversed_string) + type(string_type), intent(in) :: string + type(string_type) :: reversed_string + + reversed_string%raw = reverse(string%raw) + + end function reverse_string + + !> Position of a sequence of character within a character sequence. !> In this version both character sequences are represented by a string. elemental function index_string_string(string, substring, back) result(pos) From 30ea5af56e6b11de940bf5595273006643eedbf4 Mon Sep 17 00:00:00 2001 From: Aman Godara Date: Mon, 15 Mar 2021 11:51:03 +0530 Subject: [PATCH 02/12] added better comments to the stdlib_ascii.f90 --- src/stdlib_ascii.f90 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/stdlib_ascii.f90 b/src/stdlib_ascii.f90 index 1dc0cdc4f..d797d33b1 100644 --- a/src/stdlib_ascii.f90 +++ b/src/stdlib_ascii.f90 @@ -65,29 +65,29 @@ module stdlib_ascii character(len=*), public, parameter :: whitespace = " "//TAB//VT//CR//LF//FF !! ASCII _whitespace - !> Convert character variable to lower case - !> + !> Returns a new character sequence which is the lower case + !> version of the input character sequence !> This method is pure and returns a character sequence interface to_lower module procedure :: to_lower end interface to_lower - !> Convert character variable to upper case - !> + !> Returns a new character sequence which is the upper case + !> version of the input character sequence !> This method is pure and returns a character sequence interface to_upper module procedure :: to_upper end interface to_upper - !> Convert character variable to title case - !> + !> Returns a new character sequence which is the titled + !> version of the input character sequence !> This method is pure and returns a character sequence interface to_title module procedure :: to_title end interface to_title - !> Reverse the character order in the input character variable - !> + !> Returns a new character sequence which is the reversed + !> version of the input charater sequence !> This method is pure and returns a character sequence interface reverse module procedure :: reverse From 4d3cd0d5569135dc4e8b3e3ce1c0876df486268b Mon Sep 17 00:00:00 2001 From: Aman Godara Date: Mon, 15 Mar 2021 12:05:31 +0530 Subject: [PATCH 03/12] added comments to stdlib_string_type.f90. function is elemental or pure (query)?? --- src/stdlib_string_type.f90 | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/stdlib_string_type.f90 b/src/stdlib_string_type.f90 index 8eabc6b69..5e842a285 100644 --- a/src/stdlib_string_type.f90 +++ b/src/stdlib_string_type.f90 @@ -91,30 +91,30 @@ module stdlib_string_type module procedure :: repeat_string end interface repeat - !> - !> + !> Convert the character sequence hold by the input string to lower case !> + !> Elemental or pure ???? Does not return anything interface to_lower module procedure :: to_lower_string end interface to_lower + !> Convert the character sequence hold by the input string to upper case !> - !> - !> + !> Elemental or pure ???? Does not return anything interface to_upper module procedure :: to_upper_string end interface to_upper + !> Convert the character sequence hold by the input string to title case !> - !> - !> + !> Elemental or pure ???? Does not return anything interface to_title module procedure :: to_title_string end interface to_title - !> - !> - !> + !> Reverse the character sequence hold by the input string + !> + !> Elemental or pure ???? Does not return anything interface reverse module procedure :: reverse_string end interface reverse @@ -477,6 +477,7 @@ elemental function repeat_string(string, ncopies) result(repeated_string) end function repeat_string + !> Convert the character sequence hold by the input string to lower case elemental function to_lower_string(string) result(lowered_string) type(string_type), intent(in) :: string type(string_type) :: lowered_string @@ -486,6 +487,7 @@ elemental function to_lower_string(string) result(lowered_string) end function to_lower_string + !> Convert the character sequence hold by the input string to upper case elemental function to_upper_string(string) result(uppered_string) type(string_type), intent(in) :: string type(string_type) :: uppered_string @@ -495,6 +497,7 @@ elemental function to_upper_string(string) result(uppered_string) end function to_upper_string + !> Convert the character sequence hold by the input string to title case elemental function to_title_string(string) result(titled_string) type(string_type), intent(in) :: string type(string_type) :: titled_string @@ -504,6 +507,7 @@ elemental function to_title_string(string) result(titled_string) end function to_title_string + !> Reverse the character sequence hold by the input string elemental function reverse_string(string) result(reversed_string) type(string_type), intent(in) :: string type(string_type) :: reversed_string From 6dde4d6414f0ee7ea7bc61a65c9292c8f4da7fa2 Mon Sep 17 00:00:00 2001 From: Aman Godara Date: Mon, 15 Mar 2021 12:09:07 +0530 Subject: [PATCH 04/12] improved line spacing; nothing special in this commit --- src/stdlib_string_type.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stdlib_string_type.f90 b/src/stdlib_string_type.f90 index 5e842a285..a496cf85e 100644 --- a/src/stdlib_string_type.f90 +++ b/src/stdlib_string_type.f90 @@ -16,7 +16,7 @@ module stdlib_string_type implicit none private - + public :: string_type public :: len, len_trim, trim, index, scan, verify, repeat, adjustr, adjustl, to_lower, to_upper, to_title, reverse public :: lgt, lge, llt, lle, char, ichar, iachar From 2dd965d6d266d1c78ae2b5a9e25ed225bca0122e Mon Sep 17 00:00:00 2001 From: Aman Godara <34789087+Aman-Godara@users.noreply.github.com> Date: Mon, 15 Mar 2021 17:18:24 +0530 Subject: [PATCH 05/12] cleaning namespace and using the maybe Note: here how using maybe(string) automatically access the string%raw. maybe is used for safe memory access. Co-authored-by: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> --- src/stdlib_string_type.f90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/stdlib_string_type.f90 b/src/stdlib_string_type.f90 index a496cf85e..067526987 100644 --- a/src/stdlib_string_type.f90 +++ b/src/stdlib_string_type.f90 @@ -12,7 +12,7 @@ !> !> The specification of this module is available [here](../page/specs/stdlib_string_type.html). module stdlib_string_type - use stdlib_ascii, only: to_lower, to_upper, to_title, reverse + use stdlib_ascii, only: to_lower_ => to_lower, to_upper_ => to_upper, to_title_ => to_title, reverse_ => reverse implicit none private @@ -482,7 +482,7 @@ elemental function to_lower_string(string) result(lowered_string) type(string_type), intent(in) :: string type(string_type) :: lowered_string - lowered_string%raw = to_lower(string%raw) + lowered_string%raw = to_lower_(maybe(string)) end function to_lower_string @@ -492,7 +492,7 @@ elemental function to_upper_string(string) result(uppered_string) type(string_type), intent(in) :: string type(string_type) :: uppered_string - uppered_string%raw = to_upper(string%raw) + uppered_string%raw = to_upper_(maybe(string)) end function to_upper_string @@ -502,7 +502,7 @@ elemental function to_title_string(string) result(titled_string) type(string_type), intent(in) :: string type(string_type) :: titled_string - titled_string%raw = to_title(string%raw) + titled_string%raw = to_title_(maybe(string)) end function to_title_string @@ -512,7 +512,7 @@ elemental function reverse_string(string) result(reversed_string) type(string_type), intent(in) :: string type(string_type) :: reversed_string - reversed_string%raw = reverse(string%raw) + reversed_string%raw = reverse_(maybe(string)) end function reverse_string From 692d13b64416803ffdc7e790375e62c0f861971f Mon Sep 17 00:00:00 2001 From: milancurcic Date: Mon, 15 Mar 2021 13:11:37 -0400 Subject: [PATCH 06/12] stay within 80 characters line length --- src/stdlib_string_type.f90 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/stdlib_string_type.f90 b/src/stdlib_string_type.f90 index 067526987..106f370ba 100644 --- a/src/stdlib_string_type.f90 +++ b/src/stdlib_string_type.f90 @@ -12,13 +12,15 @@ !> !> The specification of this module is available [here](../page/specs/stdlib_string_type.html). module stdlib_string_type - use stdlib_ascii, only: to_lower_ => to_lower, to_upper_ => to_upper, to_title_ => to_title, reverse_ => reverse + use stdlib_ascii, only: to_lower_ => to_lower, to_upper_ => to_upper, & + to_title_ => to_title, reverse_ => reverse implicit none private public :: string_type - public :: len, len_trim, trim, index, scan, verify, repeat, adjustr, adjustl, to_lower, to_upper, to_title, reverse + public :: len, len_trim, trim, index, scan, verify, repeat, adjustr, & + adjustl, to_lower, to_upper, to_title, reverse public :: lgt, lge, llt, lle, char, ichar, iachar public :: assignment(=) public :: operator(>), operator(>=), operator(<), operator(<=) From fbde735625a6c556a440dc90f358606d15463390 Mon Sep 17 00:00:00 2001 From: milancurcic Date: Mon, 15 Mar 2021 13:14:23 -0400 Subject: [PATCH 07/12] fix result variable names --- src/stdlib_string_type.f90 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/stdlib_string_type.f90 b/src/stdlib_string_type.f90 index 106f370ba..f98376e07 100644 --- a/src/stdlib_string_type.f90 +++ b/src/stdlib_string_type.f90 @@ -480,31 +480,31 @@ end function repeat_string !> Convert the character sequence hold by the input string to lower case - elemental function to_lower_string(string) result(lowered_string) + elemental function to_lower_string(string) result(lowercase_string) type(string_type), intent(in) :: string - type(string_type) :: lowered_string + type(string_type) :: lowercase_string - lowered_string%raw = to_lower_(maybe(string)) + lowercase_string%raw = to_lower_(maybe(string)) end function to_lower_string !> Convert the character sequence hold by the input string to upper case - elemental function to_upper_string(string) result(uppered_string) + elemental function to_upper_string(string) result(uppercase_string) type(string_type), intent(in) :: string - type(string_type) :: uppered_string + type(string_type) :: uppercase_string - uppered_string%raw = to_upper_(maybe(string)) + uppercase_string%raw = to_upper_(maybe(string)) end function to_upper_string !> Convert the character sequence hold by the input string to title case - elemental function to_title_string(string) result(titled_string) + elemental function to_title_string(string) result(titlecase_string) type(string_type), intent(in) :: string - type(string_type) :: titled_string + type(string_type) :: titlecase_string - titled_string%raw = to_title_(maybe(string)) + titlecase_string%raw = to_title_(maybe(string)) end function to_title_string From 9f82abbf5098fc9fa31af8e1efee5b813683a1b6 Mon Sep 17 00:00:00 2001 From: Aman Godara Date: Thu, 18 Mar 2021 22:59:47 +0530 Subject: [PATCH 08/12] added dependency of modules in Makefile.manual, updated comments, fixed typo in README.md --- README.md | 2 +- src/Makefile.manual | 1 + src/stdlib_string_type.f90 | 12 ++++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d82cf2897..5873bbd57 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ To test your build, run the test suite after the build has finished with cmake --build build --target test ``` -Please report failing tests on our [issue tracker](https://github.com/fortran-lang/stdlib/issues/new/choose) including details on the compiler used, the operating system and platform architecture. +Please report failing tests on our [issue tracker](https://github.com/fortran-lang/stdlib/issues/new/choose) including details of the compiler used, the operating system and platform architecture. To install the project to the declared prefix run diff --git a/src/Makefile.manual b/src/Makefile.manual index 804b04272..b59340b8c 100644 --- a/src/Makefile.manual +++ b/src/Makefile.manual @@ -109,3 +109,4 @@ stdlib_stats_var.o: \ stdlib_stats_distribution_PRNG.o: \ stdlib_kinds.o \ stdlib_error.o +stdlib_string_type.o: stdlib_ascii.o \ No newline at end of file diff --git a/src/stdlib_string_type.f90 b/src/stdlib_string_type.f90 index f98376e07..ba1e7d523 100644 --- a/src/stdlib_string_type.f90 +++ b/src/stdlib_string_type.f90 @@ -95,28 +95,32 @@ module stdlib_string_type !> Convert the character sequence hold by the input string to lower case !> - !> Elemental or pure ???? Does not return anything + !> This method is Elemental and returns a new string_type instance which holds lowercase + !> version of the character sequence hold by the input string interface to_lower module procedure :: to_lower_string end interface to_lower !> Convert the character sequence hold by the input string to upper case !> - !> Elemental or pure ???? Does not return anything + !> This method is Elemental and returns a new string_type instance which holds uppercase + !> version of the character sequence hold by the input string interface to_upper module procedure :: to_upper_string end interface to_upper !> Convert the character sequence hold by the input string to title case !> - !> Elemental or pure ???? Does not return anything + !> This method is Elemental and returns a new string_type instance which holds titlecase + !> version of the character sequence hold by the input string interface to_title module procedure :: to_title_string end interface to_title !> Reverse the character sequence hold by the input string !> - !> Elemental or pure ???? Does not return anything + !> This method is Elemental and returns a new string_type instance which holds reversed + !> sequence of the character sequence hold by the input string interface reverse module procedure :: reverse_string end interface reverse From f36f0c1ca89111d3726c9aa7d37e3630f910a57f Mon Sep 17 00:00:00 2001 From: Aman Godara Date: Fri, 19 Mar 2021 01:16:21 +0530 Subject: [PATCH 09/12] adding unit tests for to_lower, to_upper, reverse, to_title functions of stdlib_string_type module --- src/tests/string/test_string_functions.f90 | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/tests/string/test_string_functions.f90 diff --git a/src/tests/string/test_string_functions.f90 b/src/tests/string/test_string_functions.f90 new file mode 100644 index 000000000..7adeffa17 --- /dev/null +++ b/src/tests/string/test_string_functions.f90 @@ -0,0 +1,58 @@ +! SPDX-Identifier: MIT +module test_string_functions + use stdlib_error, only : check + use stdlib_string_type, only : string_type, assignment(=), operator(==), & + to_lower, to_upper, to_title, reverse + implicit none + +contains + + subroutine test_to_lower_string + type(string_type) :: test_string, compare_string + test_string = "To_LoWEr !$%-az09AZ" + compare_string = "to_lower !$%-az09az" + + call check(to_lower(test_string) == compare_string) + + end subroutine test_to_lower_string + + subroutine test_to_upper_string + type(string_type) :: test_string, compare_string + test_string = "To_UpPeR !$%-az09AZ" + compare_string = "TO_UPPER !$%-AZ09AZ" + + call check(to_upper(test_string) == compare_string) + + end subroutine test_to_upper_string + + subroutine test_to_title_string + type(string_type) :: test_string, compare_string + test_string = "_#To tiTlE !$%-az09AZ" + compare_string = "_#To title !$%-a09az" + + call check(to_title(test_string) == compare_string) + + end subroutine test_to_title_string + + subroutine test_reverse_string + type(string_type) :: test_string, compare_string + test_string = "_To ReVerSe !$%-az09AZ " + compare_string = " ZA90za-%$! eSreVeR oT_" + + call check(reverse(test_string) == compare_string) + + end subroutine test_reverse_string + +end module test_string_functions + + +program tester + use test_string_functions + implicit none + + call test_to_lower_string + call test_to_upper_string + call test_to_title_string + call test_reverse_string + +end program tester From 006175d3f385c0d0d37be2ebe3d6258a27aa5d36 Mon Sep 17 00:00:00 2001 From: Aman Godara Date: Fri, 19 Mar 2021 16:01:31 +0530 Subject: [PATCH 10/12] Documented the newly created functions in stdlib_string_type.md --- doc/specs/stdlib_string_type.md | 179 ++++++++++++++++++++++++++++++++ src/stdlib_string_type.f90 | 24 ++--- 2 files changed, 191 insertions(+), 12 deletions(-) diff --git a/doc/specs/stdlib_string_type.md b/doc/specs/stdlib_string_type.md index adbf7483e..7a4472397 100644 --- a/doc/specs/stdlib_string_type.md +++ b/doc/specs/stdlib_string_type.md @@ -1041,6 +1041,185 @@ end program demo ``` + +### To\_lower function + +#### Description + +Returns a new string_type instance which holds the lowercase version of the character sequence hold by the input string. + +#### Syntax + +`lowercase_string = [[stdlib_string_type(module): to_lower(interface)]] (string)` + +#### Status + +Experimental + +#### Class + +Elemental function. + +#### Argument + +`string`: Instance of `string_type`. This argument is `intent(in)`. + +#### Result Value + +The Result is a scalar `string_type` value. + +#### Example + +```fortran +program demo + use stdlib_string_type + implicit none + type(string_type) :: string, lowercase_string + + string = "Lowercase This String" + ! string <-- "Lowercase This String" + + lowercase_string = to_lower(string) + ! string <-- "Lowercase This String" + ! lowercase_string <-- "lowercase this string" +end program demo +``` + + + +### To\_upper function + +#### Description + +Returns a new string_type instance which holds the uppercase version of the character sequence hold by the input string. + +#### Syntax + +`uppercase_string = [[stdlib_string_type(module): to_upper(interface)]] (string)` + +#### Status + +Experimental + +#### Class + +Elemental function. + +#### Argument + +`string`: Instance of `string_type`. This argument is `intent(in)`. + +#### Result Value + +The Result is a scalar `string_type` value. + +#### Example + +```fortran +program demo + use stdlib_string_type + implicit none + type(string_type) :: string, uppercase_string + + string = "Uppercase This String" + ! string <-- "Uppercase This String" + + uppercase_string = to_upper(string) + ! string <-- "Uppercase This String" + ! uppercase_string <-- "UPPERCASE THIS STRING" +end program demo +``` + + + +### To\_title function + +#### Description + +Returns a new string_type instance which holds the titlecase version of the character sequence hold by the input string. + +#### Syntax + +`titlecase_string = [[stdlib_string_type(module): to_title(interface)]] (string)` + +#### Status + +Experimental + +#### Class + +Elemental function. + +#### Argument + +`string`: Instance of `string_type`. This argument is `intent(in)`. + +#### Result Value + +The Result is a scalar `string_type` value. + +#### Example + +```fortran +program demo + use stdlib_string_type + implicit none + type(string_type) :: string, titlecase_string + + string = "Titlecase This String" + ! string <-- "Titlecase This String" + + titlecase_string = to_title(string) + ! string <-- "Titlecase This String" + ! titlecase_string <-- "Titlecase this string" +end program demo +``` + + +### Reverse function + +#### Description + +Returns a new string_type instance which holds the reversed version of the character sequence hold by the input string. + +#### Syntax + +`reverse_string = [[stdlib_string_type(module): reverse(interface)]] (string)` + +#### Status + +Experimental + +#### Class + +Elemental function. + +#### Argument + +`string`: Instance of `string_type`. This argument is `intent(in)`. + +#### Result Value + +The Result is a scalar `string_type` value. + +#### Example + +```fortran +program demo + use stdlib_string_type + implicit none + type(string_type) :: string, reverse_string + + string = "Reverse This String" + ! string <-- "Reverse This String" + + reverse_string = reverse(string) + ! string <-- "Reverse This String" + ! reverse_string <-- "gnirtS sihT esreveR" +end program demo +``` + + ### Comparison operator greater diff --git a/src/stdlib_string_type.f90 b/src/stdlib_string_type.f90 index ba1e7d523..3a30513ef 100644 --- a/src/stdlib_string_type.f90 +++ b/src/stdlib_string_type.f90 @@ -93,34 +93,34 @@ module stdlib_string_type module procedure :: repeat_string end interface repeat - !> Convert the character sequence hold by the input string to lower case + !> Returns the lowercase version of the character sequence hold by the input string !> - !> This method is Elemental and returns a new string_type instance which holds lowercase - !> version of the character sequence hold by the input string + !> This method is Elemental and returns a new string_type instance which holds this + !> lowercase character sequence interface to_lower module procedure :: to_lower_string end interface to_lower - !> Convert the character sequence hold by the input string to upper case + !> Returns the uppercase version of the character sequence hold by the input string !> - !> This method is Elemental and returns a new string_type instance which holds uppercase - !> version of the character sequence hold by the input string + !> This method is Elemental and returns a new string_type instance which holds this + !> uppercase character sequence interface to_upper module procedure :: to_upper_string end interface to_upper - !> Convert the character sequence hold by the input string to title case + !> Returns the titlecase version of the character sequence hold by the input string !> - !> This method is Elemental and returns a new string_type instance which holds titlecase - !> version of the character sequence hold by the input string + !> This method is Elemental and returns a new string_type instance which holds this + !> titlecase character sequence interface to_title module procedure :: to_title_string end interface to_title - !> Reverse the character sequence hold by the input string + !> Reverses the character sequence hold by the input string !> - !> This method is Elemental and returns a new string_type instance which holds reversed - !> sequence of the character sequence hold by the input string + !> This method is Elemental and returns a new string_type instance which holds this + !> reverse character sequence interface reverse module procedure :: reverse_string end interface reverse From 734551d6da65e0ab49f48c57913f6b6008ae1590 Mon Sep 17 00:00:00 2001 From: Aman Godara Date: Fri, 19 Mar 2021 17:49:06 +0530 Subject: [PATCH 11/12] improved documentation of to_title function --- doc/specs/stdlib_string_type.md | 4 +++- src/stdlib_ascii.f90 | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/specs/stdlib_string_type.md b/doc/specs/stdlib_string_type.md index 7a4472397..63c38ccf4 100644 --- a/doc/specs/stdlib_string_type.md +++ b/doc/specs/stdlib_string_type.md @@ -1136,7 +1136,9 @@ end program demo #### Description -Returns a new string_type instance which holds the titlecase version of the character sequence hold by the input string. +Returns a new string_type instance which holds the titlecase (or capitalized) version of the character sequence hold by the input string. +Capitalized version: The first alphabetical character of the input character sequence is transformed to uppercase unless it +follows a numeral and the rest of the characters in the sequence are transformed to lowercase. #### Syntax diff --git a/src/stdlib_ascii.f90 b/src/stdlib_ascii.f90 index d797d33b1..e446f29e2 100644 --- a/src/stdlib_ascii.f90 +++ b/src/stdlib_ascii.f90 @@ -79,15 +79,15 @@ module stdlib_ascii module procedure :: to_upper end interface to_upper - !> Returns a new character sequence which is the titled + !> Returns a new character sequence which is the title case !> version of the input character sequence !> This method is pure and returns a character sequence interface to_title module procedure :: to_title end interface to_title - !> Returns a new character sequence which is the reversed - !> version of the input charater sequence + !> Returns a new character sequence which is reverse of + !> the input charater sequence !> This method is pure and returns a character sequence interface reverse module procedure :: reverse From 060db2d33923fa95a6b04ba300175e4ce98e17f4 Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Fri, 19 Mar 2021 18:19:04 +0100 Subject: [PATCH 12/12] Reorder function exports --- src/stdlib_string_type.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stdlib_string_type.f90 b/src/stdlib_string_type.f90 index 3a30513ef..2b46a5de9 100644 --- a/src/stdlib_string_type.f90 +++ b/src/stdlib_string_type.f90 @@ -19,9 +19,9 @@ module stdlib_string_type private public :: string_type - public :: len, len_trim, trim, index, scan, verify, repeat, adjustr, & - adjustl, to_lower, to_upper, to_title, reverse + public :: len, len_trim, trim, index, scan, verify, repeat, adjustr, adjustl public :: lgt, lge, llt, lle, char, ichar, iachar + public :: to_lower, to_upper, to_title, reverse public :: assignment(=) public :: operator(>), operator(>=), operator(<), operator(<=) public :: operator(==), operator(/=), operator(//)