aboutsummaryrefslogtreecommitdiffstats
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-10 03:40:06 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-10 03:40:06 +0000
commitdbeed155a05b7e82dffc8f43a5918cb5a8efbbfb (patch)
treeddccaa8d5e8a97dd2716f1445fbc7377b71363e6 /ruby.c
parent873382b01cfd3b8c006c39c4d92b3fa7112ef84b (diff)
downloadruby-dbeed155a05b7e82dffc8f43a5918cb5a8efbbfb.tar.gz
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
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/ruby.c b/ruby.c
index 0e7dcc41b8..5f4ee53c92 100644
--- a/ruby.c
+++ b/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;