diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-04-05 15:55:09 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-04-05 15:55:09 +0000 |
commit | ce44928d2b4d32b41f9a19097fb7bd7b2c13c4bd (patch) | |
tree | e2e9c28e8caf5535b343988de6fa23ed0f941695 | |
parent | cded3d5c93f0964fc504a4344146e3624a9875a1 (diff) | |
download | ruby-ce44928d2b4d32b41f9a19097fb7bd7b2c13c4bd.tar.gz |
* error.c (Init_Exception): remove Exception#to_str. [Ruby2]
* eval.c (error_print): should no call "to_str" anymore use
"message" method instead.
* io.c (rb_f_open): Kernel#open() calls "to_open" if the first
argument responds to it. [Ruby2]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | .cvsignore | 1 | ||||
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | ToDo | 14 | ||||
-rw-r--r-- | error.c | 6 | ||||
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | io.c | 13 | ||||
-rw-r--r-- | lib/optparse.rb | 2 | ||||
-rw-r--r-- | lib/pathname.rb | 4 |
8 files changed, 34 insertions, 18 deletions
diff --git a/.cvsignore b/.cvsignore index 309f85c515..0c885edbf7 100644 --- a/.cvsignore +++ b/.cvsignore @@ -6,6 +6,7 @@ .ccmalloc .ppack .ext +.rbconfig.time COPYING.LIB ChangeLog.pre-alpha ChangeLog.pre1_1 @@ -1,3 +1,13 @@ +Tue Apr 6 00:14:43 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * error.c (Init_Exception): remove Exception#to_str. [Ruby2] + + * eval.c (error_print): should no call "to_str" anymore use + "message" method instead. + + * io.c (rb_f_open): Kernel#open() calls "to_open" if the first + argument responds to it. [Ruby2] + Tue Apr 6 00:13:43 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp> * lib/rinda/rinda.rb: add require 'drb/drb' @@ -2,6 +2,10 @@ Language Spec. - Class#allocate - basicNew - class Foo::Bar<Baz .. end, module Boo::Bar .. end +- raise exception by `` error +- a +1 to be a+1, not a(+1). +- clarify evaluation order of operator argument (=~, .., ...) +- :symbol => value hash in the form of {symbol: value, ...} ?? * operator !! for rescue. ??? * objectify characters * ../... outside condition invokes operator method too. @@ -14,7 +18,6 @@ Language Spec. * def Class#method .. end ?? * def Foo::Bar::baz() .. end ?? * I18N (or M17N) script/string/regexp -* Fixnum 0 as false ???? * discourage use of symbol variables (e.g. $/, etc.) in manual * discourage use of Perlish features by giving warnings. * non confusing in-block local variable (is it possible?) @@ -22,12 +25,9 @@ Language Spec. + variables appears within block may have independent values. * Regexp: make /o thread safe. * decide whether begin with rescue or ensure make do..while loop. -* a +1 to be a+1, not a(+1). * unify == and eql? again * to_i returns nil if str contains no digit. -* raise exception by `` error * jar like combined library package. -> RubyGems? -* resumable Exception via Exception#resume. * method combination, e.g. before, after, around, etc. * .. or something like defadvice in Emacs. * property - for methods, or for objects in general. @@ -35,8 +35,6 @@ Language Spec. * selector namespace - something like generic-flet in CLOS, to help RubyBehavior * private instance variable (as in Python?) @_foo in class Foo => @_Foo_foo * warn/error "bare word" method, like "foo", you should type "foo()" -* clarify evaluation order of operator argument (=~, .., ...) -* :symbol => value hash in the form of {symbol: value, ...} ?? Hacking Interpreter @@ -83,7 +81,7 @@ Standard Libraries - use Mersenne Twister RNG for random. - deprecate Array#indexes, and Array#indices. - remove dependency on MAXPATHLEN. -* String#scanf(?) +- String#scanf(?) * Object#fmt(?) * Time::strptime * Integer[num], Float[num]; Fixnum[num]? @@ -117,7 +115,7 @@ Extension Libraries Ruby Libraries -* urllib.rb, nttplib.rb, etc. +- urllib.rb, nttplib.rb, etc. * format like perl's Tools @@ -405,7 +405,6 @@ exc_to_s(exc) /* * call-seq: * exception.message => string - * exception.to_str => string * * Returns the result of invoking <code>exception.to_s</code>. * Normally this returns the exception's message or name. By @@ -414,7 +413,7 @@ exc_to_s(exc) */ static VALUE -exc_to_str(exc) +exc_message(exc) VALUE exc; { return rb_funcall(exc, rb_intern("to_s"), 0, 0); @@ -962,8 +961,7 @@ Init_Exception() rb_define_method(rb_eException, "exception", exc_exception, -1); rb_define_method(rb_eException, "initialize", exc_initialize, -1); rb_define_method(rb_eException, "to_s", exc_to_s, 0); - rb_define_method(rb_eException, "to_str", exc_to_str, 0); - rb_define_method(rb_eException, "message", exc_to_str, 0); + rb_define_method(rb_eException, "message", exc_message, 0); rb_define_method(rb_eException, "inspect", exc_inspect, 0); rb_define_method(rb_eException, "backtrace", exc_backtrace, 0); rb_define_method(rb_eException, "set_backtrace", exc_set_backtrace, 1); @@ -1125,7 +1125,7 @@ error_print() eclass = CLASS_OF(ruby_errinfo); if (EXEC_TAG() == 0) { - e = rb_obj_as_string(ruby_errinfo); + e = rb_funcall(ruby_errinfo, rb_intern("message"), 0, 0); einfo = RSTRING(e)->ptr; elen = RSTRING(e)->len; } @@ -3039,10 +3039,17 @@ rb_f_open(argc, argv) VALUE *argv; { if (argc >= 1) { - char *str = StringValuePtr(argv[0]); + ID to_open = rb_intern("to_open"); - if (str[0] == '|') { - return rb_io_popen(str+1, argc, argv, rb_cIO); + if (rb_respond_to(argv[0], to_open)) { + return rb_funcall2(argv[0], to_open, argc-1, argv+1); + } + else { + char *str = StringValuePtr(argv[0]); + + if (str[0] == '|') { + return rb_io_popen(str+1, argc, argv, rb_cIO); + } } } return rb_io_s_open(argc, argv, rb_cFile); diff --git a/lib/optparse.rb b/lib/optparse.rb index 4a979a78d1..761504a82f 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -1584,7 +1584,6 @@ Base class of exceptions from ((<OptionParser>)) Returns inspection string. --- OptionParser::ParseError#message --- OptionParser::ParseError#to_s ---- OptionParser::ParseError#to_str Default stringizing method to emit standard error message. =end #'#"#`# class ParseError < RuntimeError @@ -1625,7 +1624,6 @@ Base class of exceptions from ((<OptionParser>)) end alias to_s message - alias to_str message end =begin diff --git a/lib/pathname.rb b/lib/pathname.rb index a6d0599610..c87a6e91ce 100644 --- a/lib/pathname.rb +++ b/lib/pathname.rb @@ -229,6 +229,10 @@ class Pathname "#<#{self.class}:#{@path}>" end + def to_open(*args) # :nodoc: + Kernel::open(@path, *args) + end + # # Returns clean pathname of +self+ with consecutive slashes and useless dots # removed. The filesystem is not accessed. |