mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (rb_io_sysread): use temporary lock. [ruby-dev:24992]
* lib/ostruct.rb (OpenStruct::method_missing): check method duplication for -d. * lib/ostruct.rb (OpenStruct::initialize): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cb32ebe81c
commit
c0acb3ce17
3 changed files with 24 additions and 9 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,7 @@
|
|||
Tue Nov 30 00:49:08 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* io.c (rb_io_sysread): use temporary lock. [ruby-dev:24992]
|
||||
|
||||
Tue Nov 30 00:12:57 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
|
||||
|
||||
* regparse.c: now handles many alternatives (over 500000)
|
||||
|
@ -8,6 +12,13 @@ Mon Nov 29 16:06:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
* ext/stringio/stringio.c (strio_write): insufficiently filled string
|
||||
being extended when overwriting. [ruby-core:03836]
|
||||
|
||||
Mon Nov 29 15:59:05 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* lib/ostruct.rb (OpenStruct::method_missing): check method
|
||||
duplication for -d.
|
||||
|
||||
* lib/ostruct.rb (OpenStruct::initialize): ditto.
|
||||
|
||||
Mon Nov 29 15:22:28 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* test/io/nonblock/test_flush.rb: abandon tests when io/nonblock is
|
||||
|
|
8
io.c
8
io.c
|
@ -2321,13 +2321,19 @@ rb_io_sysread(argc, argv, io)
|
|||
if (READ_DATA_BUFFERED(fptr->f)) {
|
||||
rb_raise(rb_eIOError, "sysread for buffered IO");
|
||||
}
|
||||
rb_str_locktmp(str);
|
||||
|
||||
n = fileno(fptr->f);
|
||||
rb_thread_wait_fd(fileno(fptr->f));
|
||||
rb_io_check_closed(fptr);
|
||||
if (RSTRING(str)->len != ilen) {
|
||||
rb_raise(rb_eRuntimeError, "buffer string modified");
|
||||
}
|
||||
TRAP_BEG;
|
||||
n = read(fileno(fptr->f), RSTRING(str)->ptr, RSTRING(str)->len);
|
||||
n = read(fileno(fptr->f), RSTRING(str)->ptr, ilen);
|
||||
TRAP_END;
|
||||
|
||||
rb_str_unlocktmp(str);
|
||||
if (n == -1) {
|
||||
rb_str_resize(str, 0);
|
||||
rb_sys_fail(fptr->path);
|
||||
|
|
|
@ -47,6 +47,9 @@ class OpenStruct
|
|||
@table = {}
|
||||
if hash
|
||||
for k,v in hash
|
||||
if $DEBUG and self.respond_to?(k, true)
|
||||
raise NameError, "already existing member #{k}", caller(2)
|
||||
end
|
||||
@table[k.to_sym] = v
|
||||
end
|
||||
end
|
||||
|
@ -58,13 +61,6 @@ class OpenStruct
|
|||
@table = @table.dup
|
||||
end
|
||||
|
||||
def new_ostruct_member(name)
|
||||
self.instance_eval %{
|
||||
def #{name}; @table[:#{name}]; end
|
||||
def #{name}=(x); @table[:#{name}] = x; end
|
||||
}
|
||||
end
|
||||
|
||||
def method_missing(mid, *args) # :nodoc:
|
||||
mname = mid.id2name
|
||||
len = args.length
|
||||
|
@ -76,8 +72,10 @@ class OpenStruct
|
|||
raise TypeError, "can't modify frozen #{self.class}", caller(1)
|
||||
end
|
||||
mname.chop!
|
||||
if $DEBUG and self.respond_to?(mname, true)
|
||||
raise NameError, "already existing member #{mname}", caller(1)
|
||||
end
|
||||
@table[mname.intern] = args[0]
|
||||
self.new_ostruct_member(mname)
|
||||
elsif len == 0
|
||||
@table[mid]
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue