2
2
use stdlib_ascii, only: reverse
3
3
use stdlib_strings, only: chomp, find, join
4
4
contains
5
- module pure function join2(p1, p2) result(path)
5
+ module function join2 (p1 , p2 ) result(path)
6
6
character (:), allocatable :: path
7
7
character (* ), intent (in ) :: p1, p2
8
8
9
- path = trim (p1) // pathsep // trim (p2)
9
+ path = trim (p1) // path_sep() // trim (p2)
10
10
end function join2
11
11
12
- module pure function joinarr(p) result(path)
12
+ module function joinarr (p ) result(path)
13
13
character (:), allocatable :: path
14
14
character (* ), intent (in ) :: p(:)
15
15
16
- path = join(p, pathsep )
16
+ path = join(p, path_sep() )
17
17
end function joinarr
18
18
19
- module pure function join_op(p1, p2) result(path)
19
+ module function join_op (p1 , p2 ) result(path)
20
20
character (:), allocatable :: path
21
21
character (* ), intent (in ) :: p1, p2
22
22
@@ -28,6 +28,8 @@ module subroutine split_path(p, head, tail)
28
28
character (:), allocatable , intent (out ) :: head, tail
29
29
character (:), allocatable :: temp
30
30
integer :: i
31
+ character (len= 1 ) :: sep
32
+ sep = path_sep()
31
33
32
34
! Empty string, return (.,'')
33
35
if (trim (p) == ' ' ) then
@@ -37,28 +39,28 @@ module subroutine split_path(p, head, tail)
37
39
end if
38
40
39
41
! Remove trailing path separators
40
- temp = trim (chomp(trim (p), pathsep ))
42
+ temp = trim (chomp(trim (p), sep ))
41
43
42
44
if (temp == ' ' ) then
43
- head = pathsep
45
+ head = sep
44
46
tail = ' '
45
47
return
46
48
end if
47
49
48
- i = find(reverse(temp), pathsep )
50
+ i = find(reverse(temp), sep )
49
51
50
52
! if no `pathsep`, then it probably was a root dir like `C:\`
51
53
if (i == 0 ) then
52
- head = temp // pathsep
54
+ head = temp // sep
53
55
tail = ' '
54
56
return
55
57
end if
56
58
57
59
head = temp(:len (temp)- i)
58
60
59
61
! child of a root directory
60
- if (find(head, pathsep ) == 0 ) then
61
- head = head // pathsep
62
+ if (find(head, sep ) == 0 ) then
63
+ head = head // sep
62
64
end if
63
65
64
66
tail = temp(len (temp)- i+2 :)
0 commit comments