summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog241
-rw-r--r--array.c144
-rw-r--r--bignum.c6
-rw-r--r--class.c18
-rw-r--r--common.mk3
-rw-r--r--dir.c45
-rw-r--r--env.h6
-rw-r--r--error.c2
-rw-r--r--eval.c246
-rw-r--r--ext/Win32API/Win32API.c2
-rw-r--r--ext/bigdecimal/bigdecimal.c14
-rw-r--r--ext/curses/curses.c21
-rw-r--r--ext/curses/extconf.rb2
-rw-r--r--ext/dl/cfunc.c4
-rw-r--r--ext/dl/cptr.c2
-rw-r--r--ext/dl/handle.c6
-rw-r--r--ext/etc/etc.c6
-rw-r--r--ext/iconv/iconv.c2
-rw-r--r--ext/openssl/ossl_cipher.c4
-rw-r--r--ext/pty/pty.c4
-rw-r--r--ext/readline/readline.c12
-rw-r--r--ext/socket/socket.c32
-rw-r--r--ext/strscan/strscan.c4
-rw-r--r--ext/tk/tcltklib.c28
-rw-r--r--ext/win32ole/win32ole.c118
-rw-r--r--ext/zlib/zlib.c6
-rw-r--r--file.c10
-rw-r--r--gc.c2
-rw-r--r--hash.c83
-rw-r--r--intern.h5
-rw-r--r--io.c62
-rw-r--r--lib/date.rb2
-rw-r--r--lib/fileutils.rb2
-rw-r--r--lib/irb/context.rb2
-rw-r--r--lib/open3.rb2
-rw-r--r--lib/parsedate.rb7
-rw-r--r--lib/pstore.rb12
-rw-r--r--lib/rdoc/generators/html_generator.rb6
-rw-r--r--lib/rdoc/generators/ri_generator.rb2
-rw-r--r--lib/rdoc/parsers/parse_c.rb156
-rw-r--r--lib/rdoc/parsers/parse_rb.rb22
-rw-r--r--lib/rdoc/parsers/parse_simple.rb6
-rw-r--r--lib/rexml/document.rb8
-rw-r--r--lib/rexml/element.rb2
-rw-r--r--lib/rexml/instruction.rb4
-rw-r--r--lib/rexml/xmldecl.rb108
-rw-r--r--lib/set.rb5
-rw-r--r--lib/time.rb72
-rw-r--r--lib/timeout.rb52
-rw-r--r--lib/wsdl/soap/definitions.rb4
-rw-r--r--lib/xmlrpc/parser.rb2
-rw-r--r--marshal.c4
-rw-r--r--misc/ruby-mode.el6
-rw-r--r--numeric.c8
-rw-r--r--object.c79
-rw-r--r--pack.c4
-rw-r--r--parse.y84
-rw-r--r--process.c8
-rw-r--r--range.c4
-rw-r--r--regint.h2
-rw-r--r--regparse.c104
-rw-r--r--ruby.c10
-rw-r--r--sample/test.rb26
-rw-r--r--signal.c2
-rw-r--r--sprintf.c2
-rw-r--r--st.c138
-rw-r--r--st.h16
-rw-r--r--string.c36
-rw-r--r--struct.c41
-rw-r--r--test/logger/test_logger.rb20
-rw-r--r--test/ruby/test_iterator.rb18
-rw-r--r--time.c1
-rw-r--r--variable.c3
73 files changed, 1312 insertions, 920 deletions
diff --git a/ChangeLog b/ChangeLog
index ab03a6dbcf..29f4a0a0f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,41 @@
+Fri Mar 4 12:45:17 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c: replace rb_protect_inspect() and rb_inspecting_p() by
+ rb_exec_recursive() in eval.c.
+
+ * eval.c (rb_exec_recursive): new function.
+
+ * array.c (rb_ary_join): use rb_exec_recursive().
+
+ * array.c (rb_ary_inspect, rb_ary_hash): ditto.
+
+ * file.c (rb_file_join): ditto.
+
+ * hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
+
+ * io.c (rb_io_puts): ditto.
+
+ * object.c (rb_obj_inspect): ditto
+
+ * struct.c (rb_struct_inspect): ditto.
+
+Fri Mar 4 10:15:30 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/set.rb (SortedSet::setup): a hack to shut up warning.
+ [ruby-talk:132866]
+
Fri Mar 4 09:37:12 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* common.mk (install-nodoc, pre-install-doc, post-install-doc):
fix some omissions.
+Fri Mar 4 08:09:12 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/time.rb (Time::strptime): add new function. inspired by
+ [ruby-talk:132815].
+
+ * lib/parsedate.rb (ParseDate::strptime): ditto.
+
Thu Mar 4 07:07:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/nkf-utf8/nkf.c: follow nkf 1.63
@@ -119,13 +152,17 @@ Tue Mar 1 21:16:54 2005 K.Kosako <sndgk393 AT ybb.ne.jp>
* regcomp.c (optimize_node_left): uninitialized member
(OptEnv.backrefed_status) was used. [ruby-dev:25778]
+Tue Mar 1 16:50:37 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regparse.c: move st_*_strend() functions from st.c. fixed some
+ potential memory leaks.
+
Tue Mar 1 00:40:35 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/rinda/tuplespace.rb (Rinda::TupleSpace): improved keeper thread.
* test/rinda/test_rinda.rb: ditto.
-
Mon Feb 28 23:10:13 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/socket/socket.c (Init_socket): IPv6 is not supported although
@@ -151,6 +188,16 @@ Mon Feb 28 15:12:06 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/socket/mkconstants.rb: ditto. (added)
+Mon Feb 28 11:42:23 2005 Ian Macdonald <ian@caliban.org>
+
+ * exception error messages updated. [ruby-core:04497]
+
+Mon Feb 28 09:03:09 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/socket.c (Init_socket): add bunch of Socket
+ constants. Patch from Sam Roberts <sroberts@uniserve.com>.
+ [ruby-core:04409]
+
Sun Feb 27 05:55:38 2005 Minero Aoki <aamine@loveruby.net>
* parse.y [ripper]: fix typo. [ruby-core:04494]
@@ -177,6 +224,13 @@ Thu Feb 23 15:04:32 2005 akira yamada <akira@ruby-lang.org>
* lib/uri/generic.rb (split_userinfo): should split ":pass" into ""
and "pass". [ruby-dev:25667]
+Wed Feb 23 08:00:18 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_s_create): no need for negative argc check.
+ [ruby-core:04463]
+
+ * array.c (rb_ary_unshift_m): ditto.
+
Wed Feb 23 01:53:29 2005 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (initialize): handle certs correctly. Thanks,
@@ -264,7 +318,17 @@ Sat Feb 19 01:28:56 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/bigdecimal/lib/bigdecimal/nlsolve.rb: removed because this file
is sample script and same file exists in ext/bigdecimal/sample.
-Thu Feb 17 22:15:34 2005 K.Kosako <sndgk393 AT ybb.ne.jp>
+Fri Feb 18 17:14:00 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
+ of StandardError class, not Exception class. [ruby-core:04429]
+
+Fri Feb 18 04:06:41 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (fcall_gen): lvar(arg) will be evaluated as
+ lvar.call(arg) when lvar is a defined local variable. [new]
+
+Thu Feb 17 22:15:34 2005 K.Kosako <sndgk@ybb.ne.jp>
* ext/strscan/strscan.c: calls Oniguruma API directly.
@@ -286,6 +350,9 @@ Thu Feb 17 20:09:23 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
Thu Feb 17 14:31:52 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * object.c (rb_class_initialize): call inherited method before
+ calling initializing block.
+
* eval.c (rb_thread_start_1): initialize newly pushed frame.
fixed: [ruby-dev:25707]
@@ -302,10 +369,19 @@ Thu Feb 17 13:46:00 2005 Nathaniel Talbott <ntalbott@ruby-lang.org>
* lib/test/unit.rb: ditto.
+Thu Feb 17 04:21:47 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
+ fixed: [ruby-core:04444]
+
Thu Feb 17 00:31:21 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* test/drb/test_drb.rb, ut_safe1.rb: port from 1.8
+Thu Feb 17 00:02:27 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (is_defined): NODE_IASGN is an assignment.
+
Wed Feb 16 23:54:14 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_thread_start_1): outer block variables wasn't linked to
@@ -331,6 +407,11 @@ Wed Feb 16 02:47:45 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/lib/openssl/ssl.rb: set non-blocking flag to the
underlying IO.
+Tue Feb 15 22:14:34 2005 sheepman <sheepman@tcn.zaq.ne.jp>
+
+ * ext/readline/readline.c (Readline.readline): use rl_outstream
+ and rl_instream. [ruby-dev:25699]
+
Mon Feb 14 23:58:17 2005 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/parser.rb (RSS::ListenerMixin::tag_end):
@@ -414,6 +495,11 @@ Sat Feb 12 13:54:03 2005 Tanaka Akira <akr@m17n.org>
* lib/open-uri.rb: support https if the platform provides CA
certificates.
+Sat Feb 12 06:18:28 2005 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
+
+ * ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
+ [ruby-dev:25675]
+
Fri Feb 11 17:37:50 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_x509store.c (ossl_x509store_set_default_paths):
@@ -425,6 +511,16 @@ Fri Feb 11 11:33:53 2005 Tanaka Akira <akr@m17n.org>
:http_basic_authentication.
suggested by Kent Sibilev. [ruby-core:4392]
+Fri Feb 11 06:30:07 2005 George Ogata <g_ogata@optushome.com.au>
+
+ * misc/ruby-mode.el: [ruby-core:04415]
+
+Fri Feb 11 04:54:13 2005 Tilman Sauerbeck <tilman@code-monkey.de>
+
+ * lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
+
+ * lib/rdoc/generators/ri_generator.rb: ditto.
+
Thu Feb 10 13:52:42 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* configure.in, win32/Makefile.sub (LIBS, COMMON_HEADERS): use
@@ -456,6 +552,10 @@ Thu Feb 10 12:07:10 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/win32.c, win32/win32.h (read): avoid a BCC runtime bug.
+Thu Feb 10 00:47:25 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * struct.c (make_struct): fixed: [ruby-core:04402]
+
Wed Feb 9 16:33:05 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/socket/socket.c (wait_connectable): fixed wrong condition.
@@ -470,6 +570,10 @@ Wed Feb 9 10:02:02 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/tk/tkutil/extconf.rb: need to compile tkutil. [ruby-dev:25607]
+Wed Feb 9 08:07:08 2005 Paul Duncan <pabs@pablotron.org>
+
+ * ext/curses/curses.c (window_color_set): [ruby-core:04393]
+
Tue Feb 8 23:48:36 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.rb: reject :instance_eval, :class_eval, :module_eval
@@ -480,6 +584,11 @@ Tue Feb 8 22:38:28 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* keywords, parse.y: separate EXPR_VALUE from EXPR_BEG.
fixed: [ruby-core:04310], [ruby-core:04368]
+Tue Feb 8 13:06:12 2005 Sam Roberts <sroberts@uniserve.com>
+
+ * ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
+ [ruby-talk:130092]
+
Tue Feb 8 00:19:02 2005 Tanaka Akira <akr@m17n.org>
* lib/resolv.rb (Resolv::DNS::Name#subdomain_of?): new method.
@@ -493,6 +602,10 @@ Mon Feb 7 23:14:11 2005 Tanaka Akira <akr@m17n.org>
* rubyio.h (FMODE_TTY): renamed from FMODE_LINEBUF.
+Mon Feb 7 10:06:30 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c: [ruby-doc:818]
+
Mon Feb 7 02:13:05 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/socket/extconf.rb (sockaddr_storage): winsock2.h have the
@@ -565,6 +678,13 @@ Fri Feb 4 18:44:35 2005 Minero Aoki <aamine@loveruby.net>
* ext/ripper/lib/ripper/lexer.rb: last Lexer fix was incomplete;
test all green.
+Fri Feb 4 15:57:06 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (open_args): fix too verbose warnings for the space
+ before argument parentheses. [ruby-dev:25492]
+
+ * parse.y (parser_yylex): ditto.
+
Fri Feb 4 14:33:25 2005 Minero Aoki <aamine@loveruby.net>
* ext/ripper/lib/ripper/filter.rb: ripper/tokenizer ->
@@ -583,6 +703,11 @@ Thu Feb 3 23:42:36 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_extend, strio_putc): fill with zero
extended portion. [ruby-dev:25626]
+Thu Feb 3 16:12:57 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (parser_yylex): the first expression in the parentheses
+ should not be a command. [ruby-dev:25492]
+
Wed Feb 3 03:31:20 2005 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/nkf-utf8/nkf.c: follow original v 1.57
@@ -658,6 +783,14 @@ Mon Jan 31 13:13:35 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/remote-tk.rb: ditto
+Mon Jan 31 10:29:18 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
+
+Mon Jan 31 09:44:03 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (Init_Object): remove Object#type. [ruby-core:04335]
+
Sat Jan 29 09:42:12 2005 Sam Roberts <sroberts@uniserve.com>
* lib/resolv.rb (Resolv::DNS::Resource::IN::SRV): Added RFC2782 SRV
@@ -684,6 +817,11 @@ Thu Jan 27 17:15:03 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/tk/extconf.rb: support new tk scheme on bccwin32.
fixed: [ruby-dev:25546]
+Thu Jan 27 13:18:03 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * st.c (st_foreach): report success/failure by return value.
+ [ruby-Bugs-1396]
+
Thu Jan 27 00:12:19 2005 Minero Aoki <aamine@loveruby.net>
* test/fileutils/test_fileutils.rb (setup): support BSD style
@@ -697,6 +835,13 @@ Thu Jan 27 00:02:40 2005 Minero Aoki <aamine@loveruby.net>
* test/fileutils/fileasserts.rb (assert_same_entry): show entry
difference.
+Wed Jan 26 17:12:50 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y: forgot to initialize parser struct. [ruby-dev:25492]
+
+ * parse.y (parser_yylex): no tLABEL on EXPR_BEG.
+ [ruby-talk:127711]
+
Wed Jan 26 14:12:58 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/Setup*: remove tcltklib.
@@ -764,6 +909,11 @@ Mon Jan 24 16:00:53 2005 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/lib/kconv.rb (guess_old): not use NKF.guess_old
but NKF.guess1. fixed: [ruby-dev:25491]
+Mon Jan 24 15:44:25 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * document updates - [ruby-core:04296], [ruby-core:04301],
+ [ruby-core:04302], [ruby-core:04307]
+
Sun Jan 23 12:38:01 2005 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
* lib/soap/wsdlDriver.rb: from 1.5.3-ruby1.8.2, operation which has
@@ -801,6 +951,12 @@ Fri Jan 21 17:09:44 2005 Shugo Maeda <shugo@ruby-lang.org>
* test/net/imap/test_imap.rb: added tests for Net::IMAP.
+Fri Jan 21 16:58:10 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (rb_push_glob): should work for NUL delimited patterns.
+
+ * dir.c (rb_glob2): should aware of offset in the pattern.
+
Fri Jan 21 13:58:37 2005 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (u8tou16): fixed typo. fixed: [ruby-list:40546]
@@ -810,6 +966,23 @@ Fri Jan 21 00:37:09 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/syck/rubyext.c (syck_parser_bufsize_set): avoid VC++ warning
"local variable 'size' used without having been initialized".
+Thu Jan 20 11:42:02 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_new4): should propagate taintedness.
+
+ * env.h: rename member names in struct FRAME; last_func -> callee,
+ orig_func -> this_func, last_class -> this_class.
+
+ * struct.c (rb_struct_set): use original method name, not callee
+ name, to retrieve member slot. [ruby-core:04268]
+
+ * time.c (time_strftime): protect from format modification from GC
+ finalizers.
+
+Thu Jan 20 02:01:10 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (Init_Object): remove rb_obj_id_obsolete()
+
Wed Jan 19 18:02:19 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* lib/ipaddr.rb (to_s, test_to_s): too many colons with some cases.
@@ -854,10 +1027,13 @@ Sat Jan 15 13:44:22 2005 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/rss.rb: accept inheritance. [ruby-talk:126104]
-Wed Jan 12 00:36:29 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Jan 12 12:29:28 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_mod_define_method): incomplete subclass check.
+ [ruby-dev:25464]
- * object.c (rb_class_superclass): superclass of singleton class also
- should be a singleton class. fixed: [ruby-list:40519]
+ * class.c (rb_make_metaclass): class of metaclasses should be
+ plain Class. [ruby-list:40524]
Tue Jan 11 20:58:52 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -869,11 +1045,6 @@ Tue Jan 11 09:37:53 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* numeric.c (Init_Numeric): turn off floating point exceptions
on bcc32. "1e300".to_f had crashed by overflow.
-Mon Jan 10 23:07:45 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * variable.c (rb_autoload): hide internal data from ruby level.
- fixed: [ruby-dev:25373]
-
Mon Jan 10 15:28:51 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/cgi.rb (WEBrick::CGI::Socket#request_line): should
@@ -889,6 +1060,11 @@ Mon Jan 10 15:28:51 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* test/webrick/utils.rb: require "webrick/https.h".
+Mon Jan 10 01:22:55 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (rb_data_object_alloc): klass may be NULL.
+ [ruby-list:40498]
+
Sun Jan 9 14:12:17 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (rb_f_select): IO list could be altered. [ruby-dev:25312]
@@ -999,6 +1175,11 @@ Wed Jan 5 02:30:11 2005 Tanaka Akira <akr@m17n.org>
(rb_f_rand): call limited_rand and limited_big_rand.
[ruby-dev:25403]
+Tue Jan 4 23:25:29 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_rand): should return positive random number.
+ [ruby-dev:25401]
+
Tue Jan 4 21:25:43 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* test/drb/{test_drbssl.rb,test_drbunix.rb,ut_drb.rb}: use
@@ -1014,6 +1195,11 @@ Mon Jan 3 11:37:42 2005 Tanaka Akira <akr@m17n.org>
* random.c (random_seed): use /dev/urandom if available.
[ruby-dev:25392]
+Tue Jan 4 11:15:29 2005 TAMURA Takashi <sheepman@tcn.zaq.ne.jp>
+
+ * bignum.c (rb_big_rand): do not use rb_big_modulo to generate
+ random bignums. [ruby-dev:25396]
+
Mon Jan 3 11:03:37 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* test/drb/test_drb.rb: move TestDRbReusePort to new file.
@@ -1084,6 +1270,10 @@ Sat Jan 1 04:20:23 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_ns_spki.c (ossl_spki_set_challenge): should call
StringValue before GetSPKI. fixed: [ruby-dev:25359].
+Sat Jan 1 01:13:28 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_autoload): [ruby-dev:25373]
+
Fri Dec 31 14:10:43 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/ri/ri_formatter.rb (RI::TextFormatter::display_flow_item):
@@ -1110,6 +1300,12 @@ Thu Dec 30 05:39:35 2004 Minero Aoki <aamine@loveruby.net>
* parse.y: make parser_new() static.
+Thu Dec 30 00:41:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (svalue_to_avalue): [ruby-dev:25366]
+
+ * string.c (rb_str_justify): [ruby-dev:25367]
+
Wed Dec 29 11:07:07 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/generators/template/html/kilmer.rb: Update to use new
@@ -1180,6 +1376,10 @@ Sun Dec 26 16:21:39 2004 Shugo Maeda <shugo@ruby-lang.org>
to support the PLAIN authentication mechanism. Thanks, Benjamin
Stiglitz.
+Sat Dec 25 01:28:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_f_select): [ruby-dev:25312]
+
Fri Dec 24 23:27:18 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/image.rb: TkPhotoImage#cget bug fix
@@ -1339,6 +1539,10 @@ Mon Dec 20 14:07:02 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/panedwindow.rb: ditto
+Mon Dec 20 13:51:40 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
+
Mon Dec 20 10:51:58 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (special_local_set): prevent the parser object from GC.
@@ -1349,6 +1553,10 @@ Mon Dec 20 03:30:40 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/cgi/session.rb (CGI::Session#initialize): empty session id was
used if request had no session key. fixed: [ruby-core:03981]
+Mon Dec 20 01:51:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * struct.c (make_struct): [ruby-dev:25249]
+
Mon Dec 20 00:16:54 2004 Kouhei Sutou <kou@cozmixng.org>
* lib/rexml/encodings/SHIFT_JIS.rb: fixed LoadError bug.
@@ -1381,6 +1589,12 @@ Sat Dec 18 15:09:02 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
pack/unpack-template char "m" instead of lib/base64.rb to do base64
encoding/decoding.
+Sat Dec 18 10:51:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (dir_open_dir): new function. [ruby-dev:25242]
+
+ * io.c (rb_f_open): add type check for return value from to_open.
+
Fri Dec 17 16:44:26 2004 Tanaka Akira <akr@m17n.org>
* configure.in (ac_cv_sizeof_rlim_t): set 8 for BSD/OS.
@@ -3176,6 +3390,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):
@@ -9111,7 +9330,7 @@ Wed Dec 31 15:00:00 2003 Gavin Sinclair <gsinclair@soyabean.com.au>
* lib/pathname.rb: Completed documentation.
-Wed Dec 31 11:20:34 2003 <dave@pragprog.com>
+Wed Dec 31 11:20:34 2003 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::do_methods): Make
file referenced in "// in sss.c" relative to current file.
diff --git a/array.c b/array.c
index 957a11f9f6..ceb68f5034 100644
--- a/array.c
+++ b/array.c
@@ -15,6 +15,7 @@
#include "ruby.h"
#include "util.h"
#include "st.h"
+#include "node.h"
VALUE rb_cArray, rb_cValues;
@@ -427,9 +428,6 @@ rb_ary_s_create(argc, argv, klass)
{
VALUE ary = ary_alloc(klass);
- if (argc < 0) {
- rb_raise(rb_eArgError, "negative number of arguments");
- }
if (argc > 0) {
RARRAY(ary)->ptr = ALLOC_N(VALUE, argc);
MEMCPY(RARRAY(ary)->ptr, argv, VALUE, argc);
@@ -705,9 +703,6 @@ rb_ary_unshift_m(argc, argv, ary)
{
long len = RARRAY(ary)->len;
- if (argc < 0) {
- rb_raise(rb_eArgError, "negative number of arguments");
- }
if (argc == 0) return ary;
/* make rooms by setting the last item */
@@ -1363,10 +1358,14 @@ rb_ary_dup(ary)
extern VALUE rb_output_fs;
static VALUE
-inspect_join(ary, arg)
+recursive_join(ary, arg, recur)
VALUE ary;
VALUE *arg;
+ int recur;
{
+ if (recur) {
+ return rb_str_new2("[...]");
+ }
return rb_ary_join(arg[0], arg[1]);
}
@@ -1396,15 +1395,12 @@ rb_ary_join(ary, sep)
case T_STRING:
break;
case T_ARRAY:
- if (rb_inspecting_p(tmp)) {
- tmp = rb_str_new2("[...]");
- }
- else {
+ {
VALUE args[2];
args[0] = tmp;
args[1] = sep;
- tmp = rb_protect_inspect(inspect_join, ary, (VALUE)args);
+ tmp = rb_exec_recursive(recursive_join, ary, (VALUE)args);
}
break;
default:
@@ -1464,96 +1460,17 @@ rb_ary_to_s(ary)
return rb_ary_join(ary, rb_output_fs);
}
-static ID inspect_key;
-
-struct inspect_arg {
- VALUE (*func)();
- VALUE arg1, arg2;
-};
-
-static VALUE
-inspect_call(arg)
- struct inspect_arg *arg;
-{
- return (*arg->func)(arg->arg1, arg->arg2);
-}
-
-static VALUE
-get_inspect_tbl(create)
- int create;
-{
- VALUE inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key);
-
- if (NIL_P(inspect_tbl)) {
- if (create) {
- tbl_init:
- inspect_tbl = rb_ary_new();
- rb_thread_local_aset(rb_thread_current(), inspect_key, inspect_tbl);
- }
- }
- else if (TYPE(inspect_tbl) != T_ARRAY) {
- rb_warn("invalid inspect_tbl value");
- if (create) goto tbl_init;
- rb_thread_local_aset(rb_thread_current(), inspect_key, Qnil);
- return Qnil;
- }
- return inspect_tbl;
-}
-
static VALUE
-inspect_ensure(obj)
- VALUE obj;
-{
- VALUE inspect_tbl;
-
- inspect_tbl = get_inspect_tbl(Qfalse);
- if (!NIL_P(inspect_tbl)) {
- rb_ary_pop(inspect_tbl);
- }
- return 0;
-}
-
-VALUE
-rb_protect_inspect(func, obj, arg)
- VALUE (*func)(ANYARGS);
- VALUE obj, arg;
-{
- struct inspect_arg iarg;
- VALUE inspect_tbl;
- VALUE id;
-
- inspect_tbl = get_inspect_tbl(Qtrue);
- id = rb_obj_id(obj);
- if (rb_ary_includes(inspect_tbl, id)) {
- return (*func)(obj, arg);
- }
- rb_ary_push(inspect_tbl, id);
- iarg.func = func;
- iarg.arg1 = obj;
- iarg.arg2 = arg;
-
- return rb_ensure(inspect_call, (VALUE)&iarg, inspect_ensure, obj);
-}
-
-VALUE
-rb_inspecting_p(obj)
- VALUE obj;
-{
- VALUE inspect_tbl;
-
- inspect_tbl = get_inspect_tbl(Qfalse);
- if (NIL_P(inspect_tbl)) return Qfalse;
- return rb_ary_includes(inspect_tbl, rb_obj_id(obj));
-}
-
-static VALUE
-inspect_ary(ary)
+inspect_ary(ary, dummy, recur)
VALUE ary;
+ VALUE dummy;
+ int recur;
{
int tainted = OBJ_TAINTED(ary);
long i;
VALUE s, str;
+ if (recur) return rb_tainted_str_new2("[...]");
str = rb_str_buf_new2("[");
for (i=0; i<RARRAY(ary)->len; i++) {
s = rb_inspect(RARRAY(ary)->ptr[i]);
@@ -1578,8 +1495,7 @@ rb_ary_inspect(ary)
VALUE ary;
{
if (RARRAY(ary)->len == 0) return rb_str_new2("[]");
- if (rb_inspecting_p(ary)) return rb_str_new2("[...]");
- return rb_protect_inspect(inspect_ary, ary, 0);
+ return rb_exec_recursive(inspect_ary, ary, 0);
}
/*
@@ -2254,7 +2170,7 @@ rb_ary_transpose(ary)
}
}
else if (elen != RARRAY(tmp)->len) {
- rb_raise(rb_eIndexError, "element size differ (%d should be %d)",
+ rb_raise(rb_eIndexError, "element size differs (%d should be %d)",
RARRAY(tmp)->len, elen);
}
for (j=0; j<elen; j++) {
@@ -2637,21 +2553,17 @@ rb_ary_eql(ary1, ary2)
return Qtrue;
}
-/*
- * call-seq:
- * array.hash -> fixnum
- *
- * Compute a hash-code for this array. Two arrays with the same content
- * will have the same hash code (and will compare using <code>eql?</code>).
- */
-
static VALUE
-rb_ary_hash(ary)
- VALUE ary;
+recursive_hash(ary, dummy, recur)
+ VALUE ary, dummy;
+ int recur;
{
long i, h;
VALUE n;
+ if (recur) {
+ return LONG2FIX(0);
+ }
h = RARRAY(ary)->len;
for (i=0; i<RARRAY(ary)->len; i++) {
h = (h << 1) | (h<0 ? 1 : 0);
@@ -2663,6 +2575,21 @@ rb_ary_hash(ary)
/*
* call-seq:
+ * array.hash -> fixnum
+ *
+ * Compute a hash-code for this array. Two arrays with the same content
+ * will have the same hash code (and will compare using <code>eql?</code>).
+ */
+
+static VALUE
+rb_ary_hash(ary)
+ VALUE ary;
+{
+ return rb_exec_recursive(recursive_hash, ary, 0);
+}
+
+/*
+ * call-seq:
* array.include?(obj) -> true or false
*
* Returns <code>true</code> if the given object is present in
@@ -3177,7 +3104,6 @@ Init_Array()
rb_define_method(rb_cArray, "nitems", rb_ary_nitems, 0);
id_cmp = rb_intern("<=>");
- inspect_key = rb_intern("__inspect_key__");
rb_cValues = rb_define_class("Values", rb_cArray);
}
diff --git a/bignum.c b/bignum.c
index accd14d958..6a31b5adc1 100644
--- a/bignum.c
+++ b/bignum.c
@@ -1976,7 +1976,7 @@ rb_big_coerce(x, y)
return rb_assoc_new(rb_int2big(FIX2LONG(y)), x);
}
else {
- rb_raise(rb_eTypeError, "Can't coerce %s to Bignum",
+ rb_raise(rb_eTypeError, "can't coerce %s to Bignum",
rb_obj_classname(y));
}
/* not reached */
@@ -2015,11 +2015,13 @@ rb_big_rand(max, rand_buf)
return rb_float_new(rand_buf[0]);
}
v = bignew(len,1);
+ len--;
+ BDIGITS(v)[len] = BDIGITS(max)[len] * rand_buf[len];
while (len--) {
BDIGITS(v)[len] = ((BDIGIT)~0) * rand_buf[len];
}
- return rb_big_modulo((VALUE)v, max);
+ return v;
}
/*
diff --git a/class.c b/class.c
index 7fdfac8813..59f608732f 100644
--- a/class.c
+++ b/class.c
@@ -159,24 +159,24 @@ VALUE
rb_make_metaclass(obj, super)
VALUE obj, super;
{
- VALUE klass = rb_class_boot(super);
- FL_SET(klass, FL_SINGLETON);
- RBASIC(obj)->klass = klass;
- rb_singleton_class_attached(klass, obj);
if (BUILTIN_TYPE(obj) == T_CLASS && FL_TEST(obj, FL_SINGLETON)) {
- RBASIC(klass)->klass = klass;
- RCLASS(klass)->super = RBASIC(rb_class_real(RCLASS(obj)->super))->klass;
+ return RBASIC(obj)->klass = rb_cClass;
}
else {
- VALUE metasuper = RBASIC(rb_class_real(super))->klass;
+ VALUE metasuper;
+ VALUE klass = rb_class_boot(super);
+ FL_SET(klass, FL_SINGLETON);
+ RBASIC(obj)->klass = klass;
+ rb_singleton_class_attached(klass, obj);
+
+ metasuper = RBASIC(rb_class_real(super))->klass;
/* metaclass of a superclass may be NULL at boot time */
if (metasuper) {
RBASIC(klass)->klass = metasuper;
}
+ return klass;
}
-
- return klass;
}
VALUE
diff --git a/common.mk b/common.mk
index 34b2e872e5..3a71fa8d75 100644
--- a/common.mk
+++ b/common.mk
@@ -241,8 +241,7 @@ inits.$(OBJEXT): {$(VPATH)}inits.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
io.$(OBJEXT): {$(VPATH)}io.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}rubyio.h {$(VPATH)}rubysig.h {$(VPATH)}env.h \
- {$(VPATH)}util.h
+ {$(VPATH)}rubyio.h {$(VPATH)}rubysig.h {$(VPATH)}util.h
main.$(OBJEXT): {$(VPATH)}main.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
marshal.$(OBJEXT): {$(VPATH)}marshal.c {$(VPATH)}ruby.h config.h \
diff --git a/dir.c b/dir.c
index ad353b786c..17f0347bfe 100644
--- a/dir.c
+++ b/dir.c
@@ -1345,14 +1345,15 @@ glob_helper(path, dirsep, exist, isdir, beg, end, flags, func, arg)
}
static int
-rb_glob2(path, flags, func, arg)
+rb_glob2(path, offset, flags, func, arg)
VALUE path;
+ long offset;
int flags;
void (*func) _((VALUE, VALUE));
VALUE arg;
{
struct glob_pattern *list;
- const char *root;
+ const char *root, *start;
VALUE buf;
int n;
int status;
@@ -1361,18 +1362,18 @@ rb_glob2(path, flags, func, arg)
rb_warn("Dir.glob() ignores File::FNM_CASEFOLD");
}
+ start = root = StringValuePtr(path) + offset;
#if defined DOSISH
flags |= FNM_CASEFOLD;
- root = rb_path_skip_prefix(RSTRING(path)->ptr);
+ root = rb_path_skip_prefix(root);
#else
- root = StringValuePtr(path);
flags &= ~FNM_CASEFOLD;
#endif
if (root && *root == '/') root++;
- n = root - RSTRING(path)->ptr;
- buf = rb_str_new(RSTRING(path)->ptr, n);
+ n = root - start;
+ buf = rb_str_new(start, n);
list = glob_make_pattern(root, flags);
status = glob_helper(buf, 0, UNKNOWN, UNKNOWN, &list, &list + 1, flags, func, arg);
@@ -1431,7 +1432,7 @@ push_glob(ary, str, offset, flags)
const int escape = !(flags & FNM_NOESCAPE);
const char *p = RSTRING(str)->ptr + offset;
- const char *s = RSTRING(str)->ptr + offset;
+ const char *s = p;
const char *lbrace = 0, *rbrace = 0;
int nest = 0, status = 0;
@@ -1452,11 +1453,11 @@ push_glob(ary, str, offset, flags)
if (lbrace && rbrace) {
VALUE buffer = rb_str_new(0, strlen(s));
char *buf;
- long offset;
+ long shift;
buf = RSTRING(buffer)->ptr;
memcpy(buf, s, lbrace-s);
- offset = (lbrace-s);
+ shift = (lbrace-s);
p = lbrace;
while (p < rbrace) {
const char *t = ++p;
@@ -1469,14 +1470,14 @@ push_glob(ary, str, offset, flags)
}
Inc(p);
}
- memcpy(buf+offset, t, p-t);
- strcpy(buf+offset+(p-t), rbrace+1);
+ memcpy(buf+shift, t, p-t);
+ strcpy(buf+shift+(p-t), rbrace+1);
status = push_glob(ary, buffer, offset, flags);
if (status) break;
}
}
else if (!lbrace && !rbrace) {
- status = rb_glob2(str, flags, push_pattern, ary);
+ status = rb_glob2(str, offset, flags, push_pattern, ary);
}
return status;
@@ -1608,6 +1609,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
@@ -1631,7 +1648,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;
}
@@ -1653,7 +1670,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);
}
diff --git a/env.h b/env.h
index 1019e6b567..56991cbdf2 100644
--- a/env.h
+++ b/env.h
@@ -16,9 +16,9 @@
RUBY_EXTERN struct FRAME {
VALUE self;
int argc;
- ID last_func;
- ID orig_func;
- VALUE last_class;
+ ID callee;
+ ID this_func;
+ VALUE this_class;
struct FRAME *prev;
struct FRAME *tmp;
struct RNode *node;
diff --git a/error.c b/error.c
index 0d16ec3cb1..f8414060f5 100644
--- a/error.c
+++ b/error.c
@@ -1131,7 +1131,7 @@ rb_notimplement()
{
rb_raise(rb_eNotImpError,
"The %s() function is unimplemented on this machine",
- rb_id2name(ruby_frame->last_func));
+ rb_id2name(ruby_frame->callee));
}
void
diff --git a/eval.c b/eval.c
index ebb16396c9..e23f52e83f 100644
--- a/eval.c
+++ b/eval.c
@@ -174,9 +174,9 @@ rb_secure(level)
int level;
{
if (level <= ruby_safe_level) {
- if (ruby_frame->last_func) {
+ if (ruby_frame->callee) {
rb_raise(rb_eSecurityError, "Insecure operation `%s' at level %d",
- rb_id2name(ruby_frame->last_func), ruby_safe_level);
+ rb_id2name(ruby_frame->callee), ruby_safe_level);
}
else {
rb_raise(rb_eSecurityError, "Insecure operation at level %d", ruby_safe_level);
@@ -196,9 +196,9 @@ rb_check_safe_obj(x)
VALUE x;
{
if (ruby_safe_level > 0 && OBJ_TAINTED(x)){
- if (ruby_frame->last_func) {
+ if (ruby_frame->callee) {
rb_raise(rb_eSecurityError, "Insecure operation - %s",
- rb_id2name(ruby_frame->last_func));
+ rb_id2name(ruby_frame->callee));
}
else {
rb_raise(rb_eSecurityError, "Insecure operation: -r");
@@ -1086,9 +1086,9 @@ error_pos()
{
ruby_set_current_source();
if (ruby_sourcefile) {
- if (ruby_frame->last_func) {
+ if (ruby_frame->callee) {
warn_printf("%s:%d:in `%s'", ruby_sourcefile, ruby_sourceline,
- rb_id2name(ruby_frame->last_func));
+ rb_id2name(ruby_frame->callee));
}
else if (ruby_sourceline == 0) {
warn_printf("%s", ruby_sourcefile);
@@ -1607,9 +1607,9 @@ rb_eval_string_wrap(str, state)
ruby_top_self = rb_obj_clone(ruby_top_self);
rb_extend_object(ruby_top_self, ruby_wrapper);
PUSH_FRAME();
- ruby_frame->last_func = 0;
- ruby_frame->orig_func = 0;
- ruby_frame->last_class = 0;
+ ruby_frame->callee = 0;
+ ruby_frame->this_func = 0;
+ ruby_frame->this_class = 0;
ruby_frame->self = self;
PUSH_CREF(ruby_wrapper);
PUSH_SCOPE();
@@ -1749,9 +1749,9 @@ rb_eval_cmd(cmd, arg, level)
saved_scope = ruby_scope;
ruby_scope = top_scope;
PUSH_FRAME();
- ruby_frame->last_func = 0;
- ruby_frame->orig_func = 0;
- ruby_frame->last_class = 0;
+ ruby_frame->callee = 0;
+ ruby_frame->this_func = 0;
+ ruby_frame->this_class = 0;
ruby_frame->self = ruby_top_self;
PUSH_CREF(ruby_wrapper ? ruby_wrapper : rb_cObject);
@@ -2234,10 +2234,10 @@ is_defined(self, node, buf, noeval)
switch (nd_type(node)) {
case NODE_SUPER:
case NODE_ZSUPER:
- if (ruby_frame->orig_func == 0) return 0;
- else if (ruby_frame->last_class == 0) return 0;
- val = ruby_frame->last_class;
- if (rb_method_boundp(RCLASS(val)->super, ruby_frame->orig_func, 0)) {
+ if (ruby_frame->this_func == 0) return 0;
+ else if (ruby_frame->this_class == 0) return 0;
+ val = ruby_frame->this_class;
+ if (rb_method_boundp(RCLASS(val)->super, ruby_frame->this_func, 0)) {
if (nd_type(node) == NODE_SUPER) {
return arg_defined(self, node->nd_args, buf, "super");
}
@@ -2312,6 +2312,7 @@ is_defined(self, node, buf, noeval)
case NODE_DASGN:
case NODE_DASGN_CURR:
case NODE_GASGN:
+ case NODE_IASGN:
case NODE_CDECL:
case NODE_CVDECL:
case NODE_CVASGN:
@@ -2576,7 +2577,7 @@ svalue_to_avalue(v)
if (RARRAY(tmp)->len == 1) {
top = rb_check_array_type(RARRAY(tmp)->ptr[0]);
if (!NIL_P(top) && RARRAY(top)->len > 1) {
- return v;
+ return tmp;
}
return rb_ary_new3(1, v);
}
@@ -2687,8 +2688,8 @@ rb_eval(self, n)
ruby_current_node = node;
if (trace_func && (node->flags & NODE_NEWLINE)) {
call_trace_func("line", node, self,
- ruby_frame->last_func,
- ruby_frame->last_class);
+ ruby_frame->this_func,
+ ruby_frame->this_class);
}
switch (nd_type(node)) {
case NODE_BLOCK:
@@ -2784,8 +2785,8 @@ rb_eval(self, n)
case NODE_IF:
if (trace_func) {
call_trace_func("line", node, self,
- ruby_frame->last_func,
- ruby_frame->last_class);
+ ruby_frame->this_func,
+ ruby_frame->this_class);
}
if (RTEST(rb_eval(self, node->nd_cond))) {
node = node->nd_body;
@@ -2804,8 +2805,8 @@ rb_eval(self, n)
while (tag) {
if (trace_func) {
call_trace_func("line", tag, self,
- ruby_frame->last_func,
- ruby_frame->last_class);
+ ruby_frame->this_func,
+ ruby_frame->this_class);
}
if (tag->nd_head && nd_type(tag->nd_head) == NODE_WHEN) {
VALUE v = rb_eval(self, tag->nd_head->nd_head);
@@ -2847,8 +2848,8 @@ rb_eval(self, n)
while (tag) {
if (trace_func) {
call_trace_func("line", tag, self,
- ruby_frame->last_func,
- ruby_frame->last_class);
+ ruby_frame->this_func,
+ ruby_frame->this_class);
}
if (tag->nd_head && nd_type(tag->nd_head) == NODE_WHEN) {
VALUE v = rb_eval(self, tag->nd_head->nd_head);
@@ -3275,11 +3276,11 @@ rb_eval(self, n)
int argc; VALUE *argv; /* used in SETUP_ARGS */
TMP_PROTECT;
- if (ruby_frame->last_class == 0) {
- if (ruby_frame->orig_func) {
- rb_name_error(ruby_frame->last_func,
+ if (ruby_frame->this_class == 0) {
+ if (ruby_frame->this_func) {
+ rb_name_error(ruby_frame->callee,
"superclass method `%s' disabled",
- rb_id2name(ruby_frame->orig_func));
+ rb_id2name(ruby_frame->this_func));
}
else {
rb_raise(rb_eNoMethodError, "super called outside of method");
@@ -3961,7 +3962,7 @@ module_setup(module, n)
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
if (trace_func) {
- call_trace_func("class", n, ruby_cbase, ruby_frame->last_func, ruby_frame->last_class);
+ call_trace_func("class", n, ruby_cbase, ruby_frame->this_func, ruby_frame->this_class);
}
result = rb_eval(ruby_cbase, node->nd_next);
}
@@ -3973,7 +3974,7 @@ module_setup(module, n)
ruby_frame = frame.tmp;
if (trace_func) {
- call_trace_func("end", n, 0, ruby_frame->last_func, ruby_frame->last_class);
+ call_trace_func("end", n, 0, ruby_frame->this_func, ruby_frame->this_class);
}
if (state) JUMP_TAG(state);
@@ -4372,8 +4373,8 @@ rb_longjmp(tag, mesg)
if (trace_func && tag != TAG_FATAL) {
call_trace_func("raise", ruby_current_node,
ruby_frame->self,
- ruby_frame->last_func,
- ruby_frame->last_class);
+ ruby_frame->this_func,
+ ruby_frame->this_class);
}
if (!prot_tag) {
error_print();
@@ -4592,7 +4593,7 @@ return_jump(retval)
tt->retval = retval;
if (trace_func) {
struct FRAME *f = tt->frame;
- call_trace_func("return", f->node, f->self, f->last_func, f->last_class);
+ call_trace_func("return", f->node, f->self, f->this_func, f->this_class);
}
JUMP_TAG(TAG_RETURN);
}
@@ -4633,12 +4634,6 @@ static VALUE bmcall _((VALUE, VALUE));
static int method_arity _((VALUE));
static VALUE
-kk()
-{
- return rb_proc_new(rb_yield, Qnil);
-}
-
-static VALUE
rb_yield_0(val, self, klass, flags, avalue)
VALUE val, self, klass; /* OK */
int flags, avalue;
@@ -5532,7 +5527,7 @@ call_cfunc(func, recv, len, argc, argv)
argv[11], argv[12], argv[13], argv[14]);
break;
default:
- rb_raise(rb_eArgError, "too many arguments(%d)", len);
+ rb_raise(rb_eArgError, "too many arguments (%d)", len);
break;
}
return Qnil; /* not reached */
@@ -5570,18 +5565,17 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
stack_check();
rb_gc_finalize_deferred();
}
- PUSH_ITER(itr);
- PUSH_FRAME();
-
if (argc < 0) {
argc = -argc-1;
args = rb_ary_concat(rb_ary_new4(argc, argv), splat_value(argv[argc]));
argc = RARRAY(args)->len;
argv = RARRAY(args)->ptr;
}
- ruby_frame->last_func = id;
- ruby_frame->orig_func = oid;
- ruby_frame->last_class = nosuper?0:klass;
+ PUSH_ITER(itr);
+ PUSH_FRAME();
+ ruby_frame->callee = id;
+ ruby_frame->this_func = oid;
+ ruby_frame->this_class = nosuper?0:klass;
ruby_frame->self = recv;
ruby_frame->argc = argc;
@@ -5591,7 +5585,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
int len = body->nd_argc;
if (len < -2) {
- rb_bug("bad argc(%d) specified for `%s(%s)'",
+ rb_bug("bad argc (%d) specified for `%s(%s)'",
len, rb_class2name(klass), rb_id2name(id));
}
if (trace_func) {
@@ -5943,16 +5937,16 @@ rb_call_super(argc, argv)
{
VALUE result, self, klass, k;
- if (ruby_frame->last_class == 0) {
- rb_name_error(ruby_frame->last_func, "calling `super' from `%s' is prohibited",
- rb_id2name(ruby_frame->last_func));
+ if (ruby_frame->this_class == 0) {
+ rb_name_error(ruby_frame->callee, "calling `super' from `%s' is prohibited",
+ rb_id2name(ruby_frame->this_func));
}
self = ruby_frame->self;
- klass = ruby_frame->last_class;
+ klass = ruby_frame->this_class;
PUSH_ITER(ruby_iter->iter ? ITER_PRE : ITER_NOT);
- result = rb_call(RCLASS(klass)->super, self, ruby_frame->orig_func, argc, argv, 3);
+ result = rb_call(RCLASS(klass)->super, self, ruby_frame->this_func, argc, argv, 3);
POP_ITER();
return result;
@@ -5968,15 +5962,15 @@ backtrace(lev)
NODE *n;
ary = rb_ary_new();
- if (frame->last_func == ID_ALLOCATOR) {
+ if (frame->this_func == ID_ALLOCATOR) {
frame = frame->prev;
}
if (lev < 0) {
ruby_set_current_source();
- if (frame->last_func) {
+ if (frame->this_func) {
snprintf(buf, BUFSIZ, "%s:%d:in `%s'",
ruby_sourcefile, ruby_sourceline,
- rb_id2name(frame->last_func));
+ rb_id2name(frame->this_func));
}
else if (ruby_sourceline == 0) {
snprintf(buf, BUFSIZ, "%s", ruby_sourcefile);
@@ -5997,10 +5991,10 @@ backtrace(lev)
}
}
while (frame && (n = frame->node)) {
- if (frame->prev && frame->prev->last_func) {
+ if (frame->prev && frame->prev->this_func) {
snprintf(buf, BUFSIZ, "%s:%d:in `%s'",
n->nd_file, nd_line(n),
- rb_id2name(frame->prev->last_func));
+ rb_id2name(frame->prev->this_func));
}
else {
snprintf(buf, BUFSIZ, "%s:%d", n->nd_file, nd_line(n));
@@ -6049,7 +6043,7 @@ rb_f_caller(argc, argv)
if (NIL_P(level)) lev = 1;
else lev = NUM2INT(level);
- if (lev < 0) rb_raise(rb_eArgError, "negative level(%d)", lev);
+ if (lev < 0) rb_raise(rb_eArgError, "negative level (%d)", lev);
return backtrace(lev);
}
@@ -6073,9 +6067,9 @@ make_backtrace()
}
ID
-rb_frame_last_func()
+rb_frame_this_func()
{
- return ruby_frame->last_func;
+ return ruby_frame->this_func;
}
static NODE*
@@ -6313,8 +6307,9 @@ exec_under(func, under, cbase, args)
PUSH_CLASS(under);
PUSH_FRAME();
ruby_frame->self = _frame.prev->self;
- ruby_frame->last_func = _frame.prev->last_func;
- ruby_frame->last_class = _frame.prev->last_class;
+ ruby_frame->callee = _frame.prev->callee;
+ ruby_frame->this_func = _frame.prev->this_func;
+ ruby_frame->this_class = _frame.prev->this_class;
ruby_frame->argc = _frame.prev->argc;
if (cbase) {
PUSH_CREF(cbase);
@@ -6408,8 +6403,8 @@ specific_eval(argc, argv, klass, self)
}
if (argc > 3) {
rb_raise(rb_eArgError, "wrong number of arguments: %s(src) or %s{..}",
- rb_id2name(ruby_frame->last_func),
- rb_id2name(ruby_frame->last_func));
+ rb_id2name(ruby_frame->callee),
+ rb_id2name(ruby_frame->callee));
}
if (argc > 2) line = NUM2INT(argv[2]);
if (argc > 1) {
@@ -6505,10 +6500,10 @@ rb_load(fname, wrap)
VALUE tmp;
int state;
volatile int prohibit_int = rb_prohibit_interrupt;
- volatile ID last_func;
+ volatile ID callee, this_func;
volatile VALUE wrapper = ruby_wrapper;
volatile VALUE self = ruby_top_self;
- NODE *volatile last_node;
+ NODE * volatile last_node;
NODE *saved_cref = ruby_cref;
TMP_PROTECT;
@@ -6539,22 +6534,24 @@ rb_load(fname, wrap)
}
PUSH_ITER(ITER_NOT);
PUSH_FRAME();
- ruby_frame->last_func = 0;
- ruby_frame->last_class = 0;
+ ruby_frame->callee = 0;
+ ruby_frame->this_func = 0;
+ ruby_frame->this_class = 0;
ruby_frame->self = self;
PUSH_SCOPE();
/* default visibility is private at loading toplevel */
SCOPE_SET(SCOPE_PRIVATE);
PUSH_TAG(PROT_NONE);
state = EXEC_TAG();
- last_func = ruby_frame->last_func;
+ callee = ruby_frame->callee;
+ this_func = ruby_frame->this_func;
last_node = ruby_current_node;
if (!ruby_current_node && ruby_sourcefile) {
last_node = NEW_BEGIN(0);
}
ruby_current_node = 0;
if (state == 0) {
- NODE *node;
+ NODE * volatile node;
volatile int critical;
DEFER_INTS;
@@ -6570,7 +6567,8 @@ rb_load(fname, wrap)
eval_node(self, node);
}
}
- ruby_frame->last_func = last_func;
+ ruby_frame->callee = callee;
+ ruby_frame->this_func = this_func;
ruby_current_node = last_node;
ruby_sourcefile = 0;
ruby_set_current_source();
@@ -6840,7 +6838,7 @@ static void
load_failed(fname)
VALUE fname;
{
- rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING(fname)->ptr);
+ rb_raise(rb_eLoadError, "no such file to load -- %s", RSTRING(fname)->ptr);
}
VALUE
@@ -6853,7 +6851,7 @@ rb_require_safe(fname, safe)
int state;
struct {
NODE *node;
- ID func;
+ ID this_func, callee;
int vmode, safe;
} volatile saved;
char *volatile ftptr = 0;
@@ -6862,7 +6860,8 @@ rb_require_safe(fname, safe)
fname = rb_str_new4(fname);
saved.vmode = scope_vmode;
saved.node = ruby_current_node;
- saved.func = ruby_frame->last_func;
+ saved.callee = ruby_frame->callee;
+ saved.this_func = ruby_frame->this_func;
saved.safe = ruby_safe_level;
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
@@ -6894,7 +6893,8 @@ rb_require_safe(fname, safe)
ruby_current_node = 0;
ruby_sourcefile = rb_source_filename(RSTRING(path)->ptr);
ruby_sourceline = 0;
- ruby_frame->last_func = 0;
+ ruby_frame->callee = 0;
+ ruby_frame->this_func = 0;
SCOPE_SET(SCOPE_PUBLIC);
handle = (long)dln_load(RSTRING(path)->ptr);
rb_ary_push(ruby_dln_librefs, LONG2NUM(handle));
@@ -6908,7 +6908,8 @@ rb_require_safe(fname, safe)
POP_TAG();
ruby_current_node = saved.node;
ruby_set_current_source();
- ruby_frame->last_func = saved.func;
+ ruby_frame->this_func = saved.this_func;
+ ruby_frame->callee = saved.callee;
SCOPE_SET(saved.vmode);
ruby_safe_level = saved.safe;
if (ftptr) {
@@ -7503,8 +7504,9 @@ call_end_proc(data)
PUSH_FRAME();
ruby_frame->self = ruby_frame->prev->self;
ruby_frame->node = 0;
- ruby_frame->last_func = 0;
- ruby_frame->last_class = 0;
+ ruby_frame->callee = 0;
+ ruby_frame->this_func = 0;
+ ruby_frame->this_class = 0;
proc_invoke(data, rb_ary_new2(0), Qundef, 0);
POP_FRAME();
POP_ITER();
@@ -7986,8 +7988,9 @@ rb_f_binding(self)
data->iter = rb_f_block_given_p();
frame_dup(&data->frame);
if (ruby_frame->prev) {
- data->frame.last_func = ruby_frame->prev->last_func;
- data->frame.last_class = ruby_frame->prev->last_class;
+ data->frame.callee = ruby_frame->prev->callee;
+ data->frame.this_func = ruby_frame->prev->this_func;
+ data->frame.this_class = ruby_frame->prev->this_class;
}
if (data->iter) {
@@ -8228,8 +8231,8 @@ proc_invoke(proc, args, self, klass)
avalue = Qfalse;
args = RARRAY(args)->ptr[0];
}
- if (rb_block_given_p() && ruby_frame->last_func) {
- if (klass != ruby_frame->last_class)
+ if (rb_block_given_p() && ruby_frame->callee) {
+ if (klass != ruby_frame->this_class)
klass = rb_obj_class(proc);
bvar = rb_block_proc();
}
@@ -8242,7 +8245,7 @@ proc_invoke(proc, args, self, klass)
_block = *data;
_block.block_obj = bvar;
if (self != Qundef) _block.frame.self = self;
- if (klass) _block.frame.last_class = klass;
+ if (klass) _block.frame.this_class = klass;
_block.frame.argc = RARRAY(tmp)->len;
if (_block.frame.argc && (ruby_frame->flags & FRAME_DMETH)) {
NEWOBJ(scope, struct SCOPE);
@@ -8378,12 +8381,12 @@ rb_proc_arity(proc)
* call-seq:
* prc.arity -> fixnum
*
- * Returns the number of arguments required by the block. If the block
+ * Returns the number of arguments that would not be ignored. If the block
* is declared to take no arguments, returns 0. If the block is known
* to take exactly n arguments, returns n. If the block has optional
* arguments, return -n-1, where n is the number of mandatory
* arguments. A <code>proc</code> with no argument declarations
- * is handled like a block declaring <code>||</code> as its arguments.
+ * is the same a block declaring <code>||</code> as its arguments.
*
* Proc.new {}.arity #=> 0
* Proc.new {||}.arity #=> 0
@@ -8944,7 +8947,7 @@ method_call(argc, argv, method)
Data_Get_Struct(method, struct METHOD, data);
if (data->recv == Qundef) {
- rb_raise(rb_eTypeError, "you cannot call unbound method; bind first");
+ rb_raise(rb_eTypeError, "can't call unbound method; bind first");
}
PUSH_ITER(rb_block_given_p()?ITER_PRE:ITER_NOT);
PUSH_TAG(PROT_NONE);
@@ -9382,10 +9385,9 @@ rb_mod_define_method(argc, argv, mod)
VALUE rklass = method->rklass;
if (rklass != mod) {
if (FL_TEST(rklass, FL_SINGLETON)) {
- rb_raise(rb_eTypeError, "cannot bind singleton method to a different class");
+ rb_raise(rb_eTypeError, "can't bind singleton method to a different class");
}
- if (RCLASS(mod)->super && RCLASS(rklass)->super &&
- !RTEST(rb_class_inherited_p(mod, rklass))) {
+ if (!RTEST(rb_class_inherited_p(mod, rklass))) {
rb_raise(rb_eTypeError, "bind argument must be a subclass of %s",
rb_class2name(rklass));
}
@@ -9398,9 +9400,9 @@ rb_mod_define_method(argc, argv, mod)
body = proc_clone(body);
RBASIC(body)->flags |= PROC_NOSAFE;
Data_Get_Struct(body, struct BLOCK, block);
- block->frame.last_func = id;
- block->frame.orig_func = id;
- block->frame.last_class = mod;
+ block->frame.callee = id;
+ block->frame.this_func = id;
+ block->frame.this_class = mod;
node = NEW_BMETHOD(body);
}
else {
@@ -9470,8 +9472,6 @@ Init_Proc()
rb_define_method(rb_cProc, "to_proc", proc_to_self, 0);
rb_define_method(rb_cProc, "binding", proc_binding, 0);
- rb_define_global_function("kk", kk, 0);
-
rb_define_global_function("proc", rb_block_proc, 0);
rb_define_global_function("lambda", proc_lambda, 0);
@@ -10114,7 +10114,8 @@ rb_thread_switch(n)
rb_trap_eval(th_cmd, th_sig, th_safe);
break;
case RESTORE_RAISE:
- ruby_frame->last_func = 0;
+ ruby_frame->callee = 0;
+ ruby_frame->this_func = 0;
ruby_current_node = th_raise_node;
rb_raise_jump(th_raise_exception);
break;
@@ -11783,7 +11784,6 @@ rb_thread_start_1()
if ((state = EXEC_TAG()) == 0) {
if (THREAD_SAVE_CONTEXT(th) == 0) {
new_thread.thread = 0;
- curr_thread = th;
th->result = rb_block_pass(rb_thread_yield_0, arg, proc);
}
th = th_save;
@@ -12770,6 +12770,10 @@ thgroup_add(group, thread)
return group;
}
+/* variables for recursive traversals */
+static ID recursive_key;
+static VALUE recursive_tbl;
+
/*
* +Thread+ encapsulates the behavior of a thread of
@@ -12856,6 +12860,7 @@ Init_Thread()
/* allocate main thread */
main_thread = rb_thread_alloc(rb_cThread);
curr_thread = main_thread->prev = main_thread->next = main_thread;
+ recursive_key = rb_intern("__recursive_key__");
}
/*
@@ -12984,3 +12989,50 @@ rb_throw(tag, val)
argv[1] = val;
rb_f_throw(2, argv);
}
+
+VALUE
+rb_exec_recursive(func, obj, arg)
+ VALUE (*func) _((VALUE, VALUE, int));
+ VALUE obj, arg;
+{
+ VALUE list = rb_thread_local_aref(rb_thread_current(), recursive_key);
+ int found = Qfalse;
+
+ if (NIL_P(list) || TYPE(list) != T_NODE) {
+ list = Qnil;
+ }
+ else {
+ NODE *tmp = (NODE*)list;
+
+ while (!NIL_P(tmp)) {
+ if (tmp->nd_cfnc == func && tmp->nd_tval == obj) {
+ found = Qtrue;
+ break;
+ }
+ tmp = tmp->nd_next;
+ }
+ }
+ if (found) {
+ return (*func)(obj, arg, Qtrue);
+ }
+ else {
+ NODE *node = rb_node_newnode(NODE_MEMO, (VALUE)func, obj, list);
+ VALUE result;
+ int state;
+
+ rb_thread_local_aset(rb_thread_current(), recursive_key, (VALUE)node);
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ result = (*func)(obj, arg, Qfalse);
+ }
+ POP_TAG();
+ if (state) JUMP_TAG(state);
+
+ /* remove pushed tag */
+ list = rb_thread_local_aref(rb_thread_current(), recursive_key);
+ node = (NODE*)list;
+
+ rb_thread_local_aset(rb_thread_current(), recursive_key, (VALUE)node->nd_next);
+ return result;
+ }
+}
diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c
index 776df56ecb..be07b8504f 100644
--- a/ext/Win32API/Win32API.c
+++ b/ext/Win32API/Win32API.c
@@ -160,7 +160,7 @@ Win32API_Call(argc, argv, obj)
if (items != nimport)
- rb_raise(rb_eRuntimeError, "Wrong number of parameters: expected %d, got %d.\n",
+ rb_raise(rb_eRuntimeError, "wrong number of parameters: expected %d, got %d",
nimport, items);
for (i = 0; i < nimport; i++) {
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 4ccba8809a..5ac81114b3 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -202,7 +202,7 @@ BigDecimal_load(VALUE self, VALUE str)
/* First get max prec */
while((*pch)!=(unsigned char)'\0' && (ch=*pch++)!=(unsigned char)':') {
if(!ISDIGIT(ch)) {
- rb_raise(rb_eTypeError, "Load failed: invalid character in the marshaled string");
+ rb_raise(rb_eTypeError, "load failed: invalid character in the marshaled string");
}
m = m*10 + (unsigned long)(ch-'0');
}
@@ -230,7 +230,7 @@ BigDecimal_mode(int argc, VALUE *argv, VALUE self)
fo = VpGetException();
if(val==Qnil) return INT2FIX(fo);
if(val!=Qfalse && val!=Qtrue) {
- rb_raise(rb_eTypeError, "The second argument must be true or false.");
+ rb_raise(rb_eTypeError, "second argument must be true or false");
return Qnil; /* Not reached */
}
if(f&VP_EXCEPTION_INFINITY) {
@@ -250,13 +250,13 @@ BigDecimal_mode(int argc, VALUE *argv, VALUE self)
if(val==Qnil) return INT2FIX(fo);
Check_Type(val, T_FIXNUM);
if(!VpIsRoundMode(FIX2INT(val))) {
- rb_raise(rb_eTypeError, "Invalid rounding mode.");
+ rb_raise(rb_eTypeError, "invalid rounding mode");
return Qnil;
}
fo = VpSetRoundMode((unsigned long)FIX2INT(val));
return INT2FIX(fo);
}
- rb_raise(rb_eTypeError, "The first argument for BigDecimal#mode is invalid.");
+ rb_raise(rb_eTypeError, "first argument for BigDecimal#mode invalid");
return Qnil;
}
@@ -412,7 +412,7 @@ BigDecimal_to_f(VALUE self)
errno = 0;
d2 = pow(10.0,(double)e);
if((errno == ERANGE && e>0) || (d2>1.0 && (fabs(d) > (DBL_MAX / d2)))) {
- VpException(VP_EXCEPTION_OVERFLOW,"BigDecimal to Float conversion.",0);
+ VpException(VP_EXCEPTION_OVERFLOW,"BigDecimal to Float conversion",0);
if(d>0.0) return rb_float_new(DBL_MAX);
else return rb_float_new(-DBL_MAX);
}
@@ -940,7 +940,7 @@ BigDecimal_round(int argc, VALUE *argv, VALUE self)
Check_Type(vRound, T_FIXNUM);
sw = FIX2INT(vRound);
if(!VpIsRoundMode(sw)) {
- rb_raise(rb_eTypeError, "Invalid rounding mode.");
+ rb_raise(rb_eTypeError, "invalid rounding mode");
return Qnil;
}
break;
@@ -3304,7 +3304,7 @@ VpCtoV(Real *a, char *int_chr, U_LONG ni, char *frac, U_LONG nf, char *exp_chr,
es = e*((S_INT)BASE_FIG);
e = e * 10 + exp_chr[i] - '0';
if(es>e*((S_INT)BASE_FIG)) {
- return VpException(VP_EXCEPTION_INFINITY,"Exponent overflow",0);
+ return VpException(VP_EXCEPTION_INFINITY,"exponent overflow",0);
}
++i;
}
diff --git a/ext/curses/curses.c b/ext/curses/curses.c
index a8952bf186..d36610a88a 100644
--- a/ext/curses/curses.c
+++ b/ext/curses/curses.c
@@ -124,7 +124,7 @@ curses_init_screen()
if (rb_stdscr) return rb_stdscr;
initscr();
if (stdscr == 0) {
- rb_raise(rb_eRuntimeError, "cannot initialize curses");
+ rb_raise(rb_eRuntimeError, "can't initialize curses");
}
clear();
rb_stdscr = prep_window(cWindow, stdscr);
@@ -561,7 +561,7 @@ curses_resizeterm(VALUE obj, VALUE lin, VALUE col)
#endif
}
-#ifdef USE_COLOR
+#if defined(USE_COLOR) && defined(HAVE_WCOLOR_SET)
static VALUE
curses_start_color(VALUE obj)
{
@@ -1195,6 +1195,20 @@ window_setscrreg(VALUE obj, VALUE top, VALUE bottom)
#endif
}
+#if defined(USE_COLOR) && defined(HAVE_WCOLOR_SET)
+static VALUE
+window_color_set(VALUE obj, VALUE col)
+{
+ struct windata *winp;
+ int res;
+
+ GetWINDOW(obj, winp);
+ res = wcolor_set(winp->window, NUM2INT(col), NULL);
+ return (res == OK) ? Qtrue : Qfalse;
+ return Qfalse;
+}
+#endif /* USE_COLOR */
+
static VALUE
window_scroll(VALUE obj)
{
@@ -1471,6 +1485,9 @@ Init_curses()
rb_define_method(cWindow, "box", window_box, -1);
rb_define_method(cWindow, "move", window_move, 2);
rb_define_method(cWindow, "setpos", window_setpos, 2);
+#if defined(USE_COLOR) && defined(HAVE_WCOLOR_SET)
+ rb_define_method(cWindow, "color_set", window_color_set, 1);
+#endif /* USE_COLOR && HAVE_WCOLOR_SET */
rb_define_method(cWindow, "cury", window_cury, 0);
rb_define_method(cWindow, "curx", window_curx, 0);
rb_define_method(cWindow, "maxy", window_maxy, 0);
diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb
index 9b319ba30e..01fe971093 100644
--- a/ext/curses/extconf.rb
+++ b/ext/curses/extconf.rb
@@ -19,7 +19,7 @@ elsif have_header(*curses=%w"curses.h") and have_library("curses", "initscr")
end
if make
- for f in %w(beep bkgd bkgdset curs_set deleteln doupdate flash getbkgd getnstr init isendwin keyname keypad resizeterm scrl set setscrreg ungetch wattroff wattron wattrset wbkgd wbkgdset wdeleteln wgetnstr wresize wscrl wsetscrreg def_prog_mode reset_prog_mode timeout wtimeout nodelay init_color)
+ for f in %w(beep bkgd bkgdset curs_set deleteln doupdate flash getbkgd getnstr init isendwin keyname keypad resizeterm scrl set setscrreg ungetch wattroff wattron wattrset wbkgd wbkgdset wdeleteln wgetnstr wresize wscrl wsetscrreg def_prog_mode reset_prog_mode timeout wtimeout nodelay init_color wcolor_set)
have_func(f)
end
flag = "-D_XOPEN_SOURCE_EXTENDED"
diff --git a/ext/dl/cfunc.c b/ext/dl/cfunc.c
index 92b2d34cbb..6907e43e1c 100644
--- a/ext/dl/cfunc.c
+++ b/ext/dl/cfunc.c
@@ -237,7 +237,7 @@ rb_dlcfunc_inspect(VALUE self)
CASE(6); break; CASE(7); break; CASE(8); break; CASE(9); break; CASE(10);break; \
CASE(11);break; CASE(12);break; CASE(13);break; CASE(14);break; CASE(15);break; \
CASE(16);break; CASE(17);break; CASE(18);break; CASE(19);break; CASE(20);break; \
- default: rb_raise(rb_eArgError, "too many arguments."); \
+ default: rb_raise(rb_eArgError, "too many arguments"); \
}
@@ -257,7 +257,7 @@ rb_dlcfunc_call(VALUE self, VALUE ary)
Data_Get_Struct(self, struct cfunc_data, cfunc);
if( cfunc->ptr == 0 ){
- rb_raise(rb_eDLError, "can't call null-function.");
+ rb_raise(rb_eDLError, "can't call null-function");
return Qnil;
}
diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c
index 18df5c8a38..66a7255ef8 100644
--- a/ext/dl/cptr.c
+++ b/ext/dl/cptr.c
@@ -430,7 +430,7 @@ rb_dlptr_s_to_ptr(VALUE self, VALUE val)
return vptr;
}
else{
- rb_raise(rb_eDLError, "to_ptr should return a CPtr object.");
+ rb_raise(rb_eDLError, "to_ptr should return a CPtr object");
}
}
else{
diff --git a/ext/dl/handle.c b/ext/dl/handle.c
index 7f7eddfd18..eaeb3d67a9 100644
--- a/ext/dl/handle.c
+++ b/ext/dl/handle.c
@@ -155,7 +155,7 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
Data_Get_Struct(self, struct dl_handle, dlhandle);
if( ! dlhandle->open ){
- rb_raise(rb_eDLError, "Closed handle.");
+ rb_raise(rb_eDLError, "closed handle");
}
handle = dlhandle->ptr;
@@ -187,7 +187,7 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
}
CHECK_DLERROR;
if( !func ){
- rb_raise(rb_eDLError, "Unknown symbol \"%s\".", name);
+ rb_raise(rb_eDLError, "unknown symbol \"%s\"", name);
}
}
}
@@ -205,7 +205,7 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
}
CHECK_DLERROR;
if( !func ){
- rb_raise(rb_eDLError, "Unknown symbol \"%s\".", name);
+ rb_raise(rb_eDLError, "unknown symbol \"%s\"", name);
}
#endif
}
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index c42f279d58..6f677a6893 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -410,7 +410,11 @@ Init_etc()
rb_global_variable(&sPasswd);
#ifdef HAVE_GETGRENT
- sGroup = rb_struct_define("Group", "name", "passwd", "gid", "mem", NULL);
+ sGroup = rb_struct_define("Group", "name",
+#ifdef HAVE_ST_GR_PASSWD
+ "passwd",
+#endif
+ "gid", "mem", NULL);
rb_global_variable(&sGroup);
#endif
}
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index e21f625fd4..84b14309af 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -806,7 +806,7 @@ iconv_iconv
return iconv_convert(VALUE2ICONV(cd), str,
NIL_P(n1) ? 0 : NUM2INT(n1),
- NIL_P(n2) ? -1 : NUM2INT(n1),
+ NIL_P(n2) ? -1 : NUM2INT(n2),
NULL);
}
diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c
index 3142855de6..f90fb2477a 100644
--- a/ext/openssl/ossl_cipher.c
+++ b/ext/openssl/ossl_cipher.c
@@ -94,7 +94,7 @@ ossl_cipher_initialize(VALUE self, VALUE str)
name = StringValuePtr(str);
GetCipher(self, ctx);
if (!(cipher = EVP_get_cipherbyname(name))) {
- ossl_raise(rb_eRuntimeError, "Unsupported cipher algorithm (%s).", name);
+ ossl_raise(rb_eRuntimeError, "unsupported cipher algorithm (%s)", name);
}
if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, -1) != 1)
ossl_raise(eCipherError, NULL);
@@ -198,7 +198,7 @@ ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self)
if(!NIL_P(vsalt)){
StringValue(vsalt);
if(RSTRING(vsalt)->len != PKCS5_SALT_LEN)
- rb_raise(eCipherError, "salt must be an 8-octet string.");
+ rb_raise(eCipherError, "salt must be an 8-octet string");
salt = RSTRING(vsalt)->ptr;
}
iter = NIL_P(viter) ? 2048 : NUM2INT(viter);
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 8e9e63036c..1894e1a5d6 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -375,7 +375,7 @@ getDevice(master,slave)
}
close(i);
}
- rb_raise(rb_eRuntimeError, "Cannot get Master/Slave device");
+ rb_raise(rb_eRuntimeError, "can't get Master/Slave device");
#else
char **p;
char MasterName[DEVICELEN];
@@ -394,7 +394,7 @@ getDevice(master,slave)
close(i);
}
}
- rb_raise(rb_eRuntimeError, "Cannot get %s", SlaveName);
+ rb_raise(rb_eRuntimeError, "can't get %s", SlaveName);
#endif
}
#endif /* HAVE__GETPTY */
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 4c7b08f514..4b859dd08d 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -7,6 +7,7 @@
#include <readline/history.h>
#include "ruby.h"
+#include "rubyio.h"
#include "rubysig.h"
#ifdef HAVE_UNISTD_H
@@ -45,6 +46,7 @@ readline_readline(argc, argv, self)
char *prompt = NULL;
char *buff;
int status;
+ OpenFile *ofp, *ifp;
rb_secure(4);
if (rb_scan_args(argc, argv, "02", &tmp, &add_hist) > 0) {
@@ -54,6 +56,10 @@ readline_readline(argc, argv, self)
if (!isatty(0) && errno == EBADF) rb_raise(rb_eIOError, "stdin closed");
+ GetOpenFile(rb_stdout, ofp);
+ rl_outstream = rb_io_stdio_file(ofp);
+ GetOpenFile(rb_stdin, ifp);
+ rl_instream = rb_io_stdio_file(ifp);
buff = (char*)rb_protect((VALUE(*)_((VALUE)))readline, (VALUE)prompt,
&status);
if (status) {
@@ -488,7 +494,7 @@ hist_get(self, index)
i += state->length;
}
if (i < 0 || i > state->length - 1) {
- rb_raise(rb_eIndexError, "Invalid index");
+ rb_raise(rb_eIndexError, "invalid index");
}
return rb_tainted_str_new2(state->entries[i]->line);
}
@@ -510,7 +516,7 @@ hist_set(self, index, str)
i += state->length;
}
if (i < 0 || i > state->length - 1) {
- rb_raise(rb_eIndexError, "Invalid index");
+ rb_raise(rb_eIndexError, "invalid index");
}
SafeStringValue(str);
replace_history_entry(i, RSTRING(str)->ptr, NULL);
@@ -629,7 +635,7 @@ hist_delete_at(self, index)
if (i < 0)
i += state->length;
if (i < 0 || i > state->length - 1) {
- rb_raise(rb_eIndexError, "Invalid index");
+ rb_raise(rb_eIndexError, "invalid index");
}
return rb_remove_history(i);
}
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 17aa3661c5..230966bae4 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1611,7 +1611,7 @@ unix_send_io(sock, val)
fd = FIX2INT(val);
}
else {
- rb_raise(rb_eTypeError, "IO nor file descriptor");
+ rb_raise(rb_eTypeError, "neither IO nor file descriptor");
}
GetOpenFile(sock, fptr);
@@ -1728,7 +1728,7 @@ unix_recv_io(argc, argv, sock)
msg.msg_accrightslen != sizeof(fd)
#endif
) {
- rb_raise(rb_eSocket, "File descriptor was not passed");
+ rb_raise(rb_eSocket, "file descriptor was not passed");
}
#if FD_PASSING_BY_MSG_CONTROL
@@ -1880,7 +1880,7 @@ setup_domain_and_type(domain, dv, type, tv)
*dv = PF_IPX;
#endif
else
- rb_raise(rb_eSocket, "Unknown socket domain %s", ptr);
+ rb_raise(rb_eSocket, "unknown socket domain %s", ptr);
}
else {
*dv = NUM2INT(domain);
@@ -1911,7 +1911,7 @@ setup_domain_and_type(domain, dv, type, tv)
*tv = SOCK_PACKET;
#endif
else
- rb_raise(rb_eSocket, "Unknown socket type %s", ptr);
+ rb_raise(rb_eSocket, "unknown socket type %s", ptr);
}
else {
*tv = NUM2INT(type);
@@ -2215,7 +2215,7 @@ sock_s_gethostbyaddr(argc, argv)
}
static VALUE
-sock_s_getservbyaname(argc, argv)
+sock_s_getservbyname(argc, argv)
int argc;
VALUE *argv;
{
@@ -2245,6 +2245,25 @@ sock_s_getservbyaname(argc, argv)
}
static VALUE
+sock_s_getservbyport(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE port, proto;
+ struct servent *sp;
+
+ rb_scan_args(argc, argv, "11", &port, &proto);
+ if (NIL_P(proto)) proto = rb_str_new2("tcp");
+ StringValue(proto);
+
+ sp = getservbyport(NUM2INT(port), StringValueCStr(proto));
+ if (!sp) {
+ rb_raise(rb_eSocket, "no such service for port %d/%s", NUM2INT(port), RSTRING(proto)->ptr);
+ }
+ return rb_tainted_str_new2(sp->s_name);
+}
+
+static VALUE
sock_s_getaddrinfo(argc, argv)
int argc;
VALUE *argv;
@@ -2629,7 +2648,8 @@ Init_socket()
rb_define_singleton_method(rb_cSocket, "gethostname", sock_gethostname, 0);
rb_define_singleton_method(rb_cSocket, "gethostbyname", sock_s_gethostbyname, 1);
rb_define_singleton_method(rb_cSocket, "gethostbyaddr", sock_s_gethostbyaddr, -1);
- rb_define_singleton_method(rb_cSocket, "getservbyname", sock_s_getservbyaname, -1);
+ rb_define_singleton_method(rb_cSocket, "getservbyname", sock_s_getservbyname, -1);
+ rb_define_singleton_method(rb_cSocket, "getservbyport", sock_s_getservbyport, -1);
rb_define_singleton_method(rb_cSocket, "getaddrinfo", sock_s_getaddrinfo, -1);
rb_define_singleton_method(rb_cSocket, "getnameinfo", sock_s_getnameinfo, -1);
rb_define_singleton_method(rb_cSocket, "sockaddr_in", sock_s_pack_sockaddr_in, 2);
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index e6df60e328..bdd9680367 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -790,7 +790,7 @@ strscan_peek(self, vlen)
* s.unscan
* s.scan(/../) # => "te"
* s.scan(/\d/) # => nil
- * s.unscan # ScanError: cannot unscan: prev match had failed
+ * s.unscan # ScanError: can't unscan: prev match had failed
*/
static VALUE
strscan_peep(self, vlen)
@@ -808,7 +808,7 @@ strscan_unscan(self)
GET_SCANNER(self, p);
if (! MATCHED_P(p))
- rb_raise(ScanError, "cannot unscan: prev match had failed");
+ rb_raise(ScanError, "can't unscan: prev match had failed");
p->curr = p->prev;
CLEAR_MATCH_STATUS(p);
diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c
index ff374b07d4..e713008c37 100644
--- a/ext/tk/tcltklib.c
+++ b/ext/tk/tcltklib.c
@@ -4353,8 +4353,15 @@ delete_slaves(ip)
slave = Tcl_GetSlave(ip, slave_name);
if (slave == (Tcl_Interp*)NULL) continue;
+<<<<<<< tcltklib.c
+ if (Tcl_Eval(ip, "info slaves") == TCL_ERROR) {
+ DUMP2("ip(%lx) can't get a list of slave IPs", ip);
+ return;
+ }
+=======
/* call ip_finalize */
ip_finalize(slave);
+>>>>>>> 1.3
Tcl_DeleteInterp(slave);
Tcl_Release(slave);
@@ -4486,6 +4493,12 @@ ip_replace_wait_commands(interp, mainWin)
(ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#endif
+<<<<<<< tcltklib.c
+ /* security check */
+ if (ruby_safe_level >= 4) {
+ rb_raise(rb_eSecurityError, "can't create a TclTkIp object at level %d", ruby_safe_level);
+ }
+=======
/* replace 'tkwait' command */
#if TCL_MAJOR_VERSION >= 8
DUMP1("Tcl_CreateObjCommand(\"tkwait\")");
@@ -4663,6 +4676,7 @@ ip_init(argc, argv, self)
"Cannot create a TclTkIp object at level %d",
ruby_safe_level);
}
+>>>>>>> 1.3
/* create object */
Data_Get_Struct(self, struct tcltkip, ptr);
@@ -4855,6 +4869,16 @@ ip_create_slave_core(interp, argc, argv)
thr_crit_bup = rb_thread_critical;
rb_thread_critical = Qtrue;
+<<<<<<< tcltklib.c
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(master->ip)) {
+ DUMP1("master-ip is deleted");
+ rb_thread_critical = thr_crit_bup;
+ rb_raise(rb_eRuntimeError, "deleted master can't create a new slave interpreter");
+ }
+
+=======
+>>>>>>> 1.3
/* create slave-ip */
slave->ref_count = 0;
slave->allow_ruby_exit = 0;
@@ -7889,7 +7913,7 @@ lib_split_tklist_core(ip_obj, list_str)
if (result == TCL_ERROR) {
Tcl_DecrRefCount(listobj);
if (interp == (Tcl_Interp*)NULL) {
- rb_raise(rb_eRuntimeError, "cannot get elements from list");
+ rb_raise(rb_eRuntimeError, "can't get elements from list");
} else {
#if TCL_MAJOR_VERSION >= 8
rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(interp));
@@ -7961,7 +7985,7 @@ lib_split_tklist_core(ip_obj, list_str)
if (Tcl_SplitList(interp, RSTRING(list_str)->ptr,
&argc, &argv) == TCL_ERROR) {
if (interp == (Tcl_Interp*)NULL) {
- rb_raise(rb_eRuntimeError, "cannot get elements from list");
+ rb_raise(rb_eRuntimeError, "can't get elements from list");
} else {
rb_raise(rb_eRuntimeError, "%s", interp->result);
}
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index aab1a9c7f7..6f44ea894f 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -73,7 +73,7 @@
#define OLEData_Get_Struct(obj, pole) {\
Data_Get_Struct(obj, struct oledata, pole);\
if(!pole->pDispatch) {\
- rb_raise(rb_eRuntimeError, "Failed to get Dispatch Interface");\
+ rb_raise(rb_eRuntimeError, "failed to get Dispatch Interface");\
}\
}
@@ -606,7 +606,7 @@ ole_initialize()
if(gOLEInitialized == Qfalse) {
hr = OleInitialize(NULL);
if(FAILED(hr)) {
- ole_raise(hr, rb_eRuntimeError, "Fail: OLE initialize");
+ ole_raise(hr, rb_eRuntimeError, "fail: OLE initialize");
}
gOLEInitialized = Qtrue;
/*
@@ -1378,12 +1378,12 @@ ole_create_dcom(argc, argv, self)
if (!gole32)
gole32 = LoadLibrary("OLE32");
if (!gole32)
- rb_raise(rb_eRuntimeError, "Failed to load OLE32");
+ rb_raise(rb_eRuntimeError, "failed to load OLE32");
if (!gCoCreateInstanceEx)
gCoCreateInstanceEx = (FNCOCREATEINSTANCEEX*)
GetProcAddress(gole32, "CoCreateInstanceEx");
if (!gCoCreateInstanceEx)
- rb_raise(rb_eRuntimeError, "CoCreateInstanceEx is not supported in this environment.");
+ rb_raise(rb_eRuntimeError, "CoCreateInstanceEx is not supported in this environment");
rb_scan_args(argc, argv, "2*", &ole, &host, &others);
pbuf = ole_mb2wc(StringValuePtr(ole), -1);
@@ -1395,7 +1395,7 @@ ole_create_dcom(argc, argv, self)
SysFreeString(pbuf);
if (FAILED(hr))
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
- "Unknown OLE server: `%s'",
+ "unknown OLE server: `%s'",
StringValuePtr(ole));
memset(&serverinfo, 0, sizeof(COSERVERINFO));
serverinfo.pwszName = ole_mb2wc(StringValuePtr(host), -1);
@@ -1405,7 +1405,7 @@ ole_create_dcom(argc, argv, self)
SysFreeString(serverinfo.pwszName);
if (FAILED(hr))
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
- "Failed to create DCOM server `%s' in `%s'",
+ "failed to create DCOM server `%s' in `%s'",
StringValuePtr(ole),
StringValuePtr(host));
@@ -1432,7 +1432,7 @@ ole_bind_obj(moniker, argc, argv, self)
hr = CreateBindCtx(0, &pBindCtx);
if(FAILED(hr)) {
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
- "Failed to create bind context");
+ "failed to create bind context");
}
pbuf = ole_mb2wc(StringValuePtr(moniker), -1);
@@ -1441,7 +1441,7 @@ ole_bind_obj(moniker, argc, argv, self)
if(FAILED(hr)) {
OLE_RELEASE(pBindCtx);
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
- "Failed to parse display name of moniker `%s'",
+ "failed to parse display name of moniker `%s'",
StringValuePtr(moniker));
}
hr = pMoniker->lpVtbl->BindToObject(pMoniker, pBindCtx, NULL,
@@ -1452,7 +1452,7 @@ ole_bind_obj(moniker, argc, argv, self)
if(FAILED(hr)) {
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
- "Failed to bind moniker `%s'",
+ "failed to bind moniker `%s'",
StringValuePtr(moniker));
}
return create_win32ole_object(self, pDispatch, argc, argv);
@@ -1512,7 +1512,7 @@ fole_s_connect(argc, argv, self)
if(FAILED(hr)) {
OLE_RELEASE(pUnknown);
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
- "Failed to create WIN32OLE server `%s'",
+ "failed to create WIN32OLE server `%s'",
StringValuePtr(svr_name));
}
@@ -1572,19 +1572,19 @@ fole_s_const_load(argc, argv, self)
if (TYPE(klass) != T_CLASS &&
TYPE(klass) != T_MODULE &&
TYPE(klass) != T_NIL) {
- rb_raise(rb_eTypeError, "2nd paramator must be Class or Module.");
+ rb_raise(rb_eTypeError, "2nd parameter must be Class or Module");
}
if (rb_obj_is_kind_of(ole, cWIN32OLE)) {
OLEData_Get_Struct(ole, pole);
hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
0, lcid, &pTypeInfo);
if(FAILED(hr)) {
- ole_raise(hr, rb_eRuntimeError, "Failed to GetTypeInfo");
+ ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo");
}
hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &index);
if(FAILED(hr)) {
OLE_RELEASE(pTypeInfo);
- ole_raise(hr, rb_eRuntimeError, "Failed to GetContainingTypeLib");
+ ole_raise(hr, rb_eRuntimeError, "failed to GetContainingTypeLib");
}
OLE_RELEASE(pTypeInfo);
if(TYPE(klass) != T_NIL) {
@@ -1604,7 +1604,7 @@ fole_s_const_load(argc, argv, self)
hr = LoadTypeLibEx(pBuf, REGKIND_NONE, &pTypeLib);
SysFreeString(pBuf);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to LoadTypeLibEx");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to LoadTypeLibEx");
if(TYPE(klass) != T_NIL) {
ole_const_load(pTypeLib, klass, self);
}
@@ -1614,7 +1614,7 @@ fole_s_const_load(argc, argv, self)
OLE_RELEASE(pTypeLib);
}
else {
- rb_raise(rb_eTypeError, "1st paramator must be WIN32OLE instance");
+ rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE instance");
}
return Qnil;
}
@@ -1767,11 +1767,11 @@ fole_s_show_help(argc, argv, self)
helpfile = target;
}
if (TYPE(helpfile) != T_STRING) {
- rb_raise(rb_eTypeError, "1st parameter must be (String|WIN32OLE_TYPE|WIN32OLE_METHOD).");
+ rb_raise(rb_eTypeError, "1st parameter must be (String|WIN32OLE_TYPE|WIN32OLE_METHOD)");
}
hwnd = ole_show_help(helpfile, helpcontext);
if(hwnd == 0) {
- rb_raise(rb_eRuntimeError, "Failed to open help file `%s'",
+ rb_raise(rb_eRuntimeError, "failed to open help file `%s'",
StringValuePtr(helpfile));
}
return Qnil;
@@ -1884,7 +1884,7 @@ fole_initialize(argc, argv, self)
SysFreeString(pBuf);
if(FAILED(hr)) {
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
- "Unknown OLE server: `%s'",
+ "unknown OLE server: `%s'",
StringValuePtr(svr_name));
}
@@ -1893,7 +1893,7 @@ fole_initialize(argc, argv, self)
&IID_IDispatch, (void**)&pDispatch);
if(FAILED(hr)) {
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
- "Failed to create WIN32OLE object from `%s'",
+ "failed to create WIN32OLE object from `%s'",
StringValuePtr(svr_name));
}
@@ -1994,7 +1994,7 @@ ole_invoke(argc, argv, self, wFlags)
rb_scan_args(argc, argv, "1*", &cmd, &paramS);
OLEData_Get_Struct(self, pole);
if(!pole->pDispatch) {
- rb_raise(rb_eRuntimeError, "Failed to get dispatch interface");
+ rb_raise(rb_eRuntimeError, "failed to get dispatch interface");
}
wcmdname = ole_mb2wc(StringValuePtr(cmd), -1);
hr = pole->pDispatch->lpVtbl->GetIDsOfNames( pole->pDispatch, &IID_NULL,
@@ -2002,7 +2002,7 @@ ole_invoke(argc, argv, self, wFlags)
SysFreeString(wcmdname);
if(FAILED(hr)) {
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
- "Unknown property or method: `%s'",
+ "unknown property or method: `%s'",
StringValuePtr(cmd));
}
@@ -2039,7 +2039,7 @@ ole_invoke(argc, argv, self, wFlags)
VariantClear(&op.dp.rgvarg[i]);
}
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
- "Failed to get named argument info: `%s'",
+ "failed to get named argument info: `%s'",
StringValuePtr(cmd));
}
op.dp.rgdispidNamedArgs = &(pDispID[1]);
@@ -2495,7 +2495,7 @@ ole_propertyput(self, property, value)
if(FAILED(hr)) {
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
- "Unknown property or method: `%s'",
+ "unknown property or method: `%s'",
StringValuePtr(property));
}
/* set property value */
@@ -2606,7 +2606,7 @@ fole_each(self)
if (FAILED(hr)) {
VariantClear(&result);
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to get IEnum Interface");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to get IEnum Interface");
}
if (V_VT(&result) == VT_UNKNOWN)
@@ -2619,7 +2619,7 @@ fole_each(self)
(void**)&pEnum);
if (FAILED(hr) || !pEnum) {
VariantClear(&result);
- ole_raise(hr, rb_eRuntimeError, "Failed to get IEnum Interface");
+ ole_raise(hr, rb_eRuntimeError, "failed to get IEnum Interface");
}
VariantClear(&result);
@@ -2645,7 +2645,7 @@ fole_missing(argc, argv, self)
id = rb_to_id(argv[0]);
mname = rb_id2name(id);
if(!mname) {
- rb_raise(rb_eRuntimeError, "Fail: unknown method or property");
+ rb_raise(rb_eRuntimeError, "fail: unknown method or property");
}
n = strlen(mname);
if(mname[n-1] == '=') {
@@ -2675,7 +2675,7 @@ ole_method_sub(self, pOwnerTypeInfo, pTypeInfo, name)
VALUE method = Qnil;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
}
for(i = 0; i < pTypeAttr->cFuncs && method == Qnil; i++) {
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc);
@@ -2714,7 +2714,7 @@ olemethod_from_typeinfo(self, pTypeInfo, name)
VALUE method = Qnil;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
}
method = ole_method_sub(self, 0, pTypeInfo, name);
if (method != Qnil) {
@@ -2750,7 +2750,7 @@ ole_methods_sub(pOwnerTypeInfo, pTypeInfo, methods, mask)
WORD i;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
}
for(i = 0; i < pTypeAttr->cFuncs; i++) {
pstr = NULL;
@@ -2791,7 +2791,7 @@ ole_methods_from_typeinfo(pTypeInfo, mask)
VALUE methods = rb_ary_new();
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
}
ole_methods_sub(0, pTypeInfo, methods, mask);
@@ -2824,7 +2824,7 @@ typeinfo_from_ole(pole, ppti)
HRESULT hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
0, lcid, &pTypeInfo);
if(FAILED(hr)) {
- ole_raise(hr, rb_eRuntimeError, "Failed to GetTypeInfo");
+ ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo");
}
hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo,
-1,
@@ -2834,7 +2834,7 @@ typeinfo_from_ole(pole, ppti)
hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &i);
OLE_RELEASE(pTypeInfo);
if (FAILED(hr)) {
- ole_raise(hr, rb_eRuntimeError, "Failed to GetContainingTypeLib");
+ ole_raise(hr, rb_eRuntimeError, "failed to GetContainingTypeLib");
}
count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
for (i = 0; i < count; i++) {
@@ -2969,12 +2969,12 @@ fole_type( self )
hr = pole->pDispatch->lpVtbl->GetTypeInfo( pole->pDispatch, 0, lcid, &pTypeInfo );
if(FAILED(hr)) {
- ole_raise(hr, rb_eRuntimeError, "Failed to GetTypeInfo");
+ ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo");
}
hr = pTypeInfo->lpVtbl->GetContainingTypeLib( pTypeInfo, &pTypeLib, &index );
if(FAILED(hr)) {
OLE_RELEASE(pTypeInfo);
- ole_raise(hr, rb_eRuntimeError, "Failed to GetContainingTypeLib");
+ ole_raise(hr, rb_eRuntimeError, "failed to GetContainingTypeLib");
}
hr = pTypeLib->lpVtbl->GetDocumentation( pTypeLib, index,
&bstr, NULL, NULL, NULL);
@@ -3033,12 +3033,12 @@ fole_typelib(self)
hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
0, lcid, &pTypeInfo);
if(FAILED(hr)) {
- ole_raise(hr, rb_eRuntimeError, "Failed to GetTypeInfo");
+ ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo");
}
hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &index);
if(FAILED(hr)) {
OLE_RELEASE(pTypeInfo);
- ole_raise(hr, rb_eRuntimeError, "Failed to GetContainingTypeLib");
+ ole_raise(hr, rb_eRuntimeError, "failed to GetContainingTypeLib");
}
OLE_RELEASE(pTypeInfo);
@@ -3053,7 +3053,7 @@ fole_typelib(self)
pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
OLE_RELEASE(pTypeLib);
if (guid == Qnil) {
- rb_raise(eWIN32OLE_RUNTIME_ERROR, "Fail to get typelib");
+ rb_raise(eWIN32OLE_RUNTIME_ERROR, "failed to get typelib");
}
return make_oletypelib_obj(guid, major, minor);
}
@@ -3294,12 +3294,12 @@ fole_method_help( self, cmdname )
OLEData_Get_Struct(self, pole);
hr = typeinfo_from_ole(pole, &pTypeInfo);
if(FAILED(hr))
- ole_raise(hr, rb_eRuntimeError, "Failed to get ITypeInfo");
+ ole_raise(hr, rb_eRuntimeError, "failed to get ITypeInfo");
method = folemethod_s_allocate(cWIN32OLE_METHOD);
obj = olemethod_from_typeinfo(method, pTypeInfo, cmdname);
OLE_RELEASE(pTypeInfo);
if (obj == Qnil)
- rb_raise(eWIN32OLE_RUNTIME_ERROR, "Not found %s",
+ rb_raise(eWIN32OLE_RUNTIME_ERROR, "not found %s",
StringValuePtr(cmdname));
return obj;
}
@@ -3336,7 +3336,7 @@ foletype_s_ole_classes(self, typelib)
pbuf = ole_mb2wc(StringValuePtr(file), -1);
hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to LoadTypeLibEx");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to LoadTypeLibEx");
SysFreeString(pbuf);
ole_classes_from_typelib(pTypeLib, classes);
OLE_RELEASE(pTypeLib);
@@ -3753,7 +3753,7 @@ foletypelib_initialize(self, args)
}
if (found == Qfalse) {
- rb_raise(eWIN32OLE_RUNTIME_ERROR, "Not found type library `%s`",
+ rb_raise(eWIN32OLE_RUNTIME_ERROR, "not found type library `%s`",
StringValuePtr(typelib));
}
return self;
@@ -3922,12 +3922,12 @@ foletypelib_ole_classes(self)
hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
SysFreeString(pbuf);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to LoadTypeLibEx from `%s'",
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to LoadTypeLibEx from `%s'",
StringValuePtr(path));
ole_classes_from_typelib(pTypeLib, classes);
OLE_RELEASE(pTypeLib);
} else {
- rb_raise(eWIN32OLE_RUNTIME_ERROR, "Failed to get type library path");
+ rb_raise(eWIN32OLE_RUNTIME_ERROR, "failed to get type library path");
}
return classes;
}
@@ -3970,11 +3970,11 @@ foletype_initialize(self, typelib, oleclass)
pbuf = ole_mb2wc(StringValuePtr(file), -1);
hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to LoadTypeLibEx");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to LoadTypeLibEx");
SysFreeString(pbuf);
if (oleclass_from_typelib(self, pTypeLib, oleclass) == Qfalse) {
OLE_RELEASE(pTypeLib);
- rb_raise(eWIN32OLE_RUNTIME_ERROR, "Not found `%s` in `%s`",
+ rb_raise(eWIN32OLE_RUNTIME_ERROR, "not found `%s` in `%s`",
StringValuePtr(oleclass), StringValuePtr(typelib));
}
OLE_RELEASE(pTypeLib);
@@ -4178,7 +4178,7 @@ ole_type_major_version(pTypeInfo)
HRESULT hr;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
ver = INT2FIX(pTypeAttr->wMajorVerNum);
OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
return ver;
@@ -4210,7 +4210,7 @@ ole_type_minor_version(pTypeInfo)
HRESULT hr;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
ver = INT2FIX(pTypeAttr->wMinorVerNum);
OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
return ver;
@@ -4242,7 +4242,7 @@ ole_type_typekind(pTypeInfo)
HRESULT hr;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
typekind = INT2FIX(pTypeAttr->typekind);
OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
return typekind;
@@ -4410,7 +4410,7 @@ ole_variables(pTypeInfo)
VALUE variables = rb_ary_new();
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
}
for(i = 0; i < pTypeAttr->cVars; i++) {
@@ -4534,7 +4534,7 @@ ole_variable_ole_type(pTypeInfo, var_index)
VALUE type;
hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetVarDesc");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetVarDesc");
type = ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), Qnil);
pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
return type;
@@ -4579,7 +4579,7 @@ ole_variable_ole_type_detail(pTypeInfo, var_index)
VALUE type = rb_ary_new();
hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetVarDesc");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetVarDesc");
ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), type);
pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
return type;
@@ -4870,12 +4870,12 @@ folemethod_initialize(self, oletype, method)
Data_Get_Struct(oletype, struct oletypedata, ptype);
obj = olemethod_from_typeinfo(self, ptype->pTypeInfo, method);
if (obj == Qnil) {
- rb_raise(eWIN32OLE_RUNTIME_ERROR, "Not found %s",
+ rb_raise(eWIN32OLE_RUNTIME_ERROR, "not found %s",
StringValuePtr(method));
}
}
else {
- rb_raise(rb_eTypeError, "1st argument should be WIN32OLE_TYPE object.");
+ rb_raise(rb_eTypeError, "1st argument should be WIN32OLE_TYPE object");
}
return obj;
}
@@ -4909,7 +4909,7 @@ ole_method_return_type(pTypeInfo, method_index)
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetFuncDesc");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetFuncDesc");
type = ole_typedesc2val(pTypeInfo, &(pFuncDesc->elemdescFunc.tdesc), Qnil);
pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
@@ -4946,7 +4946,7 @@ ole_method_return_vtype(pTypeInfo, method_index)
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetFuncDesc");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetFuncDesc");
vt = INT2FIX(pFuncDesc->elemdescFunc.tdesc.vt);
pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
@@ -5019,7 +5019,7 @@ ole_method_invkind(pTypeInfo, method_index)
VALUE invkind;
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
if(FAILED(hr))
- ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetFuncDesc");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetFuncDesc");
invkind = INT2FIX(pFuncDesc->invkind);
pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
return invkind;
@@ -6403,7 +6403,7 @@ fev_initialize(argc, argv, self)
rb_scan_args(argc, argv, "11", &ole, &itf);
if (!rb_obj_is_kind_of(ole, cWIN32OLE)) {
- rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE object.");
+ rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE object");
}
if(TYPE(itf) != T_NIL) {
@@ -6430,7 +6430,7 @@ fev_initialize(argc, argv, self)
if (FAILED(hr)) {
OLE_RELEASE(pTypeInfo);
ole_raise(hr, rb_eRuntimeError,
- "Failed to query IConnectionPointContainer");
+ "failed to query IConnectionPointContainer");
}
hr = pContainer->lpVtbl->FindConnectionPoint(pContainer,
@@ -6439,7 +6439,7 @@ fev_initialize(argc, argv, self)
OLE_RELEASE(pContainer);
if (FAILED(hr)) {
OLE_RELEASE(pTypeInfo);
- ole_raise(hr, rb_eRuntimeError, "Failed to query IConnectionPoint");
+ ole_raise(hr, rb_eRuntimeError, "failed to query IConnectionPoint");
}
pIEV = EVENTSINK_Constructor();
pIEV->m_iid = iid;
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 90f4d22fa9..15f90681f8 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -2201,7 +2201,7 @@ gzfile_readpartial(gz, len, outbuf)
}
if (!NIL_P(outbuf))
rb_str_resize(outbuf, 0);
- rb_raise(rb_eEOFError, "End of file reached");
+ rb_raise(rb_eEOFError, "end of file reached");
}
dst = zstream_shift_buffer(&gz->z, len);
@@ -3100,7 +3100,7 @@ rb_gzreader_readchar(obj)
VALUE dst;
dst = rb_gzreader_getc(obj);
if (NIL_P(dst)) {
- rb_raise(rb_eEOFError, "End of file reached");
+ rb_raise(rb_eEOFError, "end of file reached");
}
return dst;
}
@@ -3282,7 +3282,7 @@ rb_gzreader_readline(argc, argv, obj)
VALUE dst;
dst = rb_gzreader_gets(argc, argv, obj);
if (NIL_P(dst)) {
- rb_raise(rb_eEOFError, "End of file reached");
+ rb_raise(rb_eEOFError, "end of file reached");
}
return dst;
}
diff --git a/file.c b/file.c
index bc3078bcf4..1b31a52207 100644
--- a/file.c
+++ b/file.c
@@ -2815,10 +2815,11 @@ static VALUE separator;
static VALUE rb_file_join _((VALUE ary, VALUE sep));
static VALUE
-file_inspect_join(ary, arg)
+file_inspect_join(ary, arg, recur)
VALUE ary;
VALUE *arg;
{
+ if (recur) return rb_str_new2("[...]");
return rb_file_join(arg[0], arg[1]);
}
@@ -2854,15 +2855,12 @@ rb_file_join(ary, sep)
case T_STRING:
break;
case T_ARRAY:
- if (rb_inspecting_p(tmp)) {
- tmp = rb_str_new2("[...]");
- }
- else {
+ {
VALUE args[2];
args[0] = tmp;
args[1] = sep;
- tmp = rb_protect_inspect(file_inspect_join, ary, (VALUE)args);
+ tmp = rb_exec_recursive(file_inspect_join, ary, (VALUE)args);
}
break;
default:
diff --git a/gc.c b/gc.c
index 4197defda4..ab8a5956d4 100644
--- a/gc.c
+++ b/gc.c
@@ -400,7 +400,7 @@ rb_data_object_alloc(klass, datap, dmark, dfree)
RUBY_DATA_FUNC dfree;
{
NEWOBJ(data, struct RData);
- Check_Type(klass, T_CLASS);
+ if (klass) Check_Type(klass, T_CLASS);
OBJSETUP(data, klass, T_DATA);
data->data = datap;
data->dfree = dfree;
diff --git a/hash.c b/hash.c
index beadac14ee..58c6576fd2 100644
--- a/hash.c
+++ b/hash.c
@@ -102,8 +102,6 @@ rb_any_hash(a)
static struct st_hash_type objhash = {
rb_any_cmp,
rb_any_hash,
- st_nothing_key_free,
- st_nothing_key_clone
};
struct foreach_safe_arg {
@@ -113,17 +111,14 @@ struct foreach_safe_arg {
};
static int
-foreach_safe_i(key, value, arg, err)
+foreach_safe_i(key, value, arg)
st_data_t key, value;
struct foreach_safe_arg *arg;
{
int status;
- if (err) {
- rb_raise(rb_eRuntimeError, "hash modified during iteration");
- }
if (key == Qundef) return ST_CONTINUE;
- status = (*arg->func)(key, value, arg->arg, err);
+ status = (*arg->func)(key, value, arg->arg);
if (status == ST_CONTINUE) {
return ST_CHECK;
}
@@ -141,7 +136,9 @@ st_foreach_safe(table, func, a)
arg.tbl = table;
arg.func = func;
arg.arg = a;
- st_foreach(table, foreach_safe_i, (st_data_t)&arg);
+ if (st_foreach(table, foreach_safe_i, (st_data_t)&arg)) {
+ rb_raise(rb_eRuntimeError, "hash modified during iteration");
+ }
}
struct hash_foreach_arg {
@@ -151,17 +148,13 @@ struct hash_foreach_arg {
};
static int
-hash_foreach_iter(key, value, arg, err)
+hash_foreach_iter(key, value, arg)
VALUE key, value;
struct hash_foreach_arg *arg;
- int err;
{
int status;
st_table *tbl;
- if (err) {
- rb_raise(rb_eRuntimeError, "hash modified during iteration");
- }
tbl = RHASH(arg->hash)->tbl;
if (key == Qundef) return ST_CONTINUE;
status = (*arg->func)(key, value, arg->arg);
@@ -199,7 +192,9 @@ static VALUE
hash_foreach_call(arg)
struct hash_foreach_arg *arg;
{
- st_foreach(RHASH(arg->hash)->tbl, hash_foreach_iter, (st_data_t)arg);
+ if (st_foreach(RHASH(arg->hash)->tbl, hash_foreach_iter, (st_data_t)arg)) {
+ rb_raise(rb_eRuntimeError, "hash modified during iteration");
+ }
return Qnil;
}
@@ -1202,11 +1197,13 @@ inspect_i(key, value, str)
}
static VALUE
-inspect_hash(hash)
- VALUE hash;
+inspect_hash(hash, dummy, recur)
+ VALUE hash, dummy;
+ int recur;
{
VALUE str;
+ if (recur) return rb_str_new2("{...}");
str = rb_str_buf_new2("{");
rb_hash_foreach(hash, inspect_i, str);
rb_str_buf_cat2(str, "}");
@@ -1228,14 +1225,15 @@ rb_hash_inspect(hash)
{
if (RHASH(hash)->tbl == 0 || RHASH(hash)->tbl->num_entries == 0)
return rb_str_new2("{}");
- if (rb_inspecting_p(hash)) return rb_str_new2("{...}");
- return rb_protect_inspect(inspect_hash, hash, 0);
+ return rb_exec_recursive(inspect_hash, hash, 0);
}
static VALUE
-to_s_hash(hash)
- VALUE hash;
+to_s_hash(hash, dummy, recur)
+ VALUE hash, dummy;
+ int recur;
{
+ if (recur) return rb_str_new2("{...}");
return rb_ary_to_s(rb_hash_to_a(hash));
}
@@ -1256,8 +1254,7 @@ static VALUE
rb_hash_to_s(hash)
VALUE hash;
{
- if (rb_inspecting_p(hash)) return rb_str_new2("{...}");
- return rb_protect_inspect(to_s_hash, hash, 0);
+ return rb_exec_recursive(to_s_hash, hash, 0);
}
/*
@@ -1518,6 +1515,25 @@ rb_hash_hash_i(key, value, hp)
return ST_CONTINUE;
}
+static VALUE
+recursive_hash(hash, dummy, recur)
+ VALUE hash, dummy;
+ int recur;
+{
+ long h;
+ VALUE n;
+
+ if (recur) {
+ return LONG2FIX(0);
+ }
+ 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);
+}
+
/*
* call-seq:
* hash.hash -> fixnum
@@ -1530,18 +1546,10 @@ 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);
+ return rb_exec_recursive(recursive_hash, hash, 0);
}
+
static int
rb_hash_invert_i(key, value, hash)
VALUE key, value;
@@ -1604,12 +1612,17 @@ rb_hash_update_block_i(key, value, hash)
* hsh.merge!(other_hash){|key, oldval, newval| block} => hsh
* hsh.update(other_hash){|key, oldval, newval| block} => hsh
*
- * Adds the contents of <i>other_hash</i> to <i>hsh</i>, overwriting
- * entries with duplicate keys with those from <i>other_hash</i>.
+ * Adds the contents of <i>other_hash</i> to <i>hsh</i>. If no
+ * block is specified entries with duplicate keys are overwritten
+ * with the values from <i>other_hash</i>, otherwise the value
+ * of each duplicate key is detemined by calling the block with
+ * the key, its value in <i>hsh</i> and its value in <i>other_hash</i>.
*
* h1 = { "a" => 100, "b" => 200 }
* h2 = { "b" => 254, "c" => 300 }
* h1.merge!(h2) #=> {"a"=>100, "b"=>254, "c"=>300}
+ * h1.merge!(h2) { |key, v1, v2| v1 }
+ * #=> {"a"=>100, "b"=>200, "c"=>300}
*/
static VALUE
@@ -1932,7 +1945,7 @@ env_aset(obj, nm, val)
char *name, *value;
if (rb_safe_level() >= 4) {
- rb_raise(rb_eSecurityError, "cannot change environment variable");
+ rb_raise(rb_eSecurityError, "can't change environment variable");
}
if (NIL_P(val)) {
diff --git a/intern.h b/intern.h
index 1da256973c..e215caa00f 100644
--- a/intern.h
+++ b/intern.h
@@ -60,8 +60,6 @@ VALUE rb_ary_assoc _((VALUE, VALUE));
VALUE rb_ary_rassoc _((VALUE, VALUE));
VALUE rb_ary_includes _((VALUE, VALUE));
VALUE rb_ary_cmp _((VALUE, VALUE));
-VALUE rb_protect_inspect _((VALUE(*)(ANYARGS),VALUE,VALUE));
-VALUE rb_inspecting_p _((VALUE));
VALUE rb_check_array_value _((VALUE));
VALUE rb_get_values_at _((VALUE, long, int, VALUE*, VALUE(*) _((VALUE,long))));
/* bignum.c */
@@ -175,7 +173,7 @@ int rb_respond_to _((VALUE, ID));
void rb_interrupt _((void));
VALUE rb_apply _((VALUE, ID, VALUE));
void rb_backtrace _((void));
-ID rb_frame_last_func _((void));
+ID rb_frame_this_func _((void));
VALUE rb_obj_instance_eval _((int, VALUE*, VALUE));
VALUE rb_mod_module_eval _((int, VALUE*, VALUE));
void rb_load _((VALUE, int));
@@ -227,6 +225,7 @@ VALUE rb_thread_main _((void));
VALUE rb_thread_local_aref _((VALUE, ID));
VALUE rb_thread_local_aset _((VALUE, ID, VALUE));
void rb_thread_atfork _((void));
+VALUE rb_exec_recursive _((VALUE(*)(ANYARGS),VALUE,VALUE));
/* file.c */
int eaccess _((const char*, int));
VALUE rb_file_s_expand_path _((int, VALUE *));
diff --git a/io.c b/io.c
index 0f8da47751..c8de07f1e2 100644
--- a/io.c
+++ b/io.c
@@ -15,7 +15,6 @@
#include "ruby.h"
#include "rubyio.h"
#include "rubysig.h"
-#include "env.h"
#include <ctype.h>
#include <errno.h>
@@ -174,7 +173,7 @@ is_socket(fd, path)
void
rb_eof_error()
{
- rb_raise(rb_eEOFError, "End of file reached");
+ rb_raise(rb_eEOFError, "end of file reached");
}
VALUE
@@ -801,8 +800,7 @@ static int
io_getc(OpenFile *fptr)
{
int r;
- if (fptr->fd == 0 && (fptr->mode & FMODE_TTY) &&
- TYPE(rb_stdout) == T_FILE) {
+ if (fptr->fd == 0 && (fptr->mode & FMODE_TTY) && TYPE(rb_stdout) == T_FILE) {
OpenFile *ofp;
GetOpenFile(rb_stdout, ofp);
if (ofp->mode & FMODE_TTY) {
@@ -2415,7 +2413,7 @@ rb_io_flags_mode(flags)
}
return MODE_BINMODE("r+", "rb+");
}
- rb_raise(rb_eArgError, "illegal access mode %o", flags);
+ rb_raise(rb_eArgError, "illegal access modenum %o", flags);
return NULL; /* not reached */
}
@@ -3278,6 +3276,10 @@ rb_f_open(argc, argv)
if (rb_respond_to(argv[0], to_open)) {
VALUE io = rb_funcall2(argv[0], to_open, argc-1, argv+1);
+
+ if (TYPE(io) != T_FILE) {
+ rb_raise(rb_eTypeError, "to_open should return IO value");
+ }
if (rb_block_given_p()) {
return rb_ensure(rb_yield, io, io_close, io);
}
@@ -3331,7 +3333,7 @@ io_reopen(io, nfile)
if (IS_PREP_STDIO(fptr)) {
if ((fptr->mode & FMODE_READWRITE) != (orig->mode & FMODE_READWRITE)) {
rb_raise(rb_eArgError,
- "%s cannot change access mode from \"%s\" to \"%s\"",
+ "%s can't change access mode from \"%s\" to \"%s\"",
PREP_STDIO_NAME(fptr), rb_io_flags_mode(fptr->mode),
rb_io_flags_mode(orig->mode));
}
@@ -3445,7 +3447,7 @@ rb_io_reopen(argc, argv, file)
if (IS_PREP_STDIO(fptr) &&
(fptr->mode & FMODE_READWRITE) != (flags & FMODE_READWRITE)) {
rb_raise(rb_eArgError,
- "%s cannot change access mode from \"%s\" to \"%s\"",
+ "%s can't change access mode from \"%s\" to \"%s\"",
PREP_STDIO_NAME(fptr), rb_io_flags_mode(fptr->mode),
rb_io_flags_mode(flags));
}
@@ -3698,7 +3700,7 @@ rb_f_putc(recv, ch)
}
static VALUE
-io_puts_ary(ary, out)
+io_puts_ary(ary, out, recur)
VALUE ary, out;
{
VALUE tmp;
@@ -3706,7 +3708,7 @@ io_puts_ary(ary, out)
for (i=0; i<RARRAY(ary)->len; i++) {
tmp = RARRAY(ary)->ptr[i];
- if (rb_inspecting_p(tmp)) {
+ if (recur) {
tmp = rb_str_new2("[...]");
}
rb_io_puts(1, &tmp, out);
@@ -3755,7 +3757,7 @@ rb_io_puts(argc, argv, out)
else {
line = rb_check_array_type(argv[i]);
if (!NIL_P(line)) {
- rb_protect_inspect(io_puts_ary, line, out);
+ rb_exec_recursive(io_puts_ary, line, out);
continue;
}
line = rb_obj_as_string(argv[i]);
@@ -4161,18 +4163,20 @@ rb_io_s_for_fd(argc, argv, klass)
static int binmode = 0;
static VALUE
-argf_forward(VALUE *argv)
+argf_forward(argc, argv)
+ int argc;
+ VALUE *argv;
{
- return rb_funcall3(current_file, ruby_frame->last_func, ruby_frame->argc, argv);
+ return rb_funcall3(current_file, rb_frame_this_func(), argc, argv);
}
-#define ARGF_FORWARD(argv) do {\
+#define ARGF_FORWARD(argc, argv) do {\
if (TYPE(current_file) != T_FILE)\
- return argf_forward(argv);\
+ return argf_forward(argc, argv);\
} while (0)
-#define NEXT_ARGF_FORWARD(argv) do {\
+#define NEXT_ARGF_FORWARD(argc, argv) do {\
if (!next_argv()) return Qnil;\
- ARGF_FORWARD(argv);\
+ ARGF_FORWARD(argc, argv);\
} while (0)
static void
@@ -4428,7 +4432,7 @@ rb_f_readline(argc, argv)
VALUE line;
if (!next_argv()) rb_eof_error();
- ARGF_FORWARD(argv);
+ ARGF_FORWARD(argc, argv);
line = rb_f_gets(argc, argv);
if (NIL_P(line)) {
rb_eof_error();
@@ -4465,7 +4469,7 @@ rb_f_readlines(argc, argv)
{
VALUE line, ary;
- NEXT_ARGF_FORWARD(argv);
+ NEXT_ARGF_FORWARD(argc, argv);
ary = rb_ary_new();
while (!NIL_P(line = argf_getline(argc, argv))) {
rb_ary_push(ary, line);
@@ -5138,7 +5142,7 @@ argf_tell()
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to tell");
}
- ARGF_FORWARD(0);
+ ARGF_FORWARD(0, 0);
return rb_io_tell(current_file);
}
@@ -5151,7 +5155,7 @@ argf_seek_m(argc, argv, self)
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to seek");
}
- ARGF_FORWARD(argv);
+ ARGF_FORWARD(argc, argv);
return rb_io_seek_m(argc, argv, current_file);
}
@@ -5162,7 +5166,7 @@ argf_set_pos(self, offset)
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to set position");
}
- ARGF_FORWARD(&offset);
+ ARGF_FORWARD(1, &offset);
return rb_io_set_pos(current_file, offset);
}
@@ -5172,7 +5176,7 @@ argf_rewind()
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to rewind");
}
- ARGF_FORWARD(0);
+ ARGF_FORWARD(0, 0);
return rb_io_rewind(current_file);
}
@@ -5182,7 +5186,7 @@ argf_fileno()
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream");
}
- ARGF_FORWARD(0);
+ ARGF_FORWARD(0, 0);
return rb_io_fileno(current_file);
}
@@ -5190,7 +5194,7 @@ static VALUE
argf_to_io()
{
next_argv();
- ARGF_FORWARD(0);
+ ARGF_FORWARD(0, 0);
return current_file;
}
@@ -5199,7 +5203,7 @@ argf_eof()
{
if (current_file) {
if (init_p == 0) return Qtrue;
- ARGF_FORWARD(0);
+ ARGF_FORWARD(0, 0);
if (rb_io_eof(current_file)) {
return Qtrue;
}
@@ -5230,7 +5234,7 @@ argf_read(argc, argv)
return str;
}
if (TYPE(current_file) != T_FILE) {
- tmp = argf_forward(argv);
+ tmp = argf_forward(argc, argv);
}
else {
tmp = io_read(argc, argv, current_file);
@@ -5325,7 +5329,7 @@ argf_readchar()
{
VALUE c;
- NEXT_ARGF_FORWARD(0);
+ NEXT_ARGF_FORWARD(0, 0);
c = argf_getc();
if (NIL_P(c)) {
rb_eof_error();
@@ -5384,7 +5388,7 @@ argf_binmode()
{
binmode = 1;
next_argv();
- ARGF_FORWARD(0);
+ ARGF_FORWARD(0, 0);
rb_io_binmode(current_file);
return argf;
}
@@ -5415,7 +5419,7 @@ static VALUE
argf_closed()
{
next_argv();
- ARGF_FORWARD(0);
+ ARGF_FORWARD(0, 0);
return rb_io_closed(current_file);
}
diff --git a/lib/date.rb b/lib/date.rb
index 9771825411..1cd4e08049 100644
--- a/lib/date.rb
+++ b/lib/date.rb
@@ -1300,7 +1300,7 @@ class DateTime < Date
def to_date() Date.new0(self.class.jd_to_ajd(jd, 0, 0), 0, @sg) end
def to_datetime() self end
- class << self; undef_method :today end
+ class << self; undef_method :today end rescue nil
# Create a new DateTime object representing the current time.
#
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index adba38ed63..b4ed5f5153 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -370,7 +370,7 @@ module FileUtils
#
# # Examples of copying several files to target directory.
# FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
- # FileUtils.cp_r Dir.glob('*.rb'), '/home/aamine/lib/ruby', :noop, :verbose
+ # FileUtils.cp_r Dir.glob('*.rb'), '/home/aamine/lib/ruby', :noop => true, :verbose => true
#
# # If you want to copy all contents of a directory instead of the
# # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
diff --git a/lib/irb/context.rb b/lib/irb/context.rb
index 9421608f85..01856cd2e7 100644
--- a/lib/irb/context.rb
+++ b/lib/irb/context.rb
@@ -38,7 +38,7 @@ module IRB
@inspect_mode = IRB.conf[:INSPECT_MODE]
self.math_mode = IRB.conf[:MATH_MODE] if IRB.conf[:MATH_MODE]
- self.use_tracer = IRB.conf[:USE_TRACER] if IRB.conf[:USE_TRASER]
+ self.use_tracer = IRB.conf[:USE_TRACER] if IRB.conf[:USE_TRACER]
self.use_loader = IRB.conf[:USE_LOADER] if IRB.conf[:USE_LOADER]
self.eval_history = IRB.conf[:EVAL_HISTORY] if IRB.conf[:EVAL_HISTORY]
diff --git a/lib/open3.rb b/lib/open3.rb
index 1ddd213f61..69a29aace1 100644
--- a/lib/open3.rb
+++ b/lib/open3.rb
@@ -42,7 +42,7 @@ module Open3
exec(*cmd)
}
- exit!
+ exit!(0)
}
pw[0].close
diff --git a/lib/parsedate.rb b/lib/parsedate.rb
index 405ab46907..2c24ec1636 100644
--- a/lib/parsedate.rb
+++ b/lib/parsedate.rb
@@ -10,6 +10,11 @@ module ParseDate
values_at(:year, :mon, :mday, :hour, :min, :sec, :zone, :wday)
end
- module_function :parsedate
+ def strptime(str, format)
+ Date._strptime(str, format).
+ values_at(:year, :mon, :mday, :hour, :min, :sec, :zone, :wday)
+ end
+
+ module_function :parsedate, :strptime
end
diff --git a/lib/pstore.rb b/lib/pstore.rb
index 50313dcb8f..51cef6e134 100644
--- a/lib/pstore.rb
+++ b/lib/pstore.rb
@@ -104,10 +104,14 @@ class PStore
commit_new(file) if FileTest.exist?(new_file)
content = file.read()
else
- file = File.open(@filename, File::RDONLY)
- file.binmode
- file.flock(File::LOCK_SH)
- content = (File.read(new_file) rescue file.read())
+ begin
+ file = File.open(@filename, File::RDONLY)
+ file.binmode
+ file.flock(File::LOCK_SH)
+ content = (File.read(new_file) rescue file.read())
+ rescue Errno::ENOENT
+ content = ""
+ end
end
if content != ""
diff --git a/lib/rdoc/generators/html_generator.rb b/lib/rdoc/generators/html_generator.rb
index f9c72a4df2..d263a14784 100644
--- a/lib/rdoc/generators/html_generator.rb
+++ b/lib/rdoc/generators/html_generator.rb
@@ -314,7 +314,7 @@ module Generators
def collect_methods
list = @context.method_list
unless @options.show_all
- list = list.find_all {|m| m.visibility == :public || m.force_documentation }
+ list = list.find_all {|m| m.visibility == :public || m.visibility == :protected || m.force_documentation }
end
@methods = list.collect {|m| HtmlMethod.new(m, self, @options) }
end
@@ -681,13 +681,13 @@ module Generators
res = []
atts.each do |att|
next unless att.section == section
- if att.visibility == :public || @options.show_all
+ if att.visibility == :public || att.visibility == :protected || @options.show_all
entry = {
"name" => CGI.escapeHTML(att.name),
"rw" => att.rw,
"a_desc" => markup(att.comment, true)
}
- unless att.visibility == :public
+ unless att.visibility == :public || att.visibility == :protected
entry["rw"] << "-"
end
res << entry
diff --git a/lib/rdoc/generators/ri_generator.rb b/lib/rdoc/generators/ri_generator.rb
index 8d94579347..c4b4a7e17c 100644
--- a/lib/rdoc/generators/ri_generator.rb
+++ b/lib/rdoc/generators/ri_generator.rb
@@ -172,7 +172,7 @@ module Generators
list = cls.method_list
unless @options.show_all
list = list.find_all do |m|
- m.visibility == :public || m.force_documentation
+ m.visibility == :public || m.visibility == :protected || m.force_documentation
end
end
diff --git a/lib/rdoc/parsers/parse_c.rb b/lib/rdoc/parsers/parse_c.rb
index 6c9134fc62..25ce83dd8e 100644
--- a/lib/rdoc/parsers/parse_c.rb
+++ b/lib/rdoc/parsers/parse_c.rb
@@ -174,7 +174,7 @@ module RDoc
# prepare to parse a C file
def initialize(top_level, file_name, body, options, stats)
@known_classes = KNOWN_CLASSES.dup
- @body = handle_ifdefs_in(body)
+ @body = handle_tab_width(handle_ifdefs_in(body))
@options = options
@stats = stats
@top_level = top_level
@@ -187,6 +187,7 @@ module RDoc
def scan
remove_commented_out_lines
do_classes
+ do_constants
do_methods
do_includes
do_aliases
@@ -240,7 +241,7 @@ module RDoc
if @body =~ %r{((?>/\*.*?\*/\s+))
(static\s+)?void\s+Init_#{class_name}\s*\(\)}xmi
comment = $1
- elsif @body =~ %r{Document-(class|module):\s#{class_name}.*?\n((?>.*?\*/))}m
+ elsif @body =~ %r{Document-(class|module):\s#{class_name}\s*?\n((?>.*?\*/))}m
comment = $2
end
class_meth.comment = mangle_comment(comment) if comment
@@ -249,13 +250,13 @@ module RDoc
############################################################
def do_classes
- @body.scan(/(\w+)\s* = \s*rb_define_module\(\s*"(\w+)"\s*\)/mx) do
+ @body.scan(/(\w+)\s* = \s*rb_define_module\s*\(\s*"(\w+)"\s*\)/mx) do
|var_name, class_name|
handle_class_module(var_name, "module", class_name, nil, nil)
end
# The '.' lets us handle SWIG-generated files
- @body.scan(/([\w\.]+)\s* = \s*rb_define_class
+ @body.scan(/([\w\.]+)\s* = \s*rb_define_class\s*
\(
\s*"(\w+)",
\s*(\w+)\s*
@@ -265,7 +266,7 @@ module RDoc
handle_class_module(var_name, "class", class_name, parent, nil)
end
- @body.scan(/(\w+)\s*=\s*boot_defclass\(\s*"(\w+?)",\s*(\w+?)\)/) do
+ @body.scan(/(\w+)\s*=\s*boot_defclass\s*\(\s*"(\w+?)",\s*(\w+?)\s*\)/) do
|var_name, class_name, parent|
parent = nil if parent == "0"
handle_class_module(var_name, "class", class_name, parent, nil)
@@ -281,18 +282,40 @@ module RDoc
handle_class_module(var_name, "module", class_name, nil, in_module)
end
- @body.scan(/([\w\.]+)\s* = \s*rb_define_class_under
+ @body.scan(/([\w\.]+)\s* = \s*rb_define_class_under\s*
\(
\s*(\w+),
\s*"(\w+)",
\s*(\w+)\s*
- \)/mx) do
+ \s*\)/mx) do
|var_name, in_module, class_name, parent|
handle_class_module(var_name, "class", class_name, parent, in_module)
end
end
+
+ ###########################################################
+
+ def do_constants
+ @body.scan(%r{\Wrb_define_
+ (
+ variable |
+ readonly_variable |
+ const |
+ global_const |
+ )
+ \s*\(
+ (?:\s*(\w+),)?
+ \s*"(\w+)",
+ \s*(.*?)\s*\)\s*;
+ }xm) do
+
+ |type, var_name, const_name, definition|
+ var_name = "rb_cObject" if !var_name or var_name == "rb_mKernel"
+ handle_constants(type, var_name, const_name, definition)
+ end
+ end
############################################################
@@ -305,7 +328,7 @@ module RDoc
module_function |
private_method
)
- \(\s*([\w\.]+),
+ \s*\(\s*([\w\.]+),
\s*"([^"]+)",
\s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
\s*(-?\w+)\s*\)
@@ -325,7 +348,21 @@ module RDoc
meth_body, param_count, source_file)
end
- @body.scan(%r{rb_define_global_function\(
+ @body.scan(%r{rb_define_attr\(
+ \s*([\w\.]+),
+ \s*"([^"]+)",
+ \s*(\d+),
+ \s*(\d+)\s*\);
+ }xm) do #"
+ |var_name, attr_name, attr_reader, attr_writer|
+
+ #var_name = "rb_cObject" if var_name == "rb_mKernel"
+ handle_attr(var_name, attr_name,
+ attr_reader.to_i != 0,
+ attr_writer.to_i != 0)
+ end
+
+ @body.scan(%r{rb_define_global_function\s*\(
\s*"([^"]+)",
\s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
\s*(-?\w+)\s*\)
@@ -336,7 +373,7 @@ module RDoc
meth_body, param_count, source_file)
end
- @body.scan(/define_filetest_function\(
+ @body.scan(/define_filetest_function\s*\(
\s*"([^"]+)",
\s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
\s*(-?\w+)\s*\)/xm) do #"
@@ -350,7 +387,7 @@ module RDoc
############################################################
def do_aliases
- @body.scan(%r{rb_define_alias\(\s*(\w+),\s*"([^"]+)",\s*"([^"]+)"\s*\)}m) do
+ @body.scan(%r{rb_define_alias\s*\(\s*(\w+),\s*"([^"]+)",\s*"([^"]+)"\s*\)}m) do
|var_name, new_name, old_name|
@stats.num_methods += 1
class_name = @known_classes[var_name] || var_name
@@ -362,6 +399,83 @@ module RDoc
############################################################
+ def handle_constants(type, var_name, const_name, definition)
+ #@stats.num_constants += 1
+ class_name = @known_classes[var_name]
+
+ return unless class_name
+
+ class_obj = find_class(var_name, class_name)
+
+ unless class_obj
+ $stderr.puts("Enclosing class/module '#{const_name}' for not known")
+ return
+ end
+
+ comment = find_const_comment(type, const_name)
+
+ con = Constant.new(const_name, definition, mangle_comment(comment))
+ class_obj.add_constant(con)
+ end
+
+ ###########################################################
+
+ def find_const_comment(type, const_name)
+ if @body =~ %r{((?>/\*.*?\*/\s+))
+ rb_define_#{type}\((?:\s*(\w+),)?\s*"#{const_name}"\s*,.*?\)\s*;}xmi
+ $1
+ elsif @body =~ %r{Document-(?:const|global|variable):\s#{const_name}\s*?\n((?>.*?\*/))}m
+ $1
+ else
+ ''
+ end
+ end
+
+ ###########################################################
+
+ def handle_attr(var_name, attr_name, reader, writer)
+ rw = ''
+ if reader
+ #@stats.num_methods += 1
+ rw << 'R'
+ end
+ if writer
+ #@stats.num_methods += 1
+ rw << 'W'
+ end
+
+ class_name = @known_classes[var_name]
+
+ return unless class_name
+
+ class_obj = find_class(var_name, class_name)
+
+ if class_obj
+ comment = find_attr_comment(attr_name)
+ unless comment.empty?
+ comment = mangle_comment(comment)
+ end
+ att = Attr.new('', attr_name, rw, comment)
+ class_obj.add_attribute(att)
+ end
+
+ end
+
+ ###########################################################
+
+ def find_attr_comment(attr_name)
+ if @body =~ %r{((?>/\*.*?\*/\s+))
+ rb_define_attr\((?:\s*(\w+),)?\s*"#{attr_name}"\s*,.*?\)\s*;}xmi
+ $1
+ elsif @body =~ %r{Document-attr:\s#{attr_name}\s*?\n((?>.*?\*/))}m
+ $1
+ else
+ ''
+ end
+ end
+
+ ###########################################################
+
def handle_method(type, var_name, meth_name,
meth_body, param_count, source_file = nil)
@stats.num_methods += 1
@@ -469,12 +583,10 @@ module RDoc
############################################################
def find_override_comment(meth_name)
- comment = nil
name = Regexp.escape(meth_name)
- if @body =~ %r{Document-method:\s#{name}.*?\n((?>.*?\*/))}m
- comment = $1
+ if @body =~ %r{Document-method:\s#{name}\s*?\n((?>.*?\*/))}m
+ $1
end
- comment
end
############################################################
@@ -482,7 +594,7 @@ module RDoc
# Look for includes of the form
# rb_include_module(rb_cArray, rb_mEnumerable);
def do_includes
- @body.scan(/rb_include_module\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m|
+ @body.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m|
if cls = @classes[c]
m = KNOWN_CLASSES[m] || m
cls.add_include(Include.new(m, ""))
@@ -512,6 +624,18 @@ module RDoc
@classes[raw_name]
end
+ def handle_tab_width(body)
+ if /\t/ =~ body
+ tab_width = Options.instance.tab_width
+ body.split(/\n/).map do |line|
+ 1 while line.gsub!(/\t+/) { ' ' * (tab_width*$&.length - $`.length % tab_width)} && $~ #`
+ line
+ end .join("\n")
+ else
+ body
+ end
+ end
+
# Remove #ifdefs that would otherwise confuse us
def handle_ifdefs_in(body)
diff --git a/lib/rdoc/parsers/parse_rb.rb b/lib/rdoc/parsers/parse_rb.rb
index 15b3484cb7..8e91c01e61 100644
--- a/lib/rdoc/parsers/parse_rb.rb
+++ b/lib/rdoc/parsers/parse_rb.rb
@@ -1883,6 +1883,7 @@ module RDoc
name_t = get_tk
back_tk = skip_tkspace
meth = nil
+ added_container = false
dot = get_tk
if dot.kind_of?(TkDOT) or dot.kind_of?(TkCOLON2)
@@ -1897,8 +1898,21 @@ module RDoc
prev_container = container
container = container.find_module_named(name_t.name)
if !container
- warn("Couldn't find #{name_t.name}. Assuming it's a module")
- container = prev_container.add_module(NormalModule, name_t.name)
+ added_container = true
+ obj = name_t.name.split("::").inject(Object) do |state, item|
+ state.const_get(item)
+ end rescue nil
+
+ type = obj.class == Class ? NormalClass : NormalModule
+ if not [Class, Module].include?(obj.class)
+ warn("Couldn't find #{name_t.name}. Assuming it's a module")
+ end
+
+ if type == NormalClass then
+ container = prev_container.add_class(type, name_t.name, obj.superclass.name)
+ else
+ container = prev_container.add_module(type, name_t.name)
+ end
end
else
# warn("Unexpected token '#{name_t2.inspect}'")
@@ -1940,7 +1954,9 @@ module RDoc
parse_method_parameters(meth)
if meth.document_self
- container.add_method(meth)
+ container.add_method(meth)
+ elsif added_container
+ container.document_self = false
end
# Having now read the method parameters and documentation modifiers, we
diff --git a/lib/rdoc/parsers/parse_simple.rb b/lib/rdoc/parsers/parse_simple.rb
index b01104574e..3f1a546964 100644
--- a/lib/rdoc/parsers/parse_simple.rb
+++ b/lib/rdoc/parsers/parse_simple.rb
@@ -30,8 +30,12 @@ module RDoc
def scan
# @body.gsub(/^(\s\n)+/, '')
- @top_level.comment = @body
+ @top_level.comment = remove_private_comments(@body)
@top_level
end
+
+ def remove_private_comments(comment)
+ comment.gsub(/^--.*?^\+\+/m, '').sub(/^--.*/m, '')
+ end
end
end
diff --git a/lib/rexml/document.rb b/lib/rexml/document.rb
index a7f056ad3f..39360d4f4a 100644
--- a/lib/rexml/document.rb
+++ b/lib/rexml/document.rb
@@ -156,12 +156,12 @@ module REXML
# unable to parse proper XML, we have to provide a hack to generate XML
# that IE's limited abilities can handle. This hack inserts a space
# before the /> on empty tags. Defaults to false
- def write( output=$stdout, indent=-1, transitive=false, ie_hack=false )
+ def write( output=$stdout, indent_level=-1, transitive=false, ie_hack=false )
output = Output.new( output, xml_decl.encoding ) if xml_decl.encoding != "UTF-8" && !output.kind_of?(Output)
@children.each { |node|
- indent( output, indent ) if node.node_type == :element
- if node.write( output, indent, transitive, ie_hack )
- output << "\n" unless indent<0 or node == @children[-1]
+ indent( output, indent_level ) if node.node_type == :element
+ if node.write( output, indent_level, transitive, ie_hack )
+ output << "\n" unless indent_level<0 or node == @children[-1]
end
}
end
diff --git a/lib/rexml/element.rb b/lib/rexml/element.rb
index b76c0179c7..e18f0b28c7 100644
--- a/lib/rexml/element.rb
+++ b/lib/rexml/element.rb
@@ -199,7 +199,7 @@ module REXML
# b.namespace("y") # -> '2'
def namespace(prefix=nil)
if prefix.nil?
- prefix = prefix()
+ prefix = self.prefix()
end
if prefix == ''
prefix = "xmlns"
diff --git a/lib/rexml/instruction.rb b/lib/rexml/instruction.rb
index 0b770d4b3d..ebd868c95c 100644
--- a/lib/rexml/instruction.rb
+++ b/lib/rexml/instruction.rb
@@ -38,8 +38,8 @@ module REXML
Instruction.new self
end
- def write writer, indent=-1, transitive=false, ie_hack=false
- indent(writer, indent)
+ def write writer, indent_level=-1, transitive=false, ie_hack=false
+ indent(writer, indent_level)
writer << START.sub(/\\/u, '')
writer << @target
writer << ' '
diff --git a/lib/rexml/xmldecl.rb b/lib/rexml/xmldecl.rb
index 3f90e0160f..df2cbf0060 100644
--- a/lib/rexml/xmldecl.rb
+++ b/lib/rexml/xmldecl.rb
@@ -2,71 +2,71 @@ require 'rexml/encoding'
require 'rexml/source'
module REXML
- # NEEDS DOCUMENTATION
- class XMLDecl < Child
- include Encoding
+ # NEEDS DOCUMENTATION
+ class XMLDecl < Child
+ include Encoding
- DEFAULT_VERSION = "1.0";
- DEFAULT_ENCODING = "UTF-8";
- DEFAULT_STANDALONE = "no";
- START = '<\?xml';
- STOP = '\?>';
+ DEFAULT_VERSION = "1.0";
+ DEFAULT_ENCODING = "UTF-8";
+ DEFAULT_STANDALONE = "no";
+ START = '<\?xml';
+ STOP = '\?>';
- attr_accessor :version, :standalone
+ attr_accessor :version, :standalone
attr_reader :writeencoding
- def initialize(version=DEFAULT_VERSION, encoding=nil, standalone=nil)
+ def initialize(version=DEFAULT_VERSION, encoding=nil, standalone=nil)
@writethis = true
@writeencoding = !encoding.nil?
- if version.kind_of? XMLDecl
- super()
- @version = version.version
- self.encoding = version.encoding
+ if version.kind_of? XMLDecl
+ super()
+ @version = version.version
+ self.encoding = version.encoding
@writeencoding = version.writeencoding
- @standalone = version.standalone
- else
- super()
- @version = version
- self.encoding = encoding
- @standalone = standalone
- end
- @version = DEFAULT_VERSION if @version.nil?
- end
+ @standalone = version.standalone
+ else
+ super()
+ @version = version
+ self.encoding = encoding
+ @standalone = standalone
+ end
+ @version = DEFAULT_VERSION if @version.nil?
+ end
- def clone
- XMLDecl.new(self)
- end
+ def clone
+ XMLDecl.new(self)
+ end
- def write writer, indent=-1, transitive=false, ie_hack=false
+ def write writer, indent_level=-1, transitive=false, ie_hack=false
return nil unless @writethis or writer.kind_of? Output
- indent( writer, indent )
- writer << START.sub(/\\/u, '')
+ indent( writer, indent_level )
+ writer << START.sub(/\\/u, '')
if writer.kind_of? Output
writer << " #{content writer.encoding}"
else
writer << " #{content encoding}"
end
- writer << STOP.sub(/\\/u, '')
- end
+ writer << STOP.sub(/\\/u, '')
+ end
- def ==( other )
- other.kind_of?(XMLDecl) and
- other.version == @version and
- other.encoding == self.encoding and
- other.standalone == @standalone
- end
+ def ==( other )
+ other.kind_of?(XMLDecl) and
+ other.version == @version and
+ other.encoding == self.encoding and
+ other.standalone == @standalone
+ end
- def xmldecl version, encoding, standalone
- @version = version
- self.encoding = encoding
- @standalone = standalone
- end
+ def xmldecl version, encoding, standalone
+ @version = version
+ self.encoding = encoding
+ @standalone = standalone
+ end
- def node_type
- :xmldecl
- end
+ def node_type
+ :xmldecl
+ end
- alias :stand_alone? :standalone
+ alias :stand_alone? :standalone
alias :old_enc= :encoding=
def encoding=( enc )
@@ -94,12 +94,12 @@ module REXML
@writethis = true
end
- private
- def content(enc)
- rv = "version='#@version'"
- rv << " encoding='#{enc}'" if @writeencoding || enc !~ /utf-8/i
- rv << " standalone='#@standalone'" if @standalone
- rv
- end
- end
+ private
+ def content(enc)
+ rv = "version='#@version'"
+ rv << " encoding='#{enc}'" if @writeencoding || enc !~ /utf-8/i
+ rv << " standalone='#@standalone'" if @standalone
+ rv
+ end
+ end
end
diff --git a/lib/set.rb b/lib/set.rb
index 8364d4a072..b8dd2ca569 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -438,6 +438,11 @@ class SortedSet < Set
def setup # :nodoc:
@@setup and return
+ module_eval {
+ # a hack to shut up warning
+ alias old_init initialize
+ remove_method :old_init
+ }
begin
require 'rbtree'
diff --git a/lib/time.rb b/lib/time.rb
index e0d831d3b0..ce3614bfce 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -94,6 +94,37 @@ class Time
end
private :zone_utc?
+ def make_time(year, mon, day, hour, min, sec, zone, now)
+ if now
+ begin
+ break if year; year = now.year
+ break if mon; mon = now.mon
+ break if day; day = now.day
+ break if hour; hour = now.hour
+ break if min; min = now.min
+ break if sec; sec = now.sec
+ end until true
+ end
+
+ year ||= 1970
+ mon ||= 1
+ day ||= 1
+ hour ||= 0
+ min ||= 0
+ sec ||= 0
+
+ off = nil
+ off = zone_offset(zone, year) if zone
+
+ if off
+ t = Time.utc(year, mon, day, hour, min, sec) - off
+ t.localtime if !zone_utc?(zone)
+ t
+ else
+ Time.local(year, mon, day, hour, min, sec)
+ end
+ end
+
#
# Parses +date+ using ParseDate.parsedate and converts it to a Time object.
#
@@ -147,35 +178,20 @@ class Time
def parse(date, now=Time.now)
year, mon, day, hour, min, sec, zone, _ = ParseDate.parsedate(date)
year = yield(year) if year && block_given?
+ make_time(year, mon, day, hour, min, sec, zone, now)
+ end
- if now
- begin
- break if year; year = now.year
- break if mon; mon = now.mon
- break if day; day = now.day
- break if hour; hour = now.hour
- break if min; min = now.min
- break if sec; sec = now.sec
- end until true
- end
-
- year ||= 1970
- mon ||= 1
- day ||= 1
- hour ||= 0
- min ||= 0
- sec ||= 0
-
- off = nil
- off = zone_offset(zone, year) if zone
-
- if off
- t = Time.utc(year, mon, day, hour, min, sec) - off
- t.localtime if !zone_utc?(zone)
- t
- else
- Time.local(year, mon, day, hour, min, sec)
- end
+ #
+ # Parses +date+ using ParseDate.strptime and converts it to a Time object.
+ #
+ # If a block is given, the year described in +date+ is converted by the
+ # block. For example:
+ #
+ # Time.parse(...) {|y| y < 100 ? (y >= 69 ? y + 1900 : y + 2000) : y}
+ def strptime(date, format, now=Time.now)
+ year, mon, day, hour, min, sec, zone, _ = ParseDate.strptime(date, format)
+ year = yield(year) if year && block_given?
+ make_time(year, mon, day, hour, min, sec, zone, now)
end
MonthValue = {
diff --git a/lib/timeout.rb b/lib/timeout.rb
index 7e3ee81ed0..36811a1040 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -1,38 +1,39 @@
+# = timeout.rb
#
-# timeout.rb -- execution timeout
+# execution timeout
#
-# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
-# Copyright (C) 2000 Information-technology Promotion Agency, Japan
-#
-#= SYNOPSIS
+# = Synopsis
#
# require 'timeout'
-# status = timeout(5) {
-# # something may take time
+# status = Timeout::timeout(5) {
+# # Something that should be interrupted if it takes too much time...
# }
#
-#= DESCRIPTION
-#
-# timeout executes the block. If the block execution terminates successfully
-# before timeout, it returns true. If not, it terminates the execution and
-# raise TimeoutError exception.
-#
-#== Parameters
-#
-# : timout
+# = Description
#
-# The time in seconds to wait for block termination.
+# A way of performing a potentially long-running operation in a thread, and terminating
+# it's execution if it hasn't finished by a fixed amount of time.
#
-# : [exception]
+# Previous versions of timeout didn't provide use a module for namespace. This version
+# provides both Timeout.timeout, and a backwards-compatible #timeout.
#
-# The exception class to be raised on timeout.
+# = Copyright
#
-#=end
+# Copyright:: (C) 2000 Network Applied Communication Laboratory, Inc.
+# Copyright:: (C) 2000 Information-technology Promotion Agency, Japan
module Timeout
+ # Raised by Timeout#timeout when the block times out.
class Error<Interrupt
end
+ # Executes the method's block. If the block execution terminates before +sec+
+ # seconds has passed, it returns true. If not, it terminates the execution
+ # and raises +exception+ (which defaults to Timeout::Error).
+ #
+ # Note that this is both a method of module Timeout, so you can 'include Timeout'
+ # into your classes so they have a #timeout method, as well as a module method,
+ # so you can call it directly as Timeout.timeout().
def timeout(sec, exception=Error)
return yield if sec == nil or sec.zero?
raise ThreadError, "timeout within critical session" if Thread.critical
@@ -48,13 +49,22 @@ module Timeout
y.kill if y and y.alive?
end
end
+
module_function :timeout
end
-# compatible
+# Identical to:
+#
+# Timeout::timeout(n, e, &block).
+#
+# Defined for backwards compatibility with earlier versions of timeout.rb, see
+# Timeout#timeout.
def timeout(n, e=Timeout::Error, &block)
Timeout::timeout(n, e, &block)
end
+
+# Another name for Timeout::Error, defined for backwards compatibility with
+# earlier versions of timeout.rb.
TimeoutError = Timeout::Error
if __FILE__ == $0
diff --git a/lib/wsdl/soap/definitions.rb b/lib/wsdl/soap/definitions.rb
index 2f6e7e19f0..fced82bdec 100644
--- a/lib/wsdl/soap/definitions.rb
+++ b/lib/wsdl/soap/definitions.rb
@@ -77,8 +77,8 @@ class Definitions < Info
def collect_faulttypes
result = []
- collect_fault_messages.each do |message|
- parts = message(message).parts
+ collect_fault_messages.each do |m|
+ parts = message(m).parts
if parts.size != 1
raise RuntimeError.new("Expecting fault message to have only 1 part.")
end
diff --git a/lib/xmlrpc/parser.rb b/lib/xmlrpc/parser.rb
index 2062ec1f05..931f93583b 100644
--- a/lib/xmlrpc/parser.rb
+++ b/lib/xmlrpc/parser.rb
@@ -51,7 +51,7 @@ end # module NQXML
module XMLRPC
- class FaultException < Exception
+ class FaultException < StandardError
attr_reader :faultCode, :faultString
def initialize(faultCode, faultString)
diff --git a/marshal.c b/marshal.c
index 5323fdde25..3791c4c79a 100644
--- a/marshal.c
+++ b/marshal.c
@@ -111,7 +111,7 @@ class2path(klass)
n);
}
if (rb_path2class(n) != rb_class_real(klass)) {
- rb_raise(rb_eTypeError, "%s cannot be referred", n);
+ rb_raise(rb_eTypeError, "%s can't be referred", n);
}
return path;
}
@@ -615,7 +615,7 @@ w_object(obj, arg, limit)
}
else if (FL_TEST(obj, FL_USER2)) {
/* FL_USER2 means HASH_PROC_DEFAULT (see hash.c) */
- rb_raise(rb_eTypeError, "cannot dump hash with default proc");
+ rb_raise(rb_eTypeError, "can't dump hash with default proc");
}
else {
w_byte(TYPE_HASH_DEF, arg);
diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el
index 829ef81765..64d231f58f 100644
--- a/misc/ruby-mode.el
+++ b/misc/ruby-mode.el
@@ -302,7 +302,8 @@ The variable ruby-indent-level controls the amount of indentation.
(defun ruby-expr-beg (&optional option)
(save-excursion
(store-match-data nil)
- (let ((space (skip-chars-backward " \t")))
+ (let ((start (point))
+ (space (skip-chars-backward " \t")))
(cond
((bolp) t)
((progn
@@ -311,7 +312,8 @@ The variable ruby-indent-level controls the amount of indentation.
(or (eq (char-syntax (char-before (point))) ?w)
(ruby-special-char-p))))
nil)
- ((or (looking-at ruby-operator-re)
+ ((or (goto-char start)
+ (looking-at ruby-operator-re)
(looking-at "[\\[({,;]")
(and (or (not (eq option 'heredoc))
(< space 0))
diff --git a/numeric.c b/numeric.c
index 71a6d10c20..bfa6b2602b 100644
--- a/numeric.c
+++ b/numeric.c
@@ -154,7 +154,7 @@ rb_num_coerce_bin(x, y)
VALUE x, y;
{
do_coerce(&x, &y, Qtrue);
- return rb_funcall(x, ruby_frame->orig_func, 1, y);
+ return rb_funcall(x, rb_frame_this_func(), 1, y);
}
VALUE
@@ -162,7 +162,7 @@ rb_num_coerce_cmp(x, y)
VALUE x, y;
{
if (do_coerce(&x, &y, Qfalse))
- return rb_funcall(x, ruby_frame->orig_func, 1, y);
+ return rb_funcall(x, rb_frame_this_func(), 1, y);
return Qnil;
}
@@ -173,7 +173,7 @@ rb_num_coerce_relop(x, y)
VALUE c, x0 = x, y0 = y;
if (!do_coerce(&x, &y, Qfalse) ||
- NIL_P(c = rb_funcall(x, ruby_frame->orig_func, 1, y))) {
+ NIL_P(c = rb_funcall(x, rb_frame_this_func(), 1, y))) {
rb_cmperr(x0, y0);
return Qnil; /* not reached */
}
@@ -1438,7 +1438,7 @@ num_step(argc, argv, from)
rb_raise(rb_eArgError, "wrong number of arguments");
}
if (rb_equal(step, INT2FIX(0))) {
- rb_raise(rb_eArgError, "step cannot be 0");
+ rb_raise(rb_eArgError, "step can't be 0");
}
}
diff --git a/object.c b/object.c
index 13f16b1c80..743de94242 100644
--- a/object.c
+++ b/object.c
@@ -138,21 +138,6 @@ rb_obj_id(obj)
return (VALUE)((long)obj|FIXNUM_FLAG);
}
-/*
- * call-seq:
- * obj.id => fixnum
- *
- * Soon-to-be deprecated version of <code>Object#object_id</code>.
- */
-
-VALUE
-rb_obj_id_obsolete(obj)
- VALUE obj;
-{
- rb_warn("Object#id will be deprecated; use Object#object_id");
- return rb_obj_id(obj);
-}
-
VALUE
rb_class_real(cl)
VALUE cl;
@@ -165,21 +150,6 @@ rb_class_real(cl)
/*
* call-seq:
- * obj.type => class
- *
- * Deprecated synonym for <code>Object#class</code>.
- */
-
-VALUE
-rb_obj_type(obj)
- VALUE obj;
-{
- rb_warn("Object#type is deprecated; use Object#class");
- return rb_class_real(CLASS_OF(obj));
-}
-
-/*
- * call-seq:
* obj.class => class
*
* Returns the class of <i>obj</i>, now preferred over
@@ -375,10 +345,16 @@ inspect_i(id, value, str)
}
static VALUE
-inspect_obj(obj, str)
+inspect_obj(obj, str, recur)
VALUE obj, str;
+ int recur;
{
- st_foreach_safe(ROBJECT(obj)->iv_tbl, inspect_i, str);
+ if (recur) {
+ rb_str_cat2(str, "...");
+ }
+ else {
+ st_foreach_safe(ROBJECT(obj)->iv_tbl, inspect_i, str);
+ }
rb_str_cat2(str, ">");
RSTRING(str)->ptr[0] = '#';
OBJ_INFECT(str, obj);
@@ -410,16 +386,10 @@ rb_obj_inspect(obj)
char *c;
c = rb_obj_classname(obj);
- if (rb_inspecting_p(obj)) {
- str = rb_str_new(0, strlen(c)+10+16+1); /* 10:tags 16:addr 1:nul */
- sprintf(RSTRING(str)->ptr, "#<%s:0x%lx ...>", c, obj);
- RSTRING(str)->len = strlen(RSTRING(str)->ptr);
- return str;
- }
- str = rb_str_new(0, strlen(c)+6+16+1); /* 6:tags 16:addr 1:nul */
+ str = rb_str_new(0, strlen(c)+10+16+1); /* 10:tags 16:addr 1:nul */
sprintf(RSTRING(str)->ptr, "-<%s:0x%lx", c, obj);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
- return rb_protect_inspect(inspect_obj, obj, str);
+ return rb_exec_recursive(inspect_obj, obj, str);
}
return rb_funcall(obj, rb_intern("to_s"), 0, 0);
}
@@ -1295,12 +1265,6 @@ rb_class_inherited_p(mod, arg)
default:
rb_raise(rb_eTypeError, "compared with non class/module");
}
-
- if (FL_TEST(mod, FL_SINGLETON)) {
- if (RCLASS(mod)->m_tbl == RCLASS(arg)->m_tbl)
- return Qtrue;
- mod = RBASIC(mod)->klass;
- }
while (mod) {
if (RCLASS(mod)->m_tbl == RCLASS(arg)->m_tbl)
return Qtrue;
@@ -1496,8 +1460,8 @@ rb_class_initialize(argc, argv, klass)
}
RCLASS(klass)->super = super;
rb_make_metaclass(klass, RBASIC(super)->klass);
- rb_mod_initialize(klass);
rb_class_inherited(super, klass);
+ rb_mod_initialize(klass);
return klass;
}
@@ -1587,9 +1551,6 @@ rb_class_superclass(klass)
if (!super) {
rb_raise(rb_eTypeError, "uninitialized class");
}
- if (FL_TEST(klass, FL_SINGLETON)) {
- super = RBASIC(klass)->klass;
- }
while (TYPE(super) == T_ICLASS) {
super = RCLASS(super)->super;
}
@@ -1972,7 +1933,8 @@ rb_obj_ivar_get(obj, iv)
*
* Sets the instance variable names by <i>symbol</i> to
* <i>object</i>, thereby frustrating the efforts of the class's
- * author to attempt to provide proper encapsulation.
+ * author to attempt to provide proper encapsulation. The variable
+ * did not have to exist prior to this call.
*
* class Fred
* def initialize(p1, p2)
@@ -1981,7 +1943,8 @@ rb_obj_ivar_get(obj, iv)
* end
* fred = Fred.new('cat', 99)
* fred.instance_variable_set(:@a, 'dog') #=> "dog"
- * fred.inspect #=> "#<Fred:0x401b3da8 @a=\"dog\", @b=99>"
+ * fred.instance_variable_set(:@c, 'cat') #=> "cat"
+ * fred.inspect #=> "#<Fred:0x401b3da8 @a=\"dog\", @b=99, @c=\"cat\">"
*/
static VALUE
@@ -2064,7 +2027,7 @@ convert_type(val, tname, method, raise)
m = rb_intern(method);
if (!rb_respond_to(val, m)) {
if (raise) {
- rb_raise(rb_eTypeError, "cannot convert %s into %s",
+ rb_raise(rb_eTypeError, "can't convert %s into %s",
NIL_P(val) ? "nil" :
val == Qtrue ? "true" :
val == Qfalse ? "false" :
@@ -2090,7 +2053,7 @@ rb_convert_type(val, type, tname, method)
v = convert_type(val, tname, method, Qtrue);
if (TYPE(v) != type) {
char *cname = rb_obj_classname(val);
- rb_raise(rb_eTypeError, "cannot convert %s to %s (%s#%s gives %s)",
+ rb_raise(rb_eTypeError, "can't convert %s to %s (%s#%s gives %s)",
cname, tname, cname, method, rb_obj_classname(v));
}
return v;
@@ -2110,7 +2073,7 @@ rb_check_convert_type(val, type, tname, method)
if (NIL_P(v)) return Qnil;
if (TYPE(v) != type) {
char *cname = rb_obj_classname(val);
- rb_raise(rb_eTypeError, "cannot convert %s to %s (%s#%s gives %s)",
+ rb_raise(rb_eTypeError, "can't convert %s to %s (%s#%s gives %s)",
cname, tname, cname, method, rb_obj_classname(v));
}
return v;
@@ -2125,7 +2088,7 @@ rb_to_integer(val, method)
VALUE v = convert_type(val, "Integer", method, Qtrue);
if (!rb_obj_is_kind_of(v, rb_cInteger)) {
char *cname = rb_obj_classname(val);
- rb_raise(rb_eTypeError, "cannot convert %s to Integer (%s#%s gives %s)",
+ rb_raise(rb_eTypeError, "can't convert %s to Integer (%s#%s gives %s)",
cname, cname, method, rb_obj_classname(v));
}
return v;
@@ -2306,7 +2269,7 @@ rb_Float(val)
return rb_float_new(rb_str_to_dbl(val, Qtrue));
case T_NIL:
- rb_raise(rb_eTypeError, "cannot convert nil into Float");
+ rb_raise(rb_eTypeError, "can't convert nil into Float");
break;
default:
@@ -2561,10 +2524,8 @@ Init_Object()
rb_define_method(rb_mKernel, "eql?", rb_obj_equal, 1);
rb_define_method(rb_mKernel, "hash", rb_obj_id, 0);
- rb_define_method(rb_mKernel, "id", rb_obj_id_obsolete, 0);
rb_define_method(rb_mKernel, "__id__", rb_obj_id, 0);
rb_define_method(rb_mKernel, "object_id", rb_obj_id, 0);
- rb_define_method(rb_mKernel, "type", rb_obj_type, 0);
rb_define_method(rb_mKernel, "class", rb_obj_class, 0);
rb_define_method(rb_mKernel, "clone", rb_obj_clone, 0);
diff --git a/pack.c b/pack.c
index 4d927052d8..a5524bcca0 100644
--- a/pack.c
+++ b/pack.c
@@ -343,7 +343,7 @@ num2i32(x)
if (TYPE(x) == T_BIGNUM) {
return rb_big2ulong_pack(x);
}
- rb_raise(rb_eTypeError, "cannot convert %s to `integer'", rb_obj_classname(x));
+ rb_raise(rb_eTypeError, "can't convert %s to `integer'", rb_obj_classname(x));
return 0; /* not reached */
}
@@ -962,7 +962,7 @@ pack_pack(ary, fmt)
{
long l = NUM2LONG(from);
if (l < 0) {
- rb_raise(rb_eArgError, "cannot compress negative numbers");
+ rb_raise(rb_eArgError, "can't compress negative numbers");
}
ul = l;
}
diff --git a/parse.y b/parse.y
index ac1668f7e5..906589e958 100644
--- a/parse.y
+++ b/parse.y
@@ -48,6 +48,8 @@
((id)&ID_SCOPE_MASK) == ID_INSTANCE || \
((id)&ID_SCOPE_MASK) == ID_CLASS))
+static int is_valid_lvar _((ID id));
+
#ifndef RIPPER
char *ruby_sourcefile; /* current source file */
int ruby_sourceline; /* current line no. */
@@ -211,10 +213,10 @@ static NODE *cond_gen _((struct parser_params*,NODE*));
static NODE *logop_gen _((struct parser_params*,enum node_type,NODE*,NODE*));
#define logop(type,node1,node2) logop_gen(parser, type, node1, node2)
-static int cond_negative();
+static int cond_negative _((NODE**));
-static NODE *newline_node();
-static void fixpos();
+static NODE *newline_node _((NODE*));
+static void fixpos _((NODE*,NODE*));
static int value_expr_gen _((struct parser_params*,NODE*));
static void void_expr_gen _((struct parser_params*,NODE*));
@@ -225,25 +227,25 @@ static void void_stmts_gen _((struct parser_params*,NODE*));
#define void_stmts(node) void_stmts_gen(parser, node)
static void reduce_nodes _((NODE**));
-static NODE *block_append();
-static NODE *list_append();
-static NODE *list_concat();
-static NODE *arg_concat();
-static NODE *arg_prepend();
-static NODE *literal_concat();
-static NODE *new_evstr();
-static NODE *evstr2dstr();
+static NODE *block_append _((NODE*,NODE*));
+static NODE *list_append _((NODE*,NODE*));
+static NODE *list_concat _((NODE*,NODE*));
+static NODE *arg_concat _((NODE*,NODE*));
+static NODE *literal_concat _((NODE*,NODE*));
+static NODE *new_evstr _((NODE*));
+static NODE *evstr2dstr _((NODE*));
static NODE *call_op_gen _((struct parser_params*,NODE*,ID,int,NODE*));
#define call_op(recv,id,narg,arg1) call_op_gen(parser, recv,id,narg,arg1)
-static NODE *negate_lit();
-static NODE *ret_args();
-static NODE *arg_blk_pass();
-static NODE *new_call();
-static NODE *new_fcall();
-static NODE *new_super();
-static NODE *new_yield();
+static NODE *negate_lit _((NODE*));
+static NODE *ret_args _((NODE*));
+static NODE *arg_blk_pass _((NODE*,NODE*));
+static NODE *new_call _((NODE*,ID,NODE*));
+static NODE *new_fcall_gen _((struct parser_params*,ID,NODE*));
+#define new_fcall(id,args) new_fcall_gen(parser, id, args)
+static NODE *new_super _((NODE*));
+static NODE *new_yield _((NODE*));
static NODE *gettable_gen _((struct parser_params*,ID));
#define gettable(id) gettable_gen(parser,id)
@@ -254,7 +256,7 @@ static NODE *aryset_gen _((struct parser_params*,NODE*,NODE*));
static NODE *attrset_gen _((struct parser_params*,NODE*,ID));
#define attrset(node,id) attrset_gen(parser, node, id)
-static void rb_backref_error();
+static void rb_backref_error _((NODE*));
static NODE *node_assign_gen _((struct parser_params*,NODE*,NODE*));
#define node_assign(node1, node2) node_assign_gen(parser, node1, node2)
@@ -362,6 +364,7 @@ static VALUE ripper_id2sym _((ID));
#define method_optarg(m,a) ((a)==Qundef ? m : dispatch2(method_add_arg,m,a))
#define method_arg(m,a) dispatch2(method_add_arg,m,a)
#define escape_Qundef(x) ((x)==Qundef ? Qnil : (x))
+
#endif /* RIPPER */
#ifndef RIPPER
@@ -1110,7 +1113,7 @@ command : operation command_args %prec tLOWEST
$$ = new_fcall($1, $2);
fixpos($$, $2);
/*%
- $$ = dispatch2(command, $1, $2);
+ $$ = dispatch2(command, $1, $2);
%*/
}
| operation command_args cmd_brace_block
@@ -1126,7 +1129,7 @@ command : operation command_args %prec tLOWEST
}
fixpos($$, $2);
/*%
- $$ = dispatch2(command, $1, $2);
+ $$ = dispatch2(command, $1, $2);
$$ = dispatch2(iter_block, $$, $3);
%*/
}
@@ -2327,7 +2330,7 @@ open_args : call_args
| tLPAREN_ARG {lex_state = EXPR_ENDARG;} rparen
{
/*%%%*/
- rb_warn("don't put space before argument parentheses");
+ rb_warning("don't put space before argument parentheses");
$$ = 0;
/*%
$$ = dispatch1(space, dispatch1(arg_paren, arg_new()));
@@ -2336,7 +2339,7 @@ open_args : call_args
| tLPAREN_ARG call_args2 {lex_state = EXPR_ENDARG;} rparen
{
/*%%%*/
- rb_warn("don't put space before argument parentheses");
+ rb_warning("don't put space before argument parentheses");
$$ = $2;
/*%
$$ = dispatch1(space, dispatch1(arg_paren, $2));
@@ -3184,7 +3187,7 @@ method_call : operation paren_args
$$ = new_fcall($1, $2);
fixpos($$, $2);
/*%
- $$ = method_arg(dispatch1(fcall, $1), $2);
+ $$ = method_arg(dispatch1(fcall, $1), $2);
%*/
}
| primary_value '.' operation2 opt_paren_args
@@ -6048,7 +6051,6 @@ parser_yylex(parser)
return '~';
case '(':
- command_start = Qtrue;
if (IS_BEG()) {
c = tLPAREN;
}
@@ -6057,7 +6059,7 @@ parser_yylex(parser)
c = tLPAREN_ARG;
}
else if (lex_state == EXPR_ARG) {
- rb_warn0("don't put space before argument parentheses");
+ rb_warning0("don't put space before argument parentheses");
c = '(';
}
}
@@ -6829,11 +6831,6 @@ gettable_gen(parser, id)
if (dyna_in_block() && rb_dvar_defined(id)) return NEW_DVAR(id);
if (local_id(id)) return NEW_LVAR(id);
/* method call without arguments */
-#if 0
- /* Rite will warn this */
- rb_warn("ambiguous identifier; %s() or self.%s is better for method call",
- rb_id2name(id), rb_id2name(id));
-#endif
return NEW_VCALL(id);
}
else if (is_global_id(id)) {
@@ -7582,15 +7579,30 @@ new_call(r,m,a)
}
static NODE*
-new_fcall(m,a)
+fcall_gen(parser, m, a)
+ struct parser_params *parser;
+ ID m;
+ NODE *a;
+{
+ if (is_local_id(m)) {
+ if ((dyna_in_block() && rb_dvar_defined(m)) || local_id(m)) {
+ return NEW_CALL(gettable(m), rb_intern("call"), a);
+ }
+ }
+ return NEW_FCALL(m,a);
+}
+
+static NODE*
+new_fcall_gen(parser, m, a)
+ struct parser_params *parser;
ID m;
NODE *a;
{
if (a && nd_type(a) == NODE_BLOCK_PASS) {
- a->nd_iter = NEW_FCALL(m,a->nd_head);
+ a->nd_iter = fcall_gen(parser,m,a->nd_head);
return a;
}
- return NEW_FCALL(m,a);
+ return fcall_gen(parser, m,a);
}
static NODE*
@@ -8268,9 +8280,7 @@ rb_parser_s_new()
{
struct parser_params *p = parser_new();
- /* Object class is a dummy */
- return Data_Make_Struct(rb_cObject, struct parser_params,
- parser_mark, parser_free, p);
+ return Data_Wrap_Struct(0, parser_mark, parser_free, p);
}
#endif
diff --git a/process.c b/process.c
index cf3644c551..a77476cbc2 100644
--- a/process.c
+++ b/process.c
@@ -1671,13 +1671,13 @@ rb_f_spawn(argc, argv)
/*
* call-seq:
- * sleep(duration=0) => fixnum
+ * sleep([duration]) => fixnum
*
* Suspends the current thread for _duration_ seconds (which may be
* any number, including a +Float+ with fractional seconds). Returns the actual
* number of seconds slept (rounded), which may be less than that asked
* for if the thread was interrupted by a +SIGALRM+, or if
- * another thread calls <code>Thread#run</code>. An argument of zero
+ * another thread calls <code>Thread#run</code>. Zero arguments
* causes +sleep+ to sleep forever.
*
* Time.new #=> Wed Apr 09 08:56:32 CDT 2003
@@ -2046,7 +2046,7 @@ check_uid_switch()
{
rb_secure(2);
if (under_uid_switch) {
- rb_raise(rb_eRuntimeError, "can't handle UID during evaluating the block given to the Process::UID.switch method");
+ rb_raise(rb_eRuntimeError, "can't handle UID while evaluating block given to Process::UID.switch method");
}
}
@@ -2056,7 +2056,7 @@ check_gid_switch()
{
rb_secure(2);
if (under_gid_switch) {
- rb_raise(rb_eRuntimeError, "can't handle GID during evaluating the block given to the Process::UID.switch method");
+ rb_raise(rb_eRuntimeError, "can't handle GID while evaluating block given to Process::UID.switch method");
}
}
diff --git a/range.c b/range.c
index d5faa00699..f1ff5a74bb 100644
--- a/range.c
+++ b/range.c
@@ -352,7 +352,7 @@ range_step(argc, argv, range)
if (unit == 0) rb_raise(rb_eArgError, "step can't be 0");
if (!rb_respond_to(b, id_succ)) {
- rb_raise(rb_eTypeError, "cannot iterate from %s",
+ rb_raise(rb_eTypeError, "can't iterate from %s",
rb_obj_classname(b));
}
@@ -400,7 +400,7 @@ range_each(range)
end = rb_ivar_get(range, id_end);
if (!rb_respond_to(beg, id_succ)) {
- rb_raise(rb_eTypeError, "cannot iterate from %s",
+ rb_raise(rb_eTypeError, "can't iterate from %s",
rb_obj_classname(beg));
}
if (FIXNUM_P(beg) && FIXNUM_P(end)) { /* fixnums are special */
diff --git a/regint.h b/regint.h
index a704b0e263..2bd514b7c3 100644
--- a/regint.h
+++ b/regint.h
@@ -73,7 +73,7 @@
#define DEFAULT_MATCH_STACK_LIMIT_SIZE 0 /* unlimited */
/* interface to external system */
-#ifdef NOT_RUBY /* gived from Makefile */
+#ifdef NOT_RUBY /* given from Makefile */
#include "config.h"
#define USE_CAPTURE_HISTORY
#define USE_VARIABLE_META_CHARS
diff --git a/regparse.c b/regparse.c
index 58e122f486..04a0ccea5b 100644
--- a/regparse.c
+++ b/regparse.c
@@ -305,6 +305,88 @@ typedef struct {
#include "st.h"
+typedef struct {
+ unsigned char* s;
+ unsigned char* end;
+} st_strend_key;
+
+static int strend_cmp(st_strend_key*, st_strend_key*);
+static int strend_hash(st_strend_key*);
+
+static struct st_hash_type type_strend_hash = {
+ strend_cmp,
+ strend_hash,
+};
+
+static st_table*
+onig_st_init_strend_table_with_size(int size)
+{
+ return onig_st_init_table_with_size(&type_strend_hash, size);
+}
+
+static int
+onig_st_lookup_strend(st_table *table, const UChar* str_key, const UChar* end_key, st_data_t *value)
+{
+ st_strend_key key;
+
+ key.s = (unsigned char* )str_key;
+ key.end = (unsigned char* )end_key;
+
+ return onig_st_lookup(table, (st_data_t )(&key), value);
+}
+
+static int
+onig_st_insert_strend(st_table *table, const UChar* str_key, const UChar* end_key, st_data_t value)
+{
+ st_strend_key* key;
+ int result;
+
+ key = (st_strend_key* )xmalloc(sizeof(st_strend_key));
+ key->s = (unsigned char* )str_key;
+ key->end = (unsigned char* )end_key;
+ result = onig_st_insert(table, (st_data_t )key, value);
+ if (result) {
+ xfree(key);
+ }
+ return result;
+}
+
+static int
+strend_cmp(st_strend_key* x, st_strend_key* y)
+{
+ unsigned char *p, *q;
+ int c;
+
+ if ((x->end - x->s) != (y->end - y->s))
+ return 1;
+
+ p = x->s;
+ q = y->s;
+ while (p < x->end) {
+ c = (int )*p - (int )*q;
+ if (c != 0) return c;
+
+ p++; q++;
+ }
+
+ return 0;
+}
+
+static int
+strend_hash(st_strend_key* x)
+{
+ int val;
+ unsigned char *p;
+
+ val = 0;
+ p = x->s;
+ while (p < x->end) {
+ val = val * 997 + (int )*p++;
+ }
+
+ return val + (val >> 5);
+}
+
typedef st_table NameTable;
typedef st_data_t HashDataType; /* 1.6 st.h doesn't define st_data_t type */
@@ -350,8 +432,10 @@ onig_print_names(FILE* fp, regex_t* reg)
static int
i_free_name_entry(UChar* key, NameEntry* e, void* arg)
{
- xfree(e->name); /* == key */
+ xfree(e->name);
if (IS_NOT_NULL(e->back_refs)) xfree(e->back_refs);
+ xfree(key);
+ xfree(e);
return ST_DELETE;
}
@@ -4546,27 +4630,9 @@ static int type_cclass_hash(type_cclass_key* key)
return val + (val >> 5);
}
-static int type_cclass_key_free(st_data_t x)
-{
- xfree((void* )x);
- return 0;
-}
-
-static st_data_t type_cclass_key_clone(st_data_t x)
-{
- type_cclass_key* new_key;
- type_cclass_key* key = (type_cclass_key* )x;
-
- new_key = (type_cclass_key* )xmalloc(sizeof(type_cclass_key));
- *new_key = *key;
- return (st_data_t )new_key;
-}
-
static struct st_hash_type type_type_cclass_hash = {
type_cclass_cmp,
type_cclass_hash,
- type_cclass_key_free,
- type_cclass_key_clone
};
static st_table* OnigTypeCClassTable;
diff --git a/ruby.c b/ruby.c
index 48b8dba24f..7f4ace7312 100644
--- a/ruby.c
+++ b/ruby.c
@@ -731,7 +731,7 @@ proc_options(argc, argv)
}
if (!*s) break;
if (!strchr("IdvwrK", *s))
- rb_raise(rb_eRuntimeError, "Illegal switch in RUBYOPT: -%c", *s);
+ rb_raise(rb_eRuntimeError, "illegal switch in RUBYOPT: -%c", *s);
s = moreswitches(s);
}
}
@@ -858,7 +858,7 @@ load_file(fname, script)
}
}
}
- rb_raise(rb_eLoadError, "No Ruby script found in input");
+ rb_raise(rb_eLoadError, "no Ruby script found in input");
}
c = rb_io_getc(f);
@@ -1047,11 +1047,11 @@ forbid_setid(s)
const char *s;
{
if (euid != uid)
- rb_raise(rb_eSecurityError, "No %s allowed while running setuid", s);
+ rb_raise(rb_eSecurityError, "no %s allowed while running setuid", s);
if (egid != gid)
- rb_raise(rb_eSecurityError, "No %s allowed while running setgid", s);
+ rb_raise(rb_eSecurityError, "no %s allowed while running setgid", s);
if (rb_safe_level() > 0)
- rb_raise(rb_eSecurityError, "No %s allowed in tainted mode", s);
+ rb_raise(rb_eSecurityError, "no %s allowed in tainted mode", s);
}
static void
diff --git a/sample/test.rb b/sample/test.rb
index 37afe6e7b8..54ac3623b1 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -832,10 +832,10 @@ test_ok($x.has_value?(4))
test_ok($x.values_at(2,3) == [4,6])
test_ok($x == {1=>2, 2=>4, 3=>6})
-$z = $y.keys.join(":")
+$z = $y.keys.sort.join(":")
test_ok($z == "1:2:3")
-$z = $y.values.join(":")
+$z = $y.values.sort.join(":")
test_ok($z == "2:4:6")
test_ok($x == $y)
@@ -1115,17 +1115,17 @@ argument_test(false, get_block(&lambda{||}),1)
argument_test(true, get_block(&lambda{|a,|}),1)
argument_test(false, get_block(&lambda{|a,|}),1,2)
-block = get_block{11}
-test_ok(block.class == Proc)
-test_ok(block.to_proc.class == Proc)
-test_ok(block.clone.call == 11)
-test_ok(get_block(&block).class == Proc)
+blk = get_block{11}
+test_ok(blk.class == Proc)
+test_ok(blk.to_proc.class == Proc)
+test_ok(blk.clone.call == 11)
+test_ok(get_block(&blk).class == Proc)
-lambda = lambda{44}
-test_ok(lambda.class == Proc)
-test_ok(lambda.to_proc.class == Proc)
-test_ok(lambda.clone.call == 44)
-test_ok(get_block(&lambda).class == Proc)
+lmd = lambda{44}
+test_ok(lmd.class == Proc)
+test_ok(lmd.to_proc.class == Proc)
+test_ok(lmd.clone.call == 44)
+test_ok(get_block(&lmd).class == Proc)
test_ok(Proc.new{|a,| a}.call(1,2,3) == 1)
argument_test(true, Proc.new{|a,|}, 1,2)
@@ -1325,7 +1325,7 @@ end
test_ok(test_b15{|e| break 155 } == 155)
def marity_test(m)
- method = method(m)
+ method = self.method(m)
test_ok(method.arity == method.to_proc.arity, 2)
end
marity_test(:test_ok)
diff --git a/signal.c b/signal.c
index 6bcc723d82..c75ad83e64 100644
--- a/signal.c
+++ b/signal.c
@@ -674,7 +674,7 @@ trap(arg)
}
#if defined(HAVE_SETITIMER)
if (sig == SIGVTALRM) {
- rb_raise(rb_eArgError, "SIGVTALRM reserved for Thread; cannot set handler");
+ rb_raise(rb_eArgError, "SIGVTALRM reserved for Thread; can't set handler");
}
#endif
if (func == SIG_DFL) {
diff --git a/sprintf.c b/sprintf.c
index 97c392816b..0b7dd28385 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -107,7 +107,7 @@ sign_bits(base, p)
(posarg = -1, GETNTHARG(n))))
#define GETNTHARG(nth) \
- ((nth >= argc) ? (rb_raise(rb_eArgError, "too few arguments."), 0) : argv[nth])
+ ((nth >= argc) ? (rb_raise(rb_eArgError, "too few arguments"), 0) : argv[nth])
#define GETASTER(val) do { \
t = p++; \
diff --git a/st.c b/st.c
index 65c2cc58bd..df4eb7e3ed 100644
--- a/st.c
+++ b/st.c
@@ -56,8 +56,6 @@ static int numhash(long);
static struct st_hash_type type_numhash = {
numcmp,
numhash,
- st_nothing_key_free,
- st_nothing_key_clone
};
/* extern int strcmp(const char *, const char *); */
@@ -65,20 +63,6 @@ static int strhash(const char *);
static struct st_hash_type type_strhash = {
strcmp,
strhash,
- st_nothing_key_free,
- st_nothing_key_clone
-};
-
-static int strend_cmp(st_strend_key*, st_strend_key*);
-static int strend_hash(st_strend_key*);
-static int strend_key_free(st_data_t key);
-static st_data_t strend_key_clone(st_data_t x);
-
-static struct st_hash_type type_strend_hash = {
- strend_cmp,
- strend_hash,
- strend_key_free,
- strend_key_clone
};
static void rehash(st_table *);
@@ -228,13 +212,6 @@ st_init_strtable_with_size(size)
return st_init_table_with_size(&type_strhash, size);
}
-st_table*
-st_init_strend_table_with_size(size)
- int size;
-{
- return st_init_table_with_size(&type_strend_hash, size);
-}
-
void
st_free_table(table)
st_table *table;
@@ -246,7 +223,6 @@ st_free_table(table)
ptr = table->bins[i];
while (ptr != 0) {
next = ptr->next;
- table->type->key_free(ptr->key);
free(ptr);
ptr = next;
}
@@ -297,21 +273,6 @@ st_lookup(table, key, value)
}
}
-int
-st_lookup_strend(table, str_key, end_key, value)
- st_table *table;
- const unsigned char* str_key;
- const unsigned char* end_key;
- st_data_t *value;
-{
- st_strend_key key;
-
- key.s = (unsigned char* )str_key;
- key.end = (unsigned char* )end_key;
-
- return st_lookup(table, (st_data_t )(&key), value);
-}
-
#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
do {\
st_table_entry *entry;\
@@ -352,22 +313,6 @@ st_insert(table, key, value)
}
}
-int
-st_insert_strend(table, str_key, end_key, value)
- st_table *table;
- const unsigned char* str_key;
- const unsigned char* end_key;
- st_data_t value;
-{
- st_strend_key* key;
-
- key = alloc(st_strend_key);
- key->s = (unsigned char* )str_key;
- key->end = (unsigned char* )end_key;
-
- return st_insert(table, (st_data_t )key, value);
-}
-
void
st_add_direct(table, key, value)
st_table *table;
@@ -381,21 +326,6 @@ st_add_direct(table, key, value)
ADD_DIRECT(table, key, value, hash_val, bin_pos);
}
-void
-st_add_direct_strend(table, str_key, end_key, value)
- st_table *table;
- const unsigned char* str_key;
- const unsigned char* end_key;
- st_data_t value;
-{
- st_strend_key* key;
-
- key = alloc(st_strend_key);
- key->s = (unsigned char* )str_key;
- key->end = (unsigned char* )end_key;
- st_add_direct(table, (st_data_t )key, value);
-}
-
static void
rehash(table)
register st_table *table;
@@ -455,7 +385,6 @@ st_copy(old_table)
return 0;
}
*entry = *ptr;
- entry->key = old_table->type->key_clone(ptr->key);
entry->next = new_table->bins[i];
new_table->bins[i] = entry;
ptr = ptr->next;
@@ -556,7 +485,7 @@ st_cleanup_safe(table, never)
table->num_entries = num_entries;
}
-void
+int
st_foreach(table, func, arg)
st_table *table;
int (*func)();
@@ -569,7 +498,7 @@ st_foreach(table, func, arg)
for(i = 0; i < table->num_bins; i++) {
last = 0;
for(ptr = table->bins[i]; ptr != 0;) {
- retval = (*func)(ptr->key, ptr->record, arg, 0);
+ retval = (*func)(ptr->key, ptr->record, arg);
switch (retval) {
case ST_CHECK: /* check if hash is modified during iteration */
tmp = 0;
@@ -580,8 +509,7 @@ st_foreach(table, func, arg)
}
if (!tmp) {
/* call func with error notice */
- retval = (*func)(0, 0, arg, 1);
- return;
+ return 1;
}
/* fall through */
case ST_CONTINUE:
@@ -589,7 +517,7 @@ st_foreach(table, func, arg)
ptr = ptr->next;
break;
case ST_STOP:
- return;
+ return 0;
case ST_DELETE:
tmp = ptr;
if (last == 0) {
@@ -599,12 +527,12 @@ st_foreach(table, func, arg)
last->next = ptr->next;
}
ptr = ptr->next;
- table->type->key_free(tmp->key);
free(tmp);
table->num_entries--;
}
}
}
+ return 0;
}
static int
@@ -659,59 +587,3 @@ numhash(n)
{
return n;
}
-
-extern int
-st_nothing_key_free(st_data_t key) { return 0; }
-
-extern st_data_t
-st_nothing_key_clone(st_data_t x) { return x; }
-
-static int strend_cmp(st_strend_key* x, st_strend_key* y)
-{
- unsigned char *p, *q;
- int c;
-
- if ((x->end - x->s) != (y->end - y->s))
- return 1;
-
- p = x->s;
- q = y->s;
- while (p < x->end) {
- c = (int )*p - (int )*q;
- if (c != 0) return c;
-
- p++; q++;
- }
-
- return 0;
-}
-
-static int strend_hash(st_strend_key* x)
-{
- int val;
- unsigned char *p;
-
- val = 0;
- p = x->s;
- while (p < x->end) {
- val = val * 997 + (int )*p++;
- }
-
- return val + (val >> 5);
-}
-
-static int strend_key_free(st_data_t x)
-{
- xfree((void* )x);
- return 0;
-}
-
-static st_data_t strend_key_clone(st_data_t x)
-{
- st_strend_key* new_key;
- st_strend_key* key = (st_strend_key* )x;
-
- new_key = alloc(st_strend_key);
- *new_key = *key;
- return (st_data_t )new_key;
-}
diff --git a/st.h b/st.h
index c5cc4e625e..da65e7fef8 100644
--- a/st.h
+++ b/st.h
@@ -14,8 +14,6 @@ typedef struct st_table st_table;
struct st_hash_type {
int (*compare)();
int (*hash)();
- int (*key_free)();
- st_data_t (*key_clone)();
};
struct st_table {
@@ -25,11 +23,6 @@ struct st_table {
struct st_table_entry **bins;
};
-typedef struct {
- unsigned char* s;
- unsigned char* end;
-} st_strend_key;
-
#define st_is_member(table,key) st_lookup(table,key,(st_data_t *)0)
enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
@@ -51,23 +44,16 @@ st_table *st_init_numtable _((void));
st_table *st_init_numtable_with_size _((int));
st_table *st_init_strtable _((void));
st_table *st_init_strtable_with_size _((int));
-st_table *st_init_strend_table_with_size _((int));
int st_delete _((st_table *, st_data_t *, st_data_t *));
int st_delete_safe _((st_table *, st_data_t *, st_data_t *, st_data_t));
int st_insert _((st_table *, st_data_t, st_data_t));
-int st_insert_strend _((st_table *, const unsigned char*, const unsigned char*, st_data_t));
int st_lookup _((st_table *, st_data_t, st_data_t *));
-int st_lookup_strend _((st_table *, const unsigned char*, const unsigned char*, st_data_t*));
-void st_foreach _((st_table *, int (*)(ANYARGS), st_data_t));
+int st_foreach _((st_table *, int (*)(ANYARGS), st_data_t));
void st_add_direct _((st_table *, st_data_t, st_data_t));
-void st_add_direct_strend _((st_table *, const unsigned char*, const unsigned char*, st_data_t));
void st_free_table _((st_table *));
void st_cleanup_safe _((st_table *, st_data_t));
st_table *st_copy _((st_table *));
-extern st_data_t st_nothing_key_clone _((st_data_t key));
-extern int st_nothing_key_free _((st_data_t key));
-
#define ST_NUMCMP ((int (*)()) 0)
#define ST_NUMHASH ((int (*)()) -2)
diff --git a/string.c b/string.c
index 73742cc38f..51147f36ec 100644
--- a/string.c
+++ b/string.c
@@ -201,6 +201,7 @@ rb_str_new4(orig)
else {
str = str_new4(klass, orig);
}
+ OBJ_INFECT(str, orig);
OBJ_FREEZE(str);
return str;
}
@@ -1323,7 +1324,7 @@ rb_str_match_m(argc, argv, str)
{
VALUE re;
if (argc < 1)
- rb_raise(rb_eArgError, "wrong number of arguments(%d for 1)", argc);
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
re = argv[0];
argv[0] = str;
return rb_funcall2(get_pat(re, 0), rb_intern("match"), argc, argv);
@@ -4378,7 +4379,7 @@ rb_str_crypt(str, salt)
StringValue(salt);
if (RSTRING(salt)->len < 2)
- rb_raise(rb_eArgError, "salt too short(need >=2 bytes)");
+ rb_raise(rb_eArgError, "salt too short (need >=2 bytes)");
if (RSTRING(str)->ptr) s = RSTRING(str)->ptr;
else s = "";
@@ -4504,7 +4505,6 @@ rb_str_justify(argc, argv, str, jflag)
rb_scan_args(argc, argv, "11", &w, &pad);
width = NUM2LONG(w);
- if (width < 0 || RSTRING(str)->len >= width) return rb_str_dup(str);
if (argc == 2) {
StringValue(pad);
f = RSTRING(pad)->ptr;
@@ -4513,6 +4513,7 @@ rb_str_justify(argc, argv, str, jflag)
rb_raise(rb_eArgError, "zero width padding");
}
}
+ if (width < 0 || RSTRING(str)->len >= width) return rb_str_dup(str);
res = rb_str_new5(str, 0, width);
p = RSTRING(res)->ptr;
if (jflag != 'l') {
@@ -4560,14 +4561,15 @@ rb_str_justify(argc, argv, str, jflag)
/*
* call-seq:
- * str.ljust(integer) => new_str
+ * str.ljust(integer, padstr=' ') => new_str
*
* If <i>integer</i> is greater than the length of <i>str</i>, returns a new
* <code>String</code> of length <i>integer</i> with <i>str</i> left justified
- * and space padded; otherwise, returns <i>str</i>.
+ * and padded with <i>padstr</i>; otherwise, returns <i>str</i>.
*
- * "hello".ljust(4) #=> "hello"
- * "hello".ljust(20) #=> "hello "
+ * "hello".ljust(4) #=> "hello"
+ * "hello".ljust(20) #=> "hello "
+ * "hello".ljust(20, '1234') #=> "hello123412341234123"
*/
static VALUE
@@ -4582,14 +4584,15 @@ rb_str_ljust(argc, argv, str)
/*
* call-seq:
- * str.rjust(integer) => new_str
+ * str.rjust(integer, padstr=' ') => new_str
*
* If <i>integer</i> is greater than the length of <i>str</i>, returns a new
* <code>String</code> of length <i>integer</i> with <i>str</i> right justified
- * and space padded; otherwise, returns <i>str</i>.
+ * and padded with <i>padstr</i>; otherwise, returns <i>str</i>.
*
- * "hello".rjust(4) #=> "hello"
- * "hello".rjust(20) #=> " hello"
+ * "hello".rjust(4) #=> "hello"
+ * "hello".rjust(20) #=> " hello"
+ * "hello".rjust(20, '1234') #=> "123412341234123hello"
*/
static VALUE
@@ -4604,14 +4607,15 @@ rb_str_rjust(argc, argv, str)
/*
* call-seq:
- * str.center(integer) => new_str
+ * str.center(integer, padstr) => new_str
*
* If <i>integer</i> is greater than the length of <i>str</i>, returns a new
- * <code>String</code> of length <i>integer</i> with <i>str</i> centered
- * between spaces; otherwise, returns <i>str</i>.
+ * <code>String</code> of length <i>integer</i> with <i>str</i> centered and
+ * padded with <i>padstr</i>; otherwise, returns <i>str</i>.
*
- * "hello".center(4) #=> "hello"
- * "hello".center(20) #=> " hello "
+ * "hello".center(4) #=> "hello"
+ * "hello".center(20) #=> " hello "
+ * "hello".center(20, '123') #=> "1231231hello12312312"
*/
static VALUE
diff --git a/struct.c b/struct.c
index 65f4eb7863..497de270ee 100644
--- a/struct.c
+++ b/struct.c
@@ -118,7 +118,7 @@ static VALUE
rb_struct_ref(obj)
VALUE obj;
{
- return rb_struct_getmember(obj, rb_frame_last_func());
+ return rb_struct_getmember(obj, rb_frame_this_func());
}
static VALUE rb_struct_ref0(obj) VALUE obj; {return RSTRUCT(obj)->ptr[0];}
@@ -165,12 +165,12 @@ rb_struct_set(obj, val)
rb_struct_modify(obj);
for (i=0; i<RARRAY(members)->len; i++) {
slot = RARRAY(members)->ptr[i];
- if (rb_id_attrset(SYM2ID(slot)) == rb_frame_last_func()) {
+ if (rb_id_attrset(SYM2ID(slot)) == rb_frame_this_func()) {
return RSTRUCT(obj)->ptr[i] = val;
}
}
- rb_name_error(rb_frame_last_func(), "`%s' is not a struct member",
- rb_id2name(rb_frame_last_func()));
+ rb_name_error(rb_frame_this_func(), "`%s' is not a struct member",
+ rb_id2name(rb_frame_this_func()));
return Qnil; /* not reached */
}
@@ -190,6 +190,7 @@ make_struct(name, members, klass)
}
else {
char *cname = StringValuePtr(name);
+
id = rb_intern(cname);
if (!rb_is_const_id(id)) {
rb_name_error(id, "identifier %s needs to be constant", cname);
@@ -198,7 +199,7 @@ make_struct(name, members, klass)
rb_warn("redefining constant Struct::%s", cname);
rb_mod_remove_const(klass, ID2SYM(id));
}
- nstr = rb_define_class_under(klass, cname, klass);
+ nstr = rb_define_class_under(klass, rb_id2name(id), klass);
}
rb_iv_set(nstr, "__size__", LONG2NUM(RARRAY(members)->len));
rb_iv_set(nstr, "__members__", members);
@@ -209,7 +210,11 @@ make_struct(name, members, klass)
rb_define_singleton_method(nstr, "members", rb_struct_s_members_m, 0);
for (i=0; i< RARRAY(members)->len; i++) {
ID id = SYM2ID(RARRAY(members)->ptr[i]);
- if (i<10) {
+ if (!rb_is_local_id(id)) {
+ rb_raise(rb_eNameError, "`%s' is not proper name for a struct member",
+ rb_id2name(id));
+ }
+ if (i<sizeof(ref_func)) {
rb_define_method_id(nstr, id, ref_func[i], 0);
}
else {
@@ -462,13 +467,23 @@ rb_struct_each_pair(s)
}
static VALUE
-inspect_struct(s)
- VALUE s;
+inspect_struct(s, dummy, recur)
+ VALUE s, dummy;
+ int recur;
{
char *cname = rb_class2name(rb_obj_class(s));
VALUE str, members;
long i;
+ if (recur) {
+ char *cname = rb_class2name(rb_obj_class(s));
+ VALUE str = rb_str_new(0, strlen(cname) + 15);
+
+ sprintf(RSTRING(str)->ptr, "#<struct %s:...>", cname);
+ RSTRING(str)->len = strlen(RSTRING(str)->ptr);
+ return str;
+ }
+
members = rb_struct_members(s);
str = rb_str_buf_new2("#<struct ");
rb_str_cat2(str, cname);
@@ -505,15 +520,7 @@ static VALUE
rb_struct_inspect(s)
VALUE s;
{
- if (rb_inspecting_p(s)) {
- char *cname = rb_class2name(rb_obj_class(s));
- VALUE str = rb_str_new(0, strlen(cname) + 15);
-
- sprintf(RSTRING(str)->ptr, "#<struct %s:...>", cname);
- RSTRING(str)->len = strlen(RSTRING(str)->ptr);
- return str;
- }
- return rb_protect_inspect(inspect_struct, s, 0);
+ return rb_exec_recursive(inspect_struct, s, 0);
}
/*
diff --git a/test/logger/test_logger.rb b/test/logger/test_logger.rb
index c953a89d9c..b86b9cf372 100644
--- a/test/logger/test_logger.rb
+++ b/test/logger/test_logger.rb
@@ -32,10 +32,10 @@ class TestLogger < Test::Unit::TestCase
end
def log_add(logger, severity, msg, progname = nil, &block)
- log(logger, :add, severity, msg, progname, &block)
+ do_log(logger, :add, severity, msg, progname, &block)
end
- def log(logger, msg_id, *arg, &block)
+ def do_log(logger, msg_id, *arg, &block)
logdev = Tempfile.new(File.basename(__FILE__) + '.log')
logger.instance_eval { @logdev = Logger::LogDevice.new(logdev) }
logger.__send__(msg_id, *arg, &block)
@@ -134,44 +134,44 @@ class TestLogger < Test::Unit::TestCase
def test_level_log
logger = Logger.new(nil)
logger.progname = "my_progname"
- log = log(logger, :debug, "custom_progname") { "msg" }
+ log = do_log(logger, :debug, "custom_progname") { "msg" }
assert_equal("msg\n", log.msg)
assert_equal("custom_progname", log.progname)
assert_equal("DEBUG", log.severity)
assert_equal("D", log.label)
#
- log = log(logger, :debug) { "msg_block" }
+ log = do_log(logger, :debug) { "msg_block" }
assert_equal("msg_block\n", log.msg)
assert_equal("my_progname", log.progname)
- log = log(logger, :debug, "msg_inline")
+ log = do_log(logger, :debug, "msg_inline")
assert_equal("msg_inline\n", log.msg)
assert_equal("my_progname", log.progname)
#
- log = log(logger, :info, "custom_progname") { "msg" }
+ log = do_log(logger, :info, "custom_progname") { "msg" }
assert_equal("msg\n", log.msg)
assert_equal("custom_progname", log.progname)
assert_equal("INFO", log.severity)
assert_equal("I", log.label)
#
- log = log(logger, :warn, "custom_progname") { "msg" }
+ log = do_log(logger, :warn, "custom_progname") { "msg" }
assert_equal("msg\n", log.msg)
assert_equal("custom_progname", log.progname)
assert_equal("WARN", log.severity)
assert_equal("W", log.label)
#
- log = log(logger, :error, "custom_progname") { "msg" }
+ log = do_log(logger, :error, "custom_progname") { "msg" }
assert_equal("msg\n", log.msg)
assert_equal("custom_progname", log.progname)
assert_equal("ERROR", log.severity)
assert_equal("E", log.label)
#
- log = log(logger, :fatal, "custom_progname") { "msg" }
+ log = do_log(logger, :fatal, "custom_progname") { "msg" }
assert_equal("msg\n", log.msg)
assert_equal("custom_progname", log.progname)
assert_equal("FATAL", log.severity)
assert_equal("F", log.label)
#
- log = log(logger, :unknown, "custom_progname") { "msg" }
+ log = do_log(logger, :unknown, "custom_progname") { "msg" }
assert_equal("msg\n", log.msg)
assert_equal("custom_progname", log.progname)
assert_equal("ANY", log.severity)
diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb
index 1c293069c4..cf9a6fdb34 100644
--- a/test/ruby/test_iterator.rb
+++ b/test/ruby/test_iterator.rb
@@ -245,11 +245,11 @@ class TestIterator < Test::Unit::TestCase
assert_equal(block.clone.call, 11)
assert_instance_of(Proc, get_block(&block))
- lambda = lambda{44}
- assert_instance_of(Proc, lambda)
- assert_instance_of(Proc, lambda.to_proc)
- assert_equal(lambda.clone.call, 44)
- assert_instance_of(Proc, get_block(&lambda))
+ lmd = lambda{44}
+ assert_instance_of(Proc, lmd)
+ assert_instance_of(Proc, lmd.to_proc)
+ assert_equal(lmd.clone.call, 44)
+ assert_instance_of(Proc, get_block(&lmd))
assert_equal(1, Proc.new{|a,| a}.call(1,2,3))
assert_nothing_raised {Proc.new{|a,|}.call(1,2)}
@@ -310,9 +310,9 @@ class TestIterator < Test::Unit::TestCase
end
block = get_block{11}
- lambda = lambda{44}
+ lmd = lambda{44}
assert_equal(0, block.arity)
- assert_equal(0, lambda.arity)
+ assert_equal(0, lmd.arity)
assert_equal(0, lambda{||}.arity)
assert_equal(1, lambda{|a|}.arity)
assert_equal(1, lambda{|a,|}.arity)
@@ -320,8 +320,8 @@ class TestIterator < Test::Unit::TestCase
end
def marity_test(m)
- method = method(m)
- assert_equal(method.arity, method.to_proc.arity)
+ mobj = method(m)
+ assert_equal(mobj.arity, mobj.to_proc.arity)
end
def test_marity
diff --git a/time.c b/time.c
index 47e3be1e17..eaf8f5acc0 100644
--- a/time.c
+++ b/time.c
@@ -1834,6 +1834,7 @@ time_strftime(time, format)
time_get_tm(time, tobj->gmt);
}
StringValue(format);
+ format = rb_str_new4(format);
fmt = RSTRING(format)->ptr;
len = RSTRING(format)->len;
if (len == 0) {
diff --git a/variable.c b/variable.c
index fb3e3cc4e7..b3824c30a2 100644
--- a/variable.c
+++ b/variable.c
@@ -1292,8 +1292,7 @@ rb_autoload(mod, id, file)
tbl = check_autoload_table(av);
}
else {
- av = Data_Wrap_Struct(rb_cData, rb_mark_tbl, st_free_table, 0);
- RBASIC(av)->klass = 0;
+ av = Data_Wrap_Struct(0, rb_mark_tbl, st_free_table, 0);
st_add_direct(tbl, autoload, av);
DATA_PTR(av) = tbl = st_init_numtable();
}