@@ -171,14 +171,16 @@ end function new_stringlist
171
171
pure function new_stringlist_carray ( array )
172
172
character (len=* ), dimension (:), intent (in ) :: array
173
173
type (stringlist_type) :: new_stringlist_carray
174
- type (string_type), dimension ( size (array) ) :: sarray
174
+
175
+ type (string_type), allocatable :: sarray(:)
175
176
integer :: i
176
177
178
+ allocate ( sarray( size (array) ) )
177
179
do i = 1 , size (array)
178
180
sarray(i) = string_type( array(i) )
179
181
end do
180
182
181
- new_stringlist_carray = stringlist_type ( sarray )
183
+ call move_alloc ( sarray, new_stringlist_carray % stringarray )
182
184
183
185
end function new_stringlist_carray
184
186
@@ -188,7 +190,6 @@ pure function new_stringlist_sarray( array )
188
190
type (string_type), dimension (:), intent (in ) :: array
189
191
type (stringlist_type) :: new_stringlist_sarray
190
192
191
- new_stringlist_sarray = stringlist_type()
192
193
new_stringlist_sarray% stringarray = array
193
194
194
195
end function new_stringlist_sarray
@@ -476,7 +477,7 @@ end function shift
476
477
! >
477
478
! > Resets stringlist 'list' to an empy stringlist of len 0
478
479
! > Modifies the input stringlist 'list'
479
- subroutine clear_list ( list )
480
+ pure subroutine clear_list ( list )
480
481
class(stringlist_type), intent (inout ) :: list
481
482
482
483
if ( allocated ( list% stringarray ) ) then
@@ -540,7 +541,7 @@ end function convert_to_current_idxn
540
541
! >
541
542
! > Inserts character scalar 'string' AT stringlist_index 'idx' in stringlist 'list'
542
543
! > Modifies the input stringlist 'list'
543
- subroutine insert_at_char_idx_wrap ( list , idx , string )
544
+ pure subroutine insert_at_char_idx_wrap ( list , idx , string )
544
545
class(stringlist_type), intent (inout ) :: list
545
546
type (stringlist_index_type), intent (in ) :: idx
546
547
character (len=* ), intent (in ) :: string
@@ -553,7 +554,7 @@ end subroutine insert_at_char_idx_wrap
553
554
! >
554
555
! > Inserts string 'string' AT stringlist_index 'idx' in stringlist 'list'
555
556
! > Modifies the input stringlist 'list'
556
- subroutine insert_at_string_idx_wrap ( list , idx , string )
557
+ pure subroutine insert_at_string_idx_wrap ( list , idx , string )
557
558
class(stringlist_type), intent (inout ) :: list
558
559
type (stringlist_index_type), intent (in ) :: idx
559
560
type (string_type), intent (in ) :: string
@@ -566,7 +567,7 @@ end subroutine insert_at_string_idx_wrap
566
567
! >
567
568
! > Inserts stringlist 'slist' AT stringlist_index 'idx' in stringlist 'list'
568
569
! > Modifies the input stringlist 'list'
569
- subroutine insert_at_stringlist_idx_wrap ( list , idx , slist )
570
+ pure subroutine insert_at_stringlist_idx_wrap ( list , idx , slist )
570
571
class(stringlist_type), intent (inout ) :: list
571
572
type (stringlist_index_type), intent (in ) :: idx
572
573
type (stringlist_type), intent (in ) :: slist
@@ -579,7 +580,7 @@ end subroutine insert_at_stringlist_idx_wrap
579
580
! >
580
581
! > Inserts chararray 'carray' AT stringlist_index 'idx' in stringlist 'list'
581
582
! > Modifies the input stringlist 'list'
582
- subroutine insert_at_chararray_idx_wrap ( list , idx , carray )
583
+ pure subroutine insert_at_chararray_idx_wrap ( list , idx , carray )
583
584
class(stringlist_type), intent (inout ) :: list
584
585
type (stringlist_index_type), intent (in ) :: idx
585
586
character (len=* ), dimension (:), intent (in ) :: carray
@@ -592,7 +593,7 @@ end subroutine insert_at_chararray_idx_wrap
592
593
! >
593
594
! > Inserts stringarray 'sarray' AT stringlist_index 'idx' in stringlist 'list'
594
595
! > Modifies the input stringlist 'list'
595
- subroutine insert_at_stringarray_idx_wrap ( list , idx , sarray )
596
+ pure subroutine insert_at_stringarray_idx_wrap ( list , idx , sarray )
596
597
class(stringlist_type), intent (inout ) :: list
597
598
type (stringlist_index_type), intent (in ) :: idx
598
599
type (string_type), dimension (:), intent (in ) :: sarray
@@ -605,7 +606,7 @@ end subroutine insert_at_stringarray_idx_wrap
605
606
! >
606
607
! > Inserts 'positions' number of empty positions BEFORE integer index 'idxn'
607
608
! > Modifies the input stringlist 'list'
608
- subroutine insert_before_engine ( list , idxn , positions )
609
+ pure subroutine insert_before_engine ( list , idxn , positions )
609
610
! > Not a part of public API
610
611
type (stringlist_type), intent (inout ) :: list
611
612
integer , intent (inout ) :: idxn
@@ -641,7 +642,7 @@ end subroutine insert_before_engine
641
642
! >
642
643
! > Inserts string 'string' BEFORE integer index 'idxn' in the underlying stringarray
643
644
! > Modifies the input stringlist 'list'
644
- subroutine insert_before_string_int_impl ( list , idxn , string )
645
+ pure subroutine insert_before_string_int_impl ( list , idxn , string )
645
646
! > Not a part of public API
646
647
class(stringlist_type), intent (inout ) :: list
647
648
integer , intent (in ) :: idxn
@@ -660,7 +661,7 @@ end subroutine insert_before_string_int_impl
660
661
! >
661
662
! > Inserts stringlist 'slist' BEFORE integer index 'idxn' in the underlying stringarray
662
663
! > Modifies the input stringlist 'list'
663
- subroutine insert_before_stringlist_int_impl ( list , idxn , slist )
664
+ pure subroutine insert_before_stringlist_int_impl ( list , idxn , slist )
664
665
! > Not a part of public API
665
666
class(stringlist_type), intent (inout ) :: list
666
667
integer , intent (in ) :: idxn
@@ -695,7 +696,7 @@ end subroutine insert_before_stringlist_int_impl
695
696
! >
696
697
! > Inserts chararray 'carray' BEFORE integer index 'idxn' in the underlying stringarray
697
698
! > Modifies the input stringlist 'list'
698
- subroutine insert_before_chararray_int_impl ( list , idxn , carray )
699
+ pure subroutine insert_before_chararray_int_impl ( list , idxn , carray )
699
700
! > Not a part of public API
700
701
class(stringlist_type), intent (inout ) :: list
701
702
integer , intent (in ) :: idxn
@@ -718,7 +719,7 @@ end subroutine insert_before_chararray_int_impl
718
719
! >
719
720
! > Inserts stringarray 'sarray' BEFORE integer index 'idxn' in the underlying stringarray
720
721
! > Modifies the input stringlist 'list'
721
- subroutine insert_before_stringarray_int_impl ( list , idxn , sarray )
722
+ pure subroutine insert_before_stringarray_int_impl ( list , idxn , sarray )
722
723
! > Not a part of public API
723
724
class(stringlist_type), intent (inout ) :: list
724
725
integer , intent (in ) :: idxn
@@ -755,7 +756,7 @@ pure subroutine get_engine( list, first, last, capture_strings )
755
756
from = max ( list% to_current_idxn( first ), 1 )
756
757
to = min ( list% to_current_idxn( last ), list% len () )
757
758
758
- ! out of bounds indexes won't be captured in capture_strings
759
+ ! out of bounds indexes won't be captured in ' capture_strings'
759
760
if ( from <= to ) then
760
761
allocate ( capture_strings( to - from + 1 ) )
761
762
@@ -812,8 +813,8 @@ end function get_range_idx_impl
812
813
! > Removes strings present at indexes in interval ['first', 'last']
813
814
! > Stores captured popped strings in array 'capture_popped'
814
815
! > No return
815
- subroutine pop_drop_engine ( list , first , last , capture_popped )
816
- class(stringlist_type) :: list
816
+ pure subroutine pop_drop_engine ( list , first , last , capture_popped )
817
+ class(stringlist_type), intent ( inout ) :: list
817
818
type (stringlist_index_type), intent (in ) :: first, last
818
819
type (string_type), allocatable , intent (out ), optional :: capture_popped(:)
819
820
@@ -824,8 +825,8 @@ subroutine pop_drop_engine( list, first, last, capture_popped )
824
825
old_len = list% len ()
825
826
firstn = list% to_current_idxn( first )
826
827
lastn = list% to_current_idxn( last )
827
- from = max ( firstn , 1 )
828
- to = min ( lastn , old_len )
828
+ from = max ( firstn, 1 )
829
+ to = min ( lastn, old_len )
829
830
830
831
! out of bounds indexes won't modify stringlist
831
832
if ( from <= to ) then
@@ -863,7 +864,7 @@ end subroutine pop_drop_engine
863
864
! > Removes the string present at stringlist_index 'idx' in stringlist 'list'
864
865
! > Returns the removed string
865
866
function pop_idx_impl ( list , idx )
866
- class(stringlist_type) :: list
867
+ class(stringlist_type), intent ( inout ) :: list
867
868
type (stringlist_index_type), intent (in ) :: idx
868
869
type (string_type) :: pop_idx_impl
869
870
@@ -883,7 +884,7 @@ end function pop_idx_impl
883
884
! > in stringlist 'list'
884
885
! > Returns removed strings
885
886
function pop_range_idx_impl ( list , first , last )
886
- class(stringlist_type) :: list
887
+ class(stringlist_type), intent ( inout ) :: list
887
888
type (stringlist_index_type), intent (in ) :: first, last
888
889
889
890
type (string_type), dimension (:), allocatable :: pop_range_idx_impl
@@ -896,8 +897,8 @@ end function pop_range_idx_impl
896
897
! >
897
898
! > Removes the string present at stringlist_index 'idx' in stringlist 'list'
898
899
! > Doesn't return the removed string
899
- subroutine drop_idx_impl ( list , idx )
900
- class(stringlist_type) :: list
900
+ pure subroutine drop_idx_impl ( list , idx )
901
+ class(stringlist_type), intent ( inout ) :: list
901
902
type (stringlist_index_type), intent (in ) :: idx
902
903
903
904
call pop_drop_engine( list, idx, idx )
@@ -909,8 +910,8 @@ end subroutine drop_idx_impl
909
910
! > Removes strings present at stringlist_indexes in interval ['first', 'last']
910
911
! > in stringlist 'list'
911
912
! > Doesn't return removed strings
912
- subroutine drop_range_idx_impl ( list , first , last )
913
- class(stringlist_type) :: list
913
+ pure subroutine drop_range_idx_impl ( list , first , last )
914
+ class(stringlist_type), intent ( inout ) :: list
914
915
type (stringlist_index_type), intent (in ) :: first, last
915
916
916
917
call pop_drop_engine( list, first, last )
0 commit comments