mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ruby.c: open in binary mode to load
* ruby.c (open_load_file): open in binary mode if available, as parser deals with EOLs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e17994426c
commit
18d0bf952a
2 changed files with 13 additions and 7 deletions
|
@ -1,4 +1,7 @@
|
|||
Mon Oct 10 12:37:06 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Mon Oct 10 12:40:04 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ruby.c (open_load_file): open in binary mode if available, as
|
||||
parser deals with EOLs.
|
||||
|
||||
* io.c (prep_io): reduce isatty call (and its system call) on
|
||||
Cygwin.
|
||||
|
|
15
ruby.c
15
ruby.c
|
@ -1877,18 +1877,21 @@ open_load_file(VALUE fname_v, int *xflag)
|
|||
use O_NONBLOCK. */
|
||||
#if defined O_NONBLOCK && HAVE_FCNTL && !(O_NONBLOCK & O_ACCMODE)
|
||||
/* TODO: fix conflicting O_NONBLOCK in ruby/win32.h */
|
||||
# define MODE_TO_LOAD (O_RDONLY | O_NONBLOCK)
|
||||
# define MODE_TO_LOAD (O_NONBLOCK)
|
||||
#elif defined O_NDELAY && HAVE_FCNTL && !(O_NDELAY & O_ACCMODE)
|
||||
# define MODE_TO_LOAD (O_RDONLY | O_NDELAY)
|
||||
# define MODE_TO_LOAD (O_NDELAY)
|
||||
#else
|
||||
# define MODE_TO_LOAD (O_RDONLY)
|
||||
# define MODE_TO_LOAD (0)
|
||||
#endif
|
||||
int mode = MODE_TO_LOAD;
|
||||
int mode = O_RDONLY |
|
||||
#ifdef O_BINARY
|
||||
O_BINARY |
|
||||
#endif
|
||||
MODE_TO_LOAD;
|
||||
#if defined DOSISH || defined __CYGWIN__
|
||||
{
|
||||
const char *ext = strrchr(fname, '.');
|
||||
if (ext && STRCASECMP(ext, ".exe") == 0) {
|
||||
mode |= O_BINARY;
|
||||
*xflag = 1;
|
||||
}
|
||||
}
|
||||
|
@ -1899,7 +1902,7 @@ open_load_file(VALUE fname_v, int *xflag)
|
|||
}
|
||||
rb_update_max_fd(fd);
|
||||
|
||||
#if defined HAVE_FCNTL && MODE_TO_LOAD != O_RDONLY
|
||||
#if defined HAVE_FCNTL && MODE_TO_LOAD
|
||||
/* disabling O_NONBLOCK */
|
||||
if (fcntl(fd, F_SETFL, 0) < 0) {
|
||||
e = errno;
|
||||
|
|
Loading…
Reference in a new issue