ruby-changes:44312
From: nobu <ko1@a...>
Date: Mon, 10 Oct 2016 12:40:11 +0900 (JST)
Subject: [ruby-changes:44312] nobu:r56385 (trunk): ruby.c: open in binary mode to load
nobu 2016-10-10 12:40:06 +0900 (Mon, 10 Oct 2016) New Revision: 56385 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56385 Log: ruby.c: open in binary mode to load * ruby.c (open_load_file): open in binary mode if available, as parser deals with EOLs. Modified files: trunk/ChangeLog trunk/ruby.c Index: ruby.c =================================================================== --- ruby.c (revision 56384) +++ ruby.c (revision 56385) @@ -1877,18 +1877,21 @@ open_load_file(VALUE fname_v, int *xflag https://github.com/ruby/ruby/blob/trunk/ruby.c#L1877 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 https://github.com/ruby/ruby/blob/trunk/ruby.c#L1902 } 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; Index: ChangeLog =================================================================== --- ChangeLog (revision 56384) +++ ChangeLog (revision 56385) @@ -1,4 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 -Mon Oct 10 12:37:06 2016 Nobuyoshi Nakada <nobu@r...> +Mon Oct 10 12:40:04 2016 Nobuyoshi Nakada <nobu@r...> + + * 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. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/