Skip to content

Commit 83a409c

Browse files
committed
fix pattern constructor due to ifort behavior
1 parent 2f2d4a0 commit 83a409c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Diff for: src/regex.f90

+16
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,24 @@ module regex_module
111111
module procedure re_matchp_nolength_noback
112112
end interface regex
113113

114+
! Override default constructor for ifort bug
115+
interface regex_token
116+
module procedure pat_from_char
117+
end interface regex_token
118+
119+
114120
contains
115121

122+
! Construct a regex pattern from a single character
123+
elemental type(regex_token) function pat_from_char(type,ccl) result(this)
124+
integer, intent(in) :: type
125+
character(kind=RCK), intent(in) :: ccl
126+
call pat_destroy(this)
127+
this%type = type
128+
allocate(character(len=1,kind=RCK) :: this%ccl)
129+
this%ccl(1:1) = ccl
130+
end function pat_from_char
131+
116132
! Check that a pattern matches the expected result
117133
logical function check_pattern(string,pattern,expected) result(success)
118134
character(len=*,kind=RCK), intent(in) :: string

Diff for: test/tests.f90

+9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ program tests
3232
call add_test(test_bracket_space())
3333
call add_test(test_end_anchor())
3434
call add_test(test_end_anchor2())
35+
call add_test(test_read_version())
3536

3637
! Test #2
3738
call add_test(run_test2())
@@ -122,4 +123,12 @@ logical function test_end_anchor2() result(success)
122123

123124
end function test_end_anchor2
124125

126+
logical function test_read_version() result(success)
127+
character(*), parameter :: &
128+
text = 'Intel(R) MPI Library 2021.8 for Linux*Copyright Intel Corporation.ifort version 2021.8.0'
129+
130+
success = check_pattern(text,'\d+\.\d+\.\d+',expected="2021.8.0")
131+
132+
end function test_read_version
133+
125134
end program tests

0 commit comments

Comments
 (0)