Skip to content

Commit 3969349

Browse files
committed
Fix fstream's assumptions about values of O_RDONLY, O_WRONLY, and O_RDWR.
1 parent b4dbb3b commit 3969349

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fstream.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ void fstream::detach (void) noexcept
9999
if (O_RDONLY == in-1 && O_WRONLY == out-1 && O_RDWR == (in|out)-1)
100100
flags = (m - 1) & O_ACCMODE;
101101
else
102-
flags = (m & (in|out)) ? O_RDWR : ((m & out) ? O_WRONLY : O_RDONLY);
102+
flags = ((m&(in|out))==(in|out)) ? O_RDWR : ((m&out) ? O_WRONLY : O_RDONLY);
103103
for (uoff_t i = 0; i < VectorSize(s_OMFlags); ++ i)
104-
flags |= s_OMFlags[i] & (!(m & (1 << i)) - 1);
104+
flags |= s_OMFlags[i] & (!(m&(1<<i))-1);
105105
if (m & nocreate)
106106
flags &= ~O_CREAT;
107107
return (flags);

0 commit comments

Comments
 (0)