diff options
-rw-r--r-- | ChangeLog | 27 | ||||
-rw-r--r-- | dir.c | 20 | ||||
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | file.c | 2 | ||||
-rw-r--r-- | hash.c | 61 | ||||
-rw-r--r-- | lib/set.rb | 14 | ||||
-rw-r--r-- | object.c | 2 |
7 files changed, 57 insertions, 71 deletions
@@ -1,3 +1,7 @@ +Sat Dec 18 10:51:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * dir.c (dir_open_dir): new function. [ruby-dev:25242] + Fri Dec 17 18:07:01 2004 Shugo Maeda <shugo@ruby-lang.org> * test/readline/test_readline.rb: fix for BSD. Thanks, GOTOU Yuuzou. @@ -122,6 +126,14 @@ Thu Dec 16 03:14:28 2004 Minero Aoki <aamine@loveruby.net> include multiple CR/LFs. Backported from main trunk (rev 1.112). [ruby-dev:25212] +Thu Dec 16 00:33:37 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * hash.c (Init_Hash): remove custom "hash" and "eql?". + +Wed Dec 15 18:57:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * lib/set.rb (Set::eql): wrong definition. [ruby-dev:25207] + Wed Dec 15 18:48:42 2004 Shugo Maeda <shugo@ruby-lang.org> * ext/curses/curses.c (window_subwin): call NUM2INT() before @@ -137,6 +149,16 @@ Wed Dec 15 15:39:32 2004 GOTOU Yuuzou <gotoyuzo@notwork.org> * ext/openssl/ossl_x509name.c (ossl_x509name_to_a): avoid SEGV (rollback the previous commit). +Wed Dec 15 16:10:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * object.c (rb_obj_id_obsolete): warn always. + + * eval.c (rb_enable_super): ditto. + +Wed Dec 15 15:31:02 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * lib/set.rb (Set#==): [ruby-dev:25206] + Wed Dec 15 14:22:10 2004 NAKAMURA Usaku <usa@ruby-lang.org> * win32/win32.c (rb_w32_fdisset): check whether the handle is valid. @@ -1252,6 +1274,11 @@ Fri Oct 22 00:20:33 2004 Nobuyoshi Nakada <nobu@ruby-lang.org> * string.c (rb_str_include): should not treat char as negative value. [ruby-dev:24558] +Thu Oct 21 21:32:30 2004 IWATSUKI Hiroyuki <don@na.rim.or.jp> + + * lib/pstore.rb (PStore#transaction): Use the empty content when a + file is not found. [ruby-dev:24561] + Thu Oct 21 19:06:15 2004 GOTOU Yuuzou <gotoyuzo@notwork.org> * lib/webrick/httpresponse.rb (WEBrick::HTTPResponse#send_body_io): @@ -1318,6 +1318,22 @@ dir_s_glob(argc, argv, obj) return rb_push_glob(str, flags); } +static VALUE +dir_open_dir(path) + VALUE path; +{ + struct dir_data *dp; + VALUE dir = rb_funcall(rb_cDir, rb_intern("open"), 1, path); + + if (TYPE(dir) != T_DATA || + RDATA(dir)->dfree != (RUBY_DATA_FUNC)free_dir) { + rb_raise(rb_eTypeError, "wrong argument type %s (expected Dir)", + rb_obj_classname(dir)); + } + return dir; +} + + /* * call-seq: * Dir.foreach( dirname ) {| filename | block } => nil @@ -1341,7 +1357,7 @@ dir_foreach(io, dirname) { VALUE dir; - dir = rb_funcall(rb_cDir, rb_intern("open"), 1, dirname); + dir = dir_open_dir(dirname); rb_ensure(dir_each, dir, dir_close, dir); return Qnil; } @@ -1363,7 +1379,7 @@ dir_entries(io, dirname) { VALUE dir; - dir = rb_funcall(rb_cDir, rb_intern("open"), 1, dirname); + dir = dir_open_dir(dirname); return rb_ensure(rb_Array, dir, dir_close, dir); } @@ -538,7 +538,7 @@ rb_enable_super(klass, name) VALUE klass; const char *name; { - rb_warning("rb_enable_super() is obsolete"); + rb_warn("rb_enable_super() is obsolete"); } static void @@ -2901,7 +2901,7 @@ rb_file_truncate(obj, len) # define LOCK_UN 8 # endif -#if 0 +#if 1 static int rb_thread_flock(fd, op, fptr) int fd, op; @@ -1503,65 +1503,6 @@ rb_hash_equal(hash1, hash2) return hash_equal(hash1, hash2, Qfalse); } -/* - * call-seq: - * hsh.eql?(other_hash) => true or false - * - * Returns true if two hashes are equal, i.e they have same key-value set, - * and same default values. - * - */ - -static VALUE -rb_hash_eql(hash1, hash2) - VALUE hash1, hash2; -{ - return hash_equal(hash1, hash2, Qtrue); -} - - -rb_hash_hash_i(key, value, hp) - VALUE key, value; - long *hp; -{ - long h = *hp; - VALUE n; - - h = (h << 1) | (h<0 ? 1 : 0); - n = rb_hash(key); - h ^= NUM2LONG(n); - h = (h << 1) | (h<0 ? 1 : 0); - n = rb_hash(value); - h ^= NUM2LONG(n); - - *hp = h; - return ST_CONTINUE; -} - -/* - * call-seq: - * hash.hash -> fixnum - * - * Compute a hash-code for this hash. Two hashes with the same content - * will have the same hash code (and will compare using <code>eql?</code>). - */ - -static VALUE -rb_hash_hash(hash) - VALUE hash; -{ - long h; - VALUE n; - - h = RHASH(hash)->tbl->num_entries; - rb_hash_foreach(hash, rb_hash_hash_i, (VALUE)&h); - h = (h << 1) | (h<0 ? 1 : 0); - n = rb_hash(RHASH(hash)->ifnone); - h ^= NUM2LONG(n); - - return LONG2FIX(h); -} - static int rb_hash_invert_i(key, value, hash) VALUE key, value; @@ -2496,8 +2437,6 @@ Init_Hash() rb_define_method(rb_cHash,"inspect", rb_hash_inspect, 0); rb_define_method(rb_cHash,"==", rb_hash_equal, 1); - rb_define_method(rb_cHash,"eql?", rb_hash_eql, 1); - rb_define_method(rb_cHash,"hash", rb_hash_hash, 0); rb_define_method(rb_cHash,"[]", rb_hash_aref, 1); rb_define_method(rb_cHash,"fetch", rb_hash_fetch, -1); rb_define_method(rb_cHash,"[]=", rb_hash_aset, 2); diff --git a/lib/set.rb b/lib/set.rb index 23d7b847e..4a9256a33 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -251,7 +251,7 @@ class Set # Merges the elements of the given enumerable object to the set and # returns self. def merge(enum) - if enum.class == self.class + if enum.is_a?(Set) @hash.update(enum.instance_eval { @hash }) else enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" @@ -291,7 +291,7 @@ class Set def &(enum) enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" n = self.class.new - enum.each { |o| include?(o) and n.add(o) } + enum.each { |o| n.add(o) if include?(o) } n end alias intersection & ## @@ -313,7 +313,8 @@ class Set set.is_a?(Set) && size == set.size or return false - set.all? { |o| include?(o) } + hash = @hash.dup + set.all? { |o| hash.include?(o) } end def hash # :nodoc: @@ -321,7 +322,8 @@ class Set end def eql?(o) # :nodoc: - @hash.hash == o.hash + return false unless o.is_a?(Set) + @hash.eql?(o.instance_eval{@hash}) end # Classifies the set by the return value of the given block and @@ -583,7 +585,9 @@ end # else # instance_eval %{ # def add(o) -# @hash[o] = true if @proc.call(o) +# if @proc.call(o) +# @hash[o] = true +# end # self # end # alias << add @@ -149,7 +149,7 @@ VALUE rb_obj_id_obsolete(obj) VALUE obj; { - rb_warning("Object#id will be deprecated; use Object#object_id"); + rb_warn("Object#id will be deprecated; use Object#object_id"); return rb_obj_id(obj); } |