summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--array.c27
-rw-r--r--hash.c32
-rw-r--r--lib/mkmf.rb4
-rw-r--r--mkconfig.rb3
5 files changed, 29 insertions, 49 deletions
diff --git a/ChangeLog b/ChangeLog
index a9a727c6f6..9aec4727a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Fri Sep 8 01:16:34 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (Init_Array): #to_s to be an alias to #inspect.
+ [ruby-dev:29520]
+
+ * hash.c (Init_Hash): ditto.
+
+ * lib/mkmf.rb (create_makefile): replace "print array" by
+ "print *array".
+
+ * mkconfig.rb: ditto.
+
Thu Sep 7 21:02:56 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* object.c (nil_to_s): returns the empty string again.
diff --git a/array.c b/array.c
index 508c123134..cb3644837b 100644
--- a/array.c
+++ b/array.c
@@ -1374,24 +1374,6 @@ rb_ary_join_m(int argc, VALUE *argv, VALUE ary)
return rb_ary_join(ary, sep);
}
-/*
- * call-seq:
- * array.to_s -> string
- *
- * Returns _self_<code>.join</code>.
- *
- * [ "a", "e", "i", "o" ].to_s #=> "aeio"
- *
- */
-
-VALUE
-rb_ary_to_s(VALUE ary)
-{
- if (RARRAY_LEN(ary) == 0) return rb_str_new(0, 0);
-
- return rb_ary_join(ary, rb_output_fs);
-}
-
static VALUE
inspect_ary(VALUE ary, VALUE dummy, int recur)
{
@@ -1414,6 +1396,7 @@ inspect_ary(VALUE ary, VALUE dummy, int recur)
/*
* call-seq:
+ * array.to_s -> string
* array.inspect -> string
*
* Create a printable version of <i>array</i>.
@@ -1426,6 +1409,12 @@ rb_ary_inspect(VALUE ary)
return rb_exec_recursive(inspect_ary, ary, 0);
}
+VALUE
+rb_ary_to_s(VALUE ary)
+{
+ return rb_ary_inspect(ary);
+}
+
/*
* call-seq:
* array.to_a -> array
@@ -2963,7 +2952,7 @@ Init_Array(void)
rb_define_method(rb_cArray, "initialize", rb_ary_initialize, -1);
rb_define_method(rb_cArray, "initialize_copy", rb_ary_replace, 1);
- rb_define_method(rb_cArray, "to_s", rb_ary_to_s, 0);
+ rb_define_method(rb_cArray, "to_s", rb_ary_inspect, 0);
rb_define_method(rb_cArray, "inspect", rb_ary_inspect, 0);
rb_define_method(rb_cArray, "to_a", rb_ary_to_a, 0);
rb_define_method(rb_cArray, "to_ary", rb_ary_to_ary_m, 0);
diff --git a/hash.c b/hash.c
index 866e5ceadb..10acf1487a 100644
--- a/hash.c
+++ b/hash.c
@@ -1147,9 +1147,13 @@ inspect_hash(VALUE hash, VALUE dummy, int recur)
/*
* call-seq:
+ * hsh.to_s => string
* hsh.inspect => string
*
* Return the contents of this hash as a string.
+ *
+ * h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 }
+ * h.to_s #=> "{\"a\"=>100, \"c\"=>300, \"d\"=>400}"
*/
static VALUE
@@ -1160,32 +1164,6 @@ rb_hash_inspect(VALUE hash)
return rb_exec_recursive(inspect_hash, hash, 0);
}
-static VALUE
-to_s_hash(VALUE hash, VALUE dummy, int recur)
-{
- if (recur) return rb_str_new2("{...}");
- return rb_ary_to_s(rb_hash_to_a(hash));
-}
-
-/*
- * call-seq:
- * hsh.to_s => string
- *
- * Converts <i>hsh</i> to a string by converting the hash to an array
- * of <code>[</code> <i>key, value</i> <code>]</code> pairs and then
- * converting that array to a string using <code>Array#join</code> with
- * the default separator.
- *
- * h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 }
- * h.to_s #=> "a100c300d400"
- */
-
-static VALUE
-rb_hash_to_s(VALUE hash)
-{
- return rb_exec_recursive(to_s_hash, hash, 0);
-}
-
/*
* call-seq:
* hsh.to_hash => hsh
@@ -2299,7 +2277,7 @@ Init_Hash(void)
rb_define_method(rb_cHash,"to_hash", rb_hash_to_hash, 0);
rb_define_method(rb_cHash,"to_a", rb_hash_to_a, 0);
- rb_define_method(rb_cHash,"to_s", rb_hash_to_s, 0);
+ rb_define_method(rb_cHash,"to_s", rb_hash_inspect, 0);
rb_define_method(rb_cHash,"inspect", rb_hash_inspect, 0);
rb_define_method(rb_cHash,"==", rb_hash_equal, 1);
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index a09d8d7cab..fb66d0cdec 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -1205,7 +1205,7 @@ def create_makefile(target, srcprefix = nil)
dllib = target ? "$(TARGET).#{CONFIG['DLEXT']}" : ""
staticlib = target ? "$(TARGET).#$LIBEXT" : ""
mfile = open("Makefile", "wb")
- mfile.print configuration(srcprefix)
+ mfile.print *configuration(srcprefix)
mfile.print %{
libpath = #{$LIBPATH.join(" ")}
LIBPATH = #{libpath}
@@ -1390,7 +1390,7 @@ site-install-rb: install-rb
unless suffixes.empty?
mfile.print ".SUFFIXES: .", suffixes.uniq.join(" ."), "\n\n"
end
- mfile.print depout
+ mfile.print *depout
else
headers = %w[ruby.h defines.h]
if RULE_SUBST
diff --git a/mkconfig.rb b/mkconfig.rb
index 9de524c785..c0ebe96e7e 100644
--- a/mkconfig.rb
+++ b/mkconfig.rb
@@ -106,7 +106,8 @@ if $so_name
v_fast << " CONFIG[\"RUBY_SO_NAME\"] = \"" + $so_name + "\"\n"
end
-print v_fast, v_others
+print *v_fast
+print *v_others
print <<EOS
CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"