diff options
Diffstat (limited to 'libguile/filesys.c')
-rw-r--r-- | libguile/filesys.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/libguile/filesys.c b/libguile/filesys.c index ceec87776..f60032818 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -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; } @@ -1856,7 +1861,10 @@ scm_init_filesys () #endif #ifdef O_LARGEFILE scm_c_define ("O_LARGEFILE", scm_from_int (O_LARGEFILE)); -#endif +#endif +#ifdef O_NOTRANS + scm_c_define ("O_NOTRANS", scm_from_int (O_NOTRANS)); +#endif #ifdef F_DUPFD scm_c_define ("F_DUPFD", scm_from_int (F_DUPFD)); |