Project

General

Profile

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

cesario (Franck Verrot), 06/13/2015 12:52 PM

View differences:

ChangeLog
1
Sat Jun 13 11:46:45 2015  Franck Verrot  <franck@verrot.fr>
2

  
3
	file.c : `load` now supports reading from a FIFO file
4

  
5
	* file.c (rb_file_load_ok): `load` can now load not only regular files
6
	  but also FIFOS. [ruby-dev:48924]
7

  
1 8
Sat Jun 13 20:28:14 2015  NARUSE, Yui  <naruse@ruby-lang.org>
2 9

  
3 10
	* file.c (rb_stat_ino): get inode from the interval of struct st.
NEWS
15 15

  
16 16
=== Core classes updates (outstanding ones only)
17 17

  
18
* Kernel
19

  
20
  * Kernel.load now supports reading from a FIFO file.
21

  
18 22
* Enumerable
19 23

  
20 24
  * Enumerable#grep_v is added as inverse version of Enumerable#grep.
file.c
114 114
#define STAT(p, s)	stat((p), (s))
115 115
#endif
116 116

  
117
#ifdef S_IFIFO
118
#  ifndef S_ISFIFO
119
#    define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
120
#  endif
121
#endif
122

  
117 123
#if defined(__BEOS__) || defined(__HAIKU__) /* should not change ID if -1 */
118 124
static int
119 125
be_chown(const char *path, uid_t owner, gid_t group)
......
1366 1372
rb_file_pipe_p(VALUE obj, VALUE fname)
1367 1373
{
1368 1374
#ifdef S_IFIFO
1369
#  ifndef S_ISFIFO
1370
#    define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
1371
#  endif
1372

  
1373 1375
    struct stat st;
1374 1376

  
1375 1377
    if (rb_stat(fname, &st) < 0) return Qfalse;
......
5630 5632
    rb_update_max_fd(fd);
5631 5633
#if !defined DOSISH
5632 5634
    {
5633
	struct stat st;
5634
	if (fstat(fd, &st) || !S_ISREG(st.st_mode)) {
5635
	    ret = 0;
5636
	}
5635
      struct stat st;
5636
      fstat(fd, &st);
5637

  
5638
      #ifdef S_IFIFO
5639
      if (!(S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode))) {
5640
      #else
5641
      if (!S_ISREG(st.st_mode)) {
5642
      #endif
5643
          ret = 0;
5644
      }
5637 5645
    }
5638 5646
#endif
5639 5647
    (void)close(fd);
test/ruby/test_require.rb
329 329
    end
330 330
  end
331 331

  
332
  def test_load_from_fifo
333
    bug = '[ruby-dev:48924] #load from a FIFO'
334
    thread = nil
335
    Dir.mktmpdir {|tmp|
336
      file = File.join(tmp,'fifo.rb')
337
      File.mkfifo(file)
338
      thread = Thread.new { open(file,'w') { f.puts "puts 1" } }
339
      assert_separately([], <<-INPUT)
340
        assert_nothing_raised(LoadError) { load("#{ file }") }
341
      INPUT
342
    }
343
    #thread.join
344
  end
345

  
332 346
  def test_tainted_loadpath
333 347
    Tempfile.create(["test_ruby_test_require", ".rb"]) {|t|
334 348
      abs_dir, file = File.split(t.path)
335
-