Skip to content

Commit 08dc86b

Browse files
committed
Allow any order of characters in the mode
1 parent b0b3dbf commit 08dc86b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/stdlib_experimental_io.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,11 @@ integer function open(filename, mode) result(u)
371371
mode_(3:3) = mode(3:3)
372372
end if
373373

374+
if (mode_(1:1) == 'b') then
375+
mode_(1:1) = mode_(3:3)
376+
mode_(3:3) = 'b'
377+
end if
378+
374379
end function
375380

376381
end module

src/tests/io/test_open.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ subroutine test_parse_mode()
9595
call assert(m == "a b")
9696

9797
m = parse_mode("br")
98-
!call assert(m == "r b")
98+
call assert(m == "r b")
9999
m = parse_mode("bw")
100-
!call assert(m == "w b")
100+
call assert(m == "w b")
101101
m = parse_mode("ba")
102-
!call assert(m == "a b")
102+
call assert(m == "a b")
103103

104104
m = parse_mode("r+")
105105
call assert(m == "r+t")

0 commit comments

Comments
 (0)