@@ -16,6 +16,7 @@ module stdlib_string_type
16
16
use stdlib_ascii, only: to_lower_ => to_lower, to_upper_ => to_upper, &
17
17
& to_title_ => to_title, to_sentence_ => to_sentence, reverse_ => reverse
18
18
use stdlib_kinds, only : int8, int16, int32, int64, lk, c_bool
19
+ use stdlib_optval, only: optval
19
20
implicit none
20
21
private
21
22
@@ -569,11 +570,7 @@ contains
569
570
logical, intent(in), optional :: back
570
571
integer :: pos
571
572
572
- if (present(back)) then
573
- pos = index(maybe(string), maybe(substring), back)
574
- else
575
- pos = index(maybe(string), maybe(substring), .false.)
576
- end if
573
+ pos = index(maybe(string), maybe(substring), optval(back, .false.))
577
574
578
575
end function index_string_string
579
576
@@ -585,11 +582,7 @@ contains
585
582
logical, intent(in), optional :: back
586
583
integer :: pos
587
584
588
- if (present(back)) then
589
- pos = index(maybe(string), substring, back)
590
- else
591
- pos = index(maybe(string), substring, .false.)
592
- end if
585
+ pos = index(maybe(string), substring, optval(back, .false.))
593
586
594
587
end function index_string_char
595
588
@@ -601,11 +594,7 @@ contains
601
594
logical, intent(in), optional :: back
602
595
integer :: pos
603
596
604
- if (present(back)) then
605
- pos = index(string, maybe(substring), back)
606
- else
607
- pos = index(string, maybe(substring), .false.)
608
- end if
597
+ pos = index(string, maybe(substring), optval(back, .false.))
609
598
610
599
end function index_char_string
611
600
@@ -619,11 +608,7 @@ contains
619
608
logical, intent(in), optional :: back
620
609
integer :: pos
621
610
622
- if (present(back)) then
623
- pos = scan(maybe(string), maybe(set), back)
624
- else
625
- pos = scan(maybe(string), maybe(set), .false.)
626
- end if
611
+ pos = scan(maybe(string), maybe(set), optval(back, .false.))
627
612
628
613
end function scan_string_string
629
614
@@ -635,11 +620,7 @@ contains
635
620
logical, intent(in), optional :: back
636
621
integer :: pos
637
622
638
- if (present(back)) then
639
- pos = scan(maybe(string), set, back)
640
- else
641
- pos = scan(maybe(string), set, .false.)
642
- end if
623
+ pos = scan(maybe(string), set, optval(back, .false.))
643
624
644
625
end function scan_string_char
645
626
@@ -651,11 +632,7 @@ contains
651
632
logical, intent(in), optional :: back
652
633
integer :: pos
653
634
654
- if (present(back)) then
655
- pos = scan(string, maybe(set), back)
656
- else
657
- pos = scan(string, maybe(set), .false.)
658
- end if
635
+ pos = scan(string, maybe(set), optval(back, .false.))
659
636
660
637
end function scan_char_string
661
638
@@ -669,11 +646,7 @@ contains
669
646
logical, intent(in), optional :: back
670
647
integer :: pos
671
648
672
- if (present(back)) then
673
- pos = verify(maybe(string), maybe(set), back)
674
- else
675
- pos = verify(maybe(string), maybe(set), .false.)
676
- end if
649
+ pos = verify(maybe(string), maybe(set), optval(back, .false.))
677
650
678
651
end function verify_string_string
679
652
@@ -686,11 +659,7 @@ contains
686
659
logical, intent(in), optional :: back
687
660
integer :: pos
688
661
689
- if (present(back)) then
690
- pos = verify(maybe(string), set, back)
691
- else
692
- pos = verify(maybe(string), set, .false.)
693
- end if
662
+ pos = verify(maybe(string), set, optval(back, .false.))
694
663
695
664
end function verify_string_char
696
665
@@ -703,11 +672,7 @@ contains
703
672
logical, intent(in), optional :: back
704
673
integer :: pos
705
674
706
- if (present(back)) then
707
- pos = verify(string, maybe(set), back)
708
- else
709
- pos = verify(string, maybe(set), .false.)
710
- end if
675
+ pos = verify(string, maybe(set), optval(back, .false.))
711
676
712
677
end function verify_char_string
713
678
0 commit comments