summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--array.c7
-rw-r--r--hash.c28
-rw-r--r--version.h8
4 files changed, 40 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 57b7d73..e996741 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Fri Nov 2 00:13:51 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_assoc): check and convert inner arrays (assocs)
+ using #to_ary.
+
+ * hash.c (rb_hash_s_create): check and convert argument hash
+ using #to_hash.
+
+ * hash.c (rb_hash_s_create): Hash#[] now takes assocs as source of
+ hash conversion.
+
Thu Nov 1 23:47:43 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.rb (DRbTCPSocket): Improving with multiple network
diff --git a/array.c b/array.c
index 835e76b..44ca19a 100644
--- a/array.c
+++ b/array.c
@@ -2420,10 +2420,9 @@ rb_ary_assoc(ary, key)
VALUE v;
for (i = 0; i < RARRAY(ary)->len; ++i) {
- v = RARRAY(ary)->ptr[i];
- if (TYPE(v) == T_ARRAY &&
- RARRAY(v)->len > 0 &&
- rb_equal(RARRAY(v)->ptr[0], key))
+ v = rb_check_array_type(RARRAY_PTR(ary)[i]);
+ if (!NIL_P(v) && RARRAY(v)->len > 0 &&
+ rb_equal(RARRAY_PTR(v)[0], key))
return v;
}
return Qnil;
diff --git a/hash.c b/hash.c
index 8b33a54..0878875 100644
--- a/hash.c
+++ b/hash.c
@@ -336,16 +336,32 @@ rb_hash_s_create(argc, argv, klass)
VALUE *argv;
VALUE klass;
{
- VALUE hash;
+ VALUE hash, tmp;
int i;
- if (argc == 1 && TYPE(argv[0]) == T_HASH) {
- hash = hash_alloc0(klass);
- RHASH(hash)->tbl = st_copy(RHASH(argv[0])->tbl);
+ if (argc == 1) {
+ tmp = rb_check_convert_type(argv[0], T_HASH, "Hash", "to_hash");
+ if (!NIL_P(tmp)) {
+ hash = hash_alloc0(klass);
+ RHASH(hash)->tbl = st_copy(RHASH(tmp)->tbl);
+ return hash;
+ }
- return hash;
+ tmp = rb_check_array_type(argv[0]);
+ if (!NIL_P(tmp)) {
+ long i;
+
+ hash = hash_alloc(klass);
+ for (i = 0; i < RARRAY_LEN(tmp); ++i) {
+ VALUE v = rb_check_array_type(RARRAY_PTR(tmp)[i]);
+
+ if (NIL_P(v)) continue;
+ if (RARRAY_LEN(v) < 1 || 2 < RARRAY_LEN(v)) continue;
+ rb_hash_aset(hash, RARRAY_PTR(v)[0], RARRAY_PTR(v)[1]);
+ }
+ return hash;
+ }
}
-
if (argc % 2 != 0) {
rb_raise(rb_eArgError, "odd number of arguments for Hash");
}
diff --git a/version.h b/version.h
index 76c3c13..613a814 100644
--- a/version.h
+++ b/version.h
@@ -1,15 +1,15 @@
#define RUBY_VERSION "1.8.6"
-#define RUBY_RELEASE_DATE "2007-10-26"
+#define RUBY_RELEASE_DATE "2007-11-02"
#define RUBY_VERSION_CODE 186
-#define RUBY_RELEASE_CODE 20071026
+#define RUBY_RELEASE_CODE 20071102
#define RUBY_PATCHLEVEL 5000
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 6
#define RUBY_RELEASE_YEAR 2007
-#define RUBY_RELEASE_MONTH 10
-#define RUBY_RELEASE_DAY 26
+#define RUBY_RELEASE_MONTH 11
+#define RUBY_RELEASE_DAY 2
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];