Project

General

Profile

Feature #11273 ยป 0001-file.c-load-now-supports-reading-from-a-FIFO-file.patch

fix on windows - cesario (Franck Verrot), 06/17/2015 07:07 AM

View differences:

ChangeLog
Wed Jun 17 16:00:00 2015 Franck Verrot <franck@verrot.fr>
file.c : `load` now supports reading from a FIFO file
* file.c (rb_file_load_ok): `load` can now load not only regular files
but also FIFOS.
Wed Jun 17 15:15:53 2015 NAKAMURA Usaku <usa@ruby-lang.org>
* safe.c (safe_setter): of course, don't have to warn the limitation of
NEWS
=== Core classes updates (outstanding ones only)
* Kernel
* Kernel.load now supports reading from a FIFO file.
* Enumerable
* Enumerable#grep_v is added as inverse version of Enumerable#grep.
file.c
#define STAT(p, s) stat((p), (s))
#endif
#ifdef S_IFIFO
# ifndef S_ISFIFO
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
# endif
#endif
#if defined(__BEOS__) || defined(__HAIKU__) /* should not change ID if -1 */
static int
be_chown(const char *path, uid_t owner, gid_t group)
......
rb_file_pipe_p(VALUE obj, VALUE fname)
{
#ifdef S_IFIFO
# ifndef S_ISFIFO
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
# endif
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
......
rb_update_max_fd(fd);
#if !defined DOSISH
{
struct stat st;
if (fstat(fd, &st) || !S_ISREG(st.st_mode)) {
ret = 0;
}
struct stat st;
fstat(fd, &st);
#ifdef S_IFIFO
if (!(S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode))) {
#else
if (!S_ISREG(st.st_mode)) {
#endif
ret = 0;
}
}
#endif
(void)close(fd);
test/ruby/test_require.rb
END
}
end unless /mswin|mingw/ =~ RUBY_PLATFORM
def test_loading_from_fifo
Dir.mktmpdir {|tmp|
file = File.join(tmp,'fifo.rb')
File.mkfifo(file)
thread = Thread.new { open(file,'w') { |f| f.puts "class Foo; end" } }
assert_separately([], <<-INPUT)
assert_nothing_raised(LoadError) { load("#{ file }") }
assert_nothing_raised(NameError) { Foo }
INPUT
}
end unless /mswin|mingw/ =~ RUBY_PLATFORM
end
    (1-1/1)