From e592a735cbe24692721833073d7aebee0d96b393 Mon Sep 17 00:00:00 2001 From: usa Date: Wed, 12 Oct 2016 12:07:16 +0000 Subject: [PATCH] * ruby.c (open_load_file): revert r56385. it introduced incompatibility about `DATA.binmode?`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ruby.c | 15 ++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 560fc63b7d..55463ff5bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Oct 12 21:05:50 2016 NAKAMURA Usaku + + * ruby.c (open_load_file): revert r56385. it introduced incompatibility + about `DATA.binmode?`. + Wed Oct 12 15:24:53 2016 SHIBATA Hiroshi * tool/downloader.rb: Removed verification of gem certification. diff --git a/ruby.c b/ruby.c index 9f94591b46..b21a32638b 100644 --- a/ruby.c +++ b/ruby.c @@ -1878,17 +1878,13 @@ 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_NONBLOCK) +# define MODE_TO_LOAD (O_RDONLY | O_NONBLOCK) #elif defined O_NDELAY && HAVE_FCNTL && !(O_NDELAY & O_ACCMODE) -# define MODE_TO_LOAD (O_NDELAY) +# define MODE_TO_LOAD (O_RDONLY | O_NDELAY) #else -# define MODE_TO_LOAD (0) +# define MODE_TO_LOAD (O_RDONLY) #endif - int mode = O_RDONLY | -#ifdef O_BINARY - O_BINARY | -#endif - MODE_TO_LOAD; + int mode = MODE_TO_LOAD; #if defined DOSISH || defined __CYGWIN__ # define isdirsep(x) ((x) == '/' || (x) == '\\') { @@ -1896,6 +1892,7 @@ open_load_file(VALUE fname_v, int *xflag) enum {extlen = sizeof(exeext)-1}; if (flen > extlen && !isdirsep(fname[flen-extlen-1]) && STRNCASECMP(fname+flen-extlen, exeext, extlen) == 0) { + mode |= O_BINARY; *xflag = 1; } } @@ -1906,7 +1903,7 @@ open_load_file(VALUE fname_v, int *xflag) } rb_update_max_fd(fd); -#if defined HAVE_FCNTL && MODE_TO_LOAD +#if defined HAVE_FCNTL && MODE_TO_LOAD != O_RDONLY /* disabling O_NONBLOCK */ if (fcntl(fd, F_SETFL, 0) < 0) { e = errno;