mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* array.c (Init_Array): #to_s to be an alias to #inspect.
[EXPERIMENTAL] [ruby-dev:29520] * hash.c (Init_Hash): ditto. * lib/mkmf.rb (create_makefile): replace "print array" by "print *array". * mkconfig.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b06a278942
commit
d1cb9e75d0
5 changed files with 29 additions and 49 deletions
12
ChangeLog
12
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.
|
||||
|
|
27
array.c
27
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);
|
||||
|
|
32
hash.c
32
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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)"
|
||||
|
|
Loading…
Reference in a new issue