@@ -421,7 +421,11 @@ contains
421
421
type(string_type), intent(in) :: string
422
422
integer :: ich
423
423
424
- ich = merge(ichar(string%raw), 0, allocated(string%raw))
424
+ if (allocated(string%raw) .and. len(string) > 0) then
425
+ ich = ichar(string%raw(1:1))
426
+ else
427
+ ich = 0
428
+ end if
425
429
426
430
end function ichar_string
427
431
@@ -431,7 +435,11 @@ contains
431
435
type(string_type), intent(in) :: string
432
436
integer :: ich
433
437
434
- ich = merge(iachar(string%raw), 0, allocated(string%raw))
438
+ if (allocated(string%raw) .and. len(string) > 0) then
439
+ ich = iachar(string%raw(1:1))
440
+ else
441
+ ich = 0
442
+ end if
435
443
436
444
end function iachar_string
437
445
@@ -571,8 +579,11 @@ contains
571
579
logical, intent(in), optional :: back
572
580
integer :: pos
573
581
574
- pos = index(maybe(string), maybe(substring), &
575
- merge(back, .false., present(back)))
582
+ if (present(back)) then
583
+ pos = index(maybe(string), maybe(substring), back)
584
+ else
585
+ pos = index(maybe(string), maybe(substring), .false.)
586
+ end if
576
587
577
588
end function index_string_string
578
589
@@ -584,8 +595,11 @@ contains
584
595
logical, intent(in), optional :: back
585
596
integer :: pos
586
597
587
- pos = index(maybe(string), substring, &
588
- merge(back, .false., present(back)))
598
+ if (present(back)) then
599
+ pos = index(maybe(string), substring, back)
600
+ else
601
+ pos = index(maybe(string), substring, .false.)
602
+ end if
589
603
590
604
end function index_string_char
591
605
@@ -597,8 +611,11 @@ contains
597
611
logical, intent(in), optional :: back
598
612
integer :: pos
599
613
600
- pos = index(string, maybe(substring), &
601
- merge(back, .false., present(back)))
614
+ if (present(back)) then
615
+ pos = index(string, maybe(substring), back)
616
+ else
617
+ pos = index(string, maybe(substring), .false.)
618
+ end if
602
619
603
620
end function index_char_string
604
621
@@ -612,8 +629,11 @@ contains
612
629
logical, intent(in), optional :: back
613
630
integer :: pos
614
631
615
- pos = scan(maybe(string), maybe(set), &
616
- merge(back, .false., present(back)))
632
+ if (present(back)) then
633
+ pos = scan(maybe(string), maybe(set), back)
634
+ else
635
+ pos = scan(maybe(string), maybe(set), .false.)
636
+ end if
617
637
618
638
end function scan_string_string
619
639
@@ -625,8 +645,11 @@ contains
625
645
logical, intent(in), optional :: back
626
646
integer :: pos
627
647
628
- pos = scan(maybe(string), set, &
629
- merge(back, .false., present(back)))
648
+ if (present(back)) then
649
+ pos = scan(maybe(string), set, back)
650
+ else
651
+ pos = scan(maybe(string), set, .false.)
652
+ end if
630
653
631
654
end function scan_string_char
632
655
@@ -638,8 +661,11 @@ contains
638
661
logical, intent(in), optional :: back
639
662
integer :: pos
640
663
641
- pos = scan(string, maybe(set), &
642
- merge(back, .false., present(back)))
664
+ if (present(back)) then
665
+ pos = scan(string, maybe(set), back)
666
+ else
667
+ pos = scan(string, maybe(set), .false.)
668
+ end if
643
669
644
670
end function scan_char_string
645
671
@@ -653,8 +679,11 @@ contains
653
679
logical, intent(in), optional :: back
654
680
integer :: pos
655
681
656
- pos = verify(maybe(string), maybe(set), &
657
- merge(back, .false., present(back)))
682
+ if (present(back)) then
683
+ pos = verify(maybe(string), maybe(set), back)
684
+ else
685
+ pos = verify(maybe(string), maybe(set), .false.)
686
+ end if
658
687
659
688
end function verify_string_string
660
689
@@ -667,8 +696,11 @@ contains
667
696
logical, intent(in), optional :: back
668
697
integer :: pos
669
698
670
- pos = verify(maybe(string), set, &
671
- merge(back, .false., present(back)))
699
+ if (present(back)) then
700
+ pos = verify(maybe(string), set, back)
701
+ else
702
+ pos = verify(maybe(string), set, .false.)
703
+ end if
672
704
673
705
end function verify_string_char
674
706
@@ -681,8 +713,11 @@ contains
681
713
logical, intent(in), optional :: back
682
714
integer :: pos
683
715
684
- pos = verify(string, maybe(set), &
685
- merge(back, .false., present(back)))
716
+ if (present(back)) then
717
+ pos = verify(string, maybe(set), back)
718
+ else
719
+ pos = verify(string, maybe(set), .false.)
720
+ end if
686
721
687
722
end function verify_char_string
688
723
0 commit comments