mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 03:30:27 +02:00
Fix `open' mode bits on GNU/Hurd.
* libguile/filesys.c (scm_open): Fix check for read-write flags for systems such as GNU/Hurd, where O_RDWR == (O_WRONLY | O_RDONLY) and O_RDONLY != 0.
This commit is contained in:
parent
3565df4546
commit
126a322431
1 changed files with 14 additions and 9 deletions
|
@ -261,8 +261,10 @@ SCM_DEFINE (scm_open, "open", 2, 1, 0,
|
|||
|
||||
fd = scm_to_int (scm_open_fdes (path, flags, mode));
|
||||
iflags = SCM_NUM2INT (2, flags);
|
||||
if (iflags & O_RDWR)
|
||||
|
||||
if ((iflags & O_RDWR) == O_RDWR)
|
||||
{
|
||||
/* Opened read-write. */
|
||||
if (iflags & O_APPEND)
|
||||
port_mode = "a+";
|
||||
else if (iflags & O_CREAT)
|
||||
|
@ -270,14 +272,17 @@ SCM_DEFINE (scm_open, "open", 2, 1, 0,
|
|||
else
|
||||
port_mode = "r+";
|
||||
}
|
||||
else {
|
||||
if (iflags & O_APPEND)
|
||||
port_mode = "a";
|
||||
else if (iflags & O_WRONLY)
|
||||
port_mode = "w";
|
||||
else
|
||||
port_mode = "r";
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Opened read-only or write-only. */
|
||||
if (iflags & O_APPEND)
|
||||
port_mode = "a";
|
||||
else if (iflags & O_WRONLY)
|
||||
port_mode = "w";
|
||||
else
|
||||
port_mode = "r";
|
||||
}
|
||||
|
||||
newpt = scm_fdes_to_port (fd, port_mode, path);
|
||||
return newpt;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue