* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,

pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
  thread_pthread.ci, thread_win32.ci: fixed indentation.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-06-05 04:25:10 +00:00
parent f3dfa40734
commit 99d65b14b4
17 changed files with 2201 additions and 2170 deletions

View File

@ -1,3 +1,15 @@
Tue Jun 5 13:26:36 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
Tue Jun 5 13:17:11 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* call_cfunc.ci, compile.c, dir.c, eval.c, eval_jump.h, numeric.c,
pack.c, re.c, thread.c, thread_win32.ci, vm.c, vm_dump.c: fixed
indentation.
Mon Jun 04 21:15:45 2007 NARUSE, Yui <naruse@ruby-lang.org> Mon Jun 04 21:15:45 2007 NARUSE, Yui <naruse@ruby-lang.org>
* lib/json.rb, lib/json, ext/json, test/json: * lib/json.rb, lib/json, ext/json, test/json:
@ -965,8 +977,8 @@ Wed Mar 21 17:04:30 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
Tue Mar 21 08:20:00 2007 Nathaniel Talbott <ntalbott@ruby-lang.org> Tue Mar 21 08:20:00 2007 Nathaniel Talbott <ntalbott@ruby-lang.org>
* test/testunit/collector/test_dir.rb: Fixed test/unit tests that * test/testunit/collector/test_dir.rb: Fixed test/unit tests that
were breaking due to Module#public_instance_methods now were breaking due to Module#public_instance_methods now
returning a Symbol instead of a String. returning a Symbol instead of a String.
* test/testunit/collector/test_objectspace.rb: Ditto. * test/testunit/collector/test_objectspace.rb: Ditto.
@ -1256,14 +1268,14 @@ Fri Mar 2 21:17:14 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (get_ptr_of_variant, ole_set_safe_array, * ext/win32ole/win32ole.c (get_ptr_of_variant, ole_set_safe_array,
ole_val2ptr_variant, ole_val2olevariantdata, ole_variant2val, ole_val2ptr_variant, ole_val2olevariantdata, ole_variant2val,
): fix some bugs of WIN32OLE_VARIANT.new when variant type is ): fix some bugs of WIN32OLE_VARIANT.new when variant type is
VT_ARRAY|VT_BSTR or VT_BYREF. VT_ARRAY|VT_BSTR or VT_BYREF.
* ext/win32ole/win32ole.c (folevariant_s_array, folevariant_initialize): * ext/win32ole/win32ole.c (folevariant_s_array, folevariant_initialize):
WIN32OLE_VARIANT#[], WIN32OLE_VARIANT#[]=, WIN32OLE_VARIANT#value= WIN32OLE_VARIANT#[], WIN32OLE_VARIANT#[]=, WIN32OLE_VARIANT#value=
is defined as instance method of WIN32OLE_VARIANT. is defined as instance method of WIN32OLE_VARIANT.
* test/win32ole/test_win32ole_variant.rb: add some test for * test/win32ole/test_win32ole_variant.rb: add some test for
VT_ARRAY, VT_BYREF variant type. VT_ARRAY, VT_BYREF variant type.
Fri Mar 2 07:58:24 2007 Yukihiro Matsumoto <matz@ruby-lang.org> Fri Mar 2 07:58:24 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
@ -1642,7 +1654,7 @@ Sat Feb 24 10:38:05 2007 Minero Aoki <aamine@loveruby.net>
Sat Feb 24 07:31:35 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp> Sat Feb 24 07:31:35 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c: add WIN32OLE_VARIANT.array, * ext/win32ole/win32ole.c: add WIN32OLE_VARIANT.array,
WIN32OLE_VARIANT#value=, refactoring. WIN32OLE_VARIANT#value=, refactoring.
* test/win32ole/test_win32ole_variant.rb: add some test for * test/win32ole/test_win32ole_variant.rb: add some test for
@ -1757,7 +1769,7 @@ Wed Feb 21 09:14:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
Tue Feb 20 21:19:29 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp> Tue Feb 20 21:19:29 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (installed_code_page_proc, * ext/win32ole/win32ole.c (installed_code_page_proc,
ole_variant2val): small refactoring. ole_variant2val): small refactoring.
Tue Feb 20 15:11:42 2007 Koichi Sasada <ko1@atdot.net> Tue Feb 20 15:11:42 2007 Koichi Sasada <ko1@atdot.net>
@ -1822,7 +1834,7 @@ Fri Feb 16 20:59:10 2007 Koichi Sasada <ko1@atdot.net>
Fri Feb 16 19:24:22 2007 Yukihiro Matsumoto <matz@ruby-lang.org> Fri Feb 16 19:24:22 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* math.c (math_log): update document to mention second optional * math.c (math_log): update document to mention second optional
argument for logarithm base. argument for logarithm base.
Fri Feb 16 19:19:21 2007 Yukihiro Matsumoto <matz@ruby-lang.org> Fri Feb 16 19:19:21 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
@ -1872,7 +1884,7 @@ Thu Feb 15 01:43:45 2007 Koichi Sasada <ko1@atdot.net>
Wed Feb 14 22:52:43 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp> Wed Feb 14 22:52:43 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_variant2val): VC++6 does not * ext/win32ole/win32ole.c (ole_variant2val): VC++6 does not
support VT_I8, VT_UI8. support VT_I8, VT_UI8.
Wed Feb 14 22:10:21 2007 Koichi Sasada <ko1@atdot.net> Wed Feb 14 22:10:21 2007 Koichi Sasada <ko1@atdot.net>
@ -1998,7 +2010,7 @@ Sun Feb 11 22:10:08 2007 Kouhei Sutou <kou@cozmixng.org>
Sun Feb 11 18:47:14 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp> Sun Feb 11 18:47:14 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_val2olevariantdata): * ext/win32ole/win32ole.c (ole_val2olevariantdata):
WIN32OLE_VARIANT#new accepts nil when variant type is VT_ARRAY. WIN32OLE_VARIANT#new accepts nil when variant type is VT_ARRAY.
* test/win32ole/test_win32ole_variant.rb: ditto. * test/win32ole/test_win32ole_variant.rb: ditto.
@ -2026,7 +2038,7 @@ Sat Feb 10 17:46:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
Sat Feb 10 00:13:11 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> Sat Feb 10 00:13:11 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb: fix typo (TkConfigMethod::__confinfo_cmd, * ext/tk/lib/tk.rb: fix typo (TkConfigMethod::__confinfo_cmd,
__conv_keyonly_opts). __conv_keyonly_opts).
Fri Feb 9 12:33:40 2007 Koichi Sasada <ko1@atdot.net> Fri Feb 9 12:33:40 2007 Koichi Sasada <ko1@atdot.net>
@ -2066,7 +2078,7 @@ Thu Feb 8 22:44:04 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_set_safe_array, ole_variant2val, * ext/win32ole/win32ole.c (ole_set_safe_array, ole_variant2val,
ole_val_ary2variant_ary): fix WIN32OLE_VARIANT.new bug when ole_val_ary2variant_ary): fix WIN32OLE_VARIANT.new bug when
1st argument is empty array, and when 2nd argument is 1st argument is empty array, and when 2nd argument is
VT_ARRAY|VT_BYREF. VT_ARRAY|VT_BYREF.
* test/win32ole/test_win32ole_variant.rb: ditto. * test/win32ole/test_win32ole_variant.rb: ditto.
@ -2123,7 +2135,7 @@ Thu Feb 8 15:48:44 2007 Koichi Sasada <ko1@atdot.net>
* thread.c: fix to use polling in select on cygwin and mswin32. * thread.c: fix to use polling in select on cygwin and mswin32.
* thread.c, thread_pthread.ci, thread_win32.ci, yarvcore.h: * thread.c, thread_pthread.ci, thread_win32.ci, yarvcore.h:
rename: rename:
* rb_thread_t#interrupt_function -> unblock_function * rb_thread_t#interrupt_function -> unblock_function
* rb_interrupt_function_t -> rb_unblock_function * rb_interrupt_function_t -> rb_unblock_function
@ -2223,7 +2235,7 @@ Wed Feb 7 09:35:32 2007 Koichi Sasada <ko1@atdot.net>
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE. * thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
* vm.c (rb_svar, rb_backref_get, rb_backref_get, * vm.c (rb_svar, rb_backref_get, rb_backref_get,
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c. rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
* vm.c (yarv_init_redefined_flag): add a prototype and rename * vm.c (yarv_init_redefined_flag): add a prototype and rename
@ -2409,7 +2421,7 @@ Sat Feb 3 23:51:58 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
symbol from a symbol and a class. back-ported from matzruby. symbol from a symbol and a class. back-ported from matzruby.
* parse.y (rb_decompose_ivar2): reverse function of * parse.y (rb_decompose_ivar2): reverse function of
rb_compose_ivar2(). rb_compose_ivar2().
* marshal.c (w_symbol): support class local instance variables. * marshal.c (w_symbol): support class local instance variables.
@ -2433,7 +2445,7 @@ Sat Feb 3 23:21:13 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
Sat Feb 3 14:32:58 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp> Sat Feb 3 14:32:58 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_val2olevariantdata, ole_val2variant): * ext/win32ole/win32ole.c (ole_val2olevariantdata, ole_val2variant):
fix the bug of WIN32OLE_VARIANT.new when variant type is fix the bug of WIN32OLE_VARIANT.new when variant type is
VT_ARRAY. VT_ARRAY.
* ext/win32ole/sample/excel1.rb: rewrite using WIN32OLE_VARIANT. * ext/win32ole/sample/excel1.rb: rewrite using WIN32OLE_VARIANT.
@ -2484,7 +2496,7 @@ Fri Feb 2 18:27:54 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
Fri Feb 2 00:13:44 2007 Yukihiro Matsumoto <matz@ruby-lang.org> Fri Feb 2 00:13:44 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* ruby.h (SYMBOL_P): make Symbol immediate again for performance. * ruby.h (SYMBOL_P): make Symbol immediate again for performance.
* string.c: redesign symbol methods. * string.c: redesign symbol methods.
@ -2556,7 +2568,7 @@ Mon Jan 29 21:32:37 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* test/win32ole/test_win32ole.rb: add test for WIN32OLE.locale=, * test/win32ole/test_win32ole.rb: add test for WIN32OLE.locale=,
WIN32OLE.locale. WIN32OLE.locale.
* test/win32ole/test_win32ole_variant.rb: add test for * test/win32ole/test_win32ole_variant.rb: add test for
WIN32OLE_VARIANT#vartype. WIN32OLE_VARIANT#vartype.
Mon Jan 29 14:14:35 2007 Yukihiro Matsumoto <matz@ruby-lang.org> Mon Jan 29 14:14:35 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
@ -2570,11 +2582,11 @@ Sun Jan 28 08:41:49 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
Sat Jan 27 18:36:33 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp> Sat Jan 27 18:36:33 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_val2olevariantdata): bug fix. * ext/win32ole/win32ole.c (ole_val2olevariantdata): bug fix.
WIN32OLE_VARIANT.new check that 1st argument should T_ARRAY WIN32OLE_VARIANT.new check that 1st argument should T_ARRAY
when variant type is VT_ARRAY. when variant type is VT_ARRAY.
* test/win32ole/test_win32ole_variant.rb: add some test. * test/win32ole/test_win32ole_variant.rb: add some test.
Fri Jan 26 23:55:56 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp> Fri Jan 26 23:55:56 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
@ -2629,14 +2641,14 @@ Mon Jan 22 14:57:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
Sat Jan 20 21:05:18 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp> Sat Jan 20 21:05:18 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (fole_s_set_code_page): WIN32OLE.codepage= * ext/win32ole/win32ole.c (fole_s_set_code_page): WIN32OLE.codepage=
accepts installed codepage. accepts installed codepage.
* test/win32ole/test_win32ole.rb (test_s_codepage_changed): ditto. * test/win32ole/test_win32ole.rb (test_s_codepage_changed): ditto.
Sat Jan 20 11:18:49 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp> Sat Jan 20 11:18:49 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_invoke, ole_invoke2, ole_propertyput): * ext/win32ole/win32ole.c (ole_invoke, ole_invoke2, ole_propertyput):
modify WIN32OLERuntimeError message. modify WIN32OLERuntimeError message.
* test/win32ole/test_win32ole.rb: ditto. * test/win32ole/test_win32ole.rb: ditto.
@ -2665,11 +2677,11 @@ Fri Jan 19 06:53:38 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (olevariant_free): fix memory leak. * ext/win32ole/win32ole.c (olevariant_free): fix memory leak.
* ext/win32ole/win32ole.c (ole_val2olevariantdata): * ext/win32ole/win32ole.c (ole_val2olevariantdata):
WIN32OLE_VARIANT.new accepts nil as first argument for some VARIANT WIN32OLE_VARIANT.new accepts nil as first argument for some VARIANT
TYPE. TYPE.
* test/win32ole/test_win32ole_variant.rb: ditto. * test/win32ole/test_win32ole_variant.rb: ditto.
Wed Jan 17 17:31:28 2007 Koichi Sasada <ko1@atdot.net> Wed Jan 17 17:31:28 2007 Koichi Sasada <ko1@atdot.net>
@ -2681,7 +2693,7 @@ Wed Jan 17 17:31:28 2007 Koichi Sasada <ko1@atdot.net>
* yarvcore.h, yarvcore.c: rename or remove some global variables * yarvcore.h, yarvcore.c: rename or remove some global variables
removed: mYarvCore, mYarvInsns removed: mYarvCore, mYarvInsns
renamed: cYarvISeq -> rb_cISeq, renamed: cYarvISeq -> rb_cISeq,
cYarvProc -> rb_cProc, cYarvBinding -> rb_cBinding cYarvProc -> rb_cProc, cYarvBinding -> rb_cBinding
::YarvCore module is removed and ::YarvCore::VM class becomes ::VM. ::YarvCore module is removed and ::YarvCore::VM class becomes ::VM.
And change/remove some functions which added with YARV. And change/remove some functions which added with YARV.
@ -2733,8 +2745,8 @@ Tue Jan 16 12:00:06 2007 Koichi Sasada <ko1@atdot.net>
Sat Jan 13 23:24:59 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp> Sat Jan 13 23:24:59 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_free, ole_type_free, * ext/win32ole/win32ole.c (ole_free, ole_type_free,
olemethod_free, olevariable_free, oleparam_free, olemethod_free, olevariable_free, oleparam_free,
ole_event_free): fix memory leak. [ruby-core:09846] ole_event_free): fix memory leak. [ruby-core:09846]
Wed Jan 10 00:10:23 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed Jan 10 00:10:23 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
@ -2783,7 +2795,7 @@ Sun Jan 7 17:47:16 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c: update comment for rdoc of * ext/win32ole/win32ole.c: update comment for rdoc of
WIN32OLE#[] and WIN32OLE#[]=. WIN32OLE#[] and WIN32OLE#[]=.
Sun Jan 7 12:13:26 2007 Eric Hodel <drbrain@segment7.net> Sun Jan 7 12:13:26 2007 Eric Hodel <drbrain@segment7.net>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#find_class_comment): * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#find_class_comment):
Look for class and module comments above rb_define_class and Look for class and module comments above rb_define_class and
@ -2843,7 +2855,7 @@ Sat Jan 6 09:10:52 2007 Koichi Sasada <ko1@atdot.net>
Sat Jan 6 08:29:17 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp> Sat Jan 6 08:29:17 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (Init_win32ole): add * ext/win32ole/win32ole.c (Init_win32ole): add
WIN32OLE::VARIANT::VT_EMPTY, WIN32OLE::VARIANT::VT_NULL WIN32OLE::VARIANT::VT_EMPTY, WIN32OLE::VARIANT::VT_NULL
* test/win32ole/test_win32ole_variant_m.rb (test_variant): ditto. * test/win32ole/test_win32ole_variant_m.rb (test_variant): ditto.
@ -2916,7 +2928,7 @@ Fri Jan 5 13:59:53 2007 Koichi Sasada <ko1@atdot.net>
Fri Jan 5 12:03:07 2007 Koichi Sasada <ko1@atdot.net> Fri Jan 5 12:03:07 2007 Koichi Sasada <ko1@atdot.net>
* compile.c (iseq_compile_each, set_block_local_tbl): * compile.c (iseq_compile_each, set_block_local_tbl):
support NODE_LAMBDA (partly). support NODE_LAMBDA (partly).
* sample/test.rb: restore test of NODE_LAMBDA * sample/test.rb: restore test of NODE_LAMBDA
@ -2961,7 +2973,7 @@ Thu Jan 4 16:57:14 2007 Koichi Sasada <ko1@atdot.net>
Thu Jan 4 17:00:06 2007 GOTOU Yuuzou <gotoyuzo@notwork.org> Thu Jan 4 17:00:06 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_asn1.c (Init_ossl_asn1): * ext/openssl/ossl_asn1.c (Init_ossl_asn1):
OpenSSL::ASN1::ASN1Data#value,#tag,#tag_class and OpenSSL::ASN1::ASN1Data#value,#tag,#tag_class and
OpenSSL::ASN1::BitString#unused_bits should be public. OpenSSL::ASN1::BitString#unused_bits should be public.
Thu Jan 04 13:45:10 2007 Koichi Sasada <ko1@atdot.net> Thu Jan 04 13:45:10 2007 Koichi Sasada <ko1@atdot.net>
@ -3093,7 +3105,7 @@ Wed Dec 27 10:04:11 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
Tue Dec 26 21:02:14 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp> Tue Dec 26 21:02:14 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* test/win32ole/test_folderitem2_invokeverb.rb: The argument * test/win32ole/test_folderitem2_invokeverb.rb: The argument
of Shell.NameSpace should not be file path. of Shell.NameSpace should not be file path.
Tue Dec 26 06:13:08 2006 Minero Aoki <aamine@loveruby.net> Tue Dec 26 06:13:08 2006 Minero Aoki <aamine@loveruby.net>

View File

@ -17,76 +17,76 @@ call_cfunc(func, recv, len, argc, argv)
} }
switch (len) { switch (len) {
case -2: case -2:
return (*func) (recv, rb_ary_new4(argc, argv)); return (*func) (recv, rb_ary_new4(argc, argv));
break; break;
case -1: case -1:
return (*func) (argc, argv, recv); return (*func) (argc, argv, recv);
break; break;
case 0: case 0:
return (*func) (recv); return (*func) (recv);
break; break;
case 1: case 1:
return (*func) (recv, argv[0]); return (*func) (recv, argv[0]);
break; break;
case 2: case 2:
return (*func) (recv, argv[0], argv[1]); return (*func) (recv, argv[0], argv[1]);
break; break;
case 3: case 3:
return (*func) (recv, argv[0], argv[1], argv[2]); return (*func) (recv, argv[0], argv[1], argv[2]);
break; break;
case 4: case 4:
return (*func) (recv, argv[0], argv[1], argv[2], argv[3]); return (*func) (recv, argv[0], argv[1], argv[2], argv[3]);
break; break;
case 5: case 5:
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4]); return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4]);
break; break;
case 6: case 6:
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4], return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
argv[5]); argv[5]);
break; break;
case 7: case 7:
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4], return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
argv[5], argv[6]); argv[5], argv[6]);
break; break;
case 8: case 8:
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4], return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
argv[5], argv[6], argv[7]); argv[5], argv[6], argv[7]);
break; break;
case 9: case 9:
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4], return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
argv[5], argv[6], argv[7], argv[8]); argv[5], argv[6], argv[7], argv[8]);
break; break;
case 10: case 10:
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4], return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
argv[5], argv[6], argv[7], argv[8], argv[9]); argv[5], argv[6], argv[7], argv[8], argv[9]);
break; break;
case 11: case 11:
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4], return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
argv[5], argv[6], argv[7], argv[8], argv[9], argv[5], argv[6], argv[7], argv[8], argv[9],
argv[10]); argv[10]);
break; break;
case 12: case 12:
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4], return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
argv[5], argv[6], argv[7], argv[8], argv[9], argv[5], argv[6], argv[7], argv[8], argv[9],
argv[10], argv[11]); argv[10], argv[11]);
break; break;
case 13: case 13:
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4], return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10],
argv[11], argv[12]); argv[11], argv[12]);
break; break;
case 14: case 14:
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4], return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10],
argv[11], argv[12], argv[13]); argv[11], argv[12], argv[13]);
break; break;
case 15: case 15:
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4], return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10],
argv[11], argv[12], argv[13], argv[14]); argv[11], argv[12], argv[13], argv[14]);
break; break;
default: default:
rb_raise(rb_eArgError, "too many arguments(%d)", len); rb_raise(rb_eArgError, "too many arguments(%d)", len);
break; break;
} }

3162
compile.c

File diff suppressed because it is too large Load Diff

12
dir.c
View File

@ -1209,19 +1209,19 @@ glob_helper(
p = p->next; p = p->next;
} }
switch (p->type) { switch (p->type) {
case PLAIN: case PLAIN:
plain = 1; plain = 1;
break; break;
case MAGICAL: case MAGICAL:
magical = 1; magical = 1;
break; break;
case MATCH_ALL: case MATCH_ALL:
match_all = 1; match_all = 1;
break; break;
case MATCH_DIR: case MATCH_DIR:
match_dir = 1; match_dir = 1;
break; break;
case RECURSIVE: case RECURSIVE:
rb_bug("continuous RECURSIVEs"); rb_bug("continuous RECURSIVEs");
} }
} }
@ -1593,7 +1593,7 @@ dir_globs(long argc, VALUE *argv, int flags)
* Dir[ string [, string ...] ] => array * Dir[ string [, string ...] ] => array
* *
* Equivalent to calling * Equivalent to calling
* <code>Dir.glob(</code><i>array,</i><code>0)</code> and * <code>Dir.glob(</code><i>array,</i><code>0)</code> and
* <code>Dir.glob([</code><i>string,...</i><code>],0)</code>. * <code>Dir.glob([</code><i>string,...</i><code>],0)</code>.
* *
*/ */

180
eval.c
View File

@ -340,9 +340,9 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int level)
/* /*
* call-seq: * call-seq:
* Module.nesting => array * Module.nesting => array
* *
* Returns the list of +Modules+ nested at the point of call. * Returns the list of +Modules+ nested at the point of call.
* *
* module M1 * module M1
* module M2 * module M2
* $a = Module.nesting * $a = Module.nesting
@ -371,14 +371,14 @@ rb_mod_nesting(void)
/* /*
* call-seq: * call-seq:
* Module.constants => array * Module.constants => array
* *
* Returns an array of the names of all constants defined in the * Returns an array of the names of all constants defined in the
* system. This list includes the names of all modules and classes. * system. This list includes the names of all modules and classes.
* *
* p Module.constants.sort[1..5] * p Module.constants.sort[1..5]
* *
* <em>produces:</em> * <em>produces:</em>
* *
* ["ARGV", "ArgumentError", "Array", "Bignum", "Binding"] * ["ARGV", "ArgumentError", "Array", "Bignum", "Binding"]
*/ */
@ -421,11 +421,11 @@ rb_frozen_class_p(VALUE klass)
desc = "object"; desc = "object";
else { else {
switch (TYPE(klass)) { switch (TYPE(klass)) {
case T_MODULE: case T_MODULE:
case T_ICLASS: case T_ICLASS:
desc = "module"; desc = "module";
break; break;
case T_CLASS: case T_CLASS:
desc = "class"; desc = "class";
break; break;
} }
@ -437,7 +437,7 @@ rb_frozen_class_p(VALUE klass)
/* /*
* call-seq: * call-seq:
* obj.respond_to?(symbol, include_private=false) => true or false * obj.respond_to?(symbol, include_private=false) => true or false
* *
* Returns +true+> if _obj_ responds to the given * Returns +true+> if _obj_ responds to the given
* method. Private methods are included in the search only if the * method. Private methods are included in the search only if the
* optional second parameter evaluates to +true+. * optional second parameter evaluates to +true+.
@ -472,7 +472,7 @@ rb_respond_to(VALUE obj, ID id)
/* /*
* call-seq: * call-seq:
* obj.respond_to?(symbol, include_private=false) => true or false * obj.respond_to?(symbol, include_private=false) => true or false
* *
* Returns +true+> if _obj_ responds to the given * Returns +true+> if _obj_ responds to the given
* method. Private methods are included in the search only if the * method. Private methods are included in the search only if the
* optional second parameter evaluates to +true+. * optional second parameter evaluates to +true+.
@ -495,11 +495,11 @@ obj_respond_to(int argc, VALUE *argv, VALUE obj)
/* /*
* call-seq: * call-seq:
* mod.method_defined?(symbol) => true or false * mod.method_defined?(symbol) => true or false
* *
* Returns +true+ if the named method is defined by * Returns +true+ if the named method is defined by
* _mod_ (or its included modules and, if _mod_ is a class, * _mod_ (or its included modules and, if _mod_ is a class,
* its ancestors). Public and protected methods are matched. * its ancestors). Public and protected methods are matched.
* *
* module A * module A
* def method1() end * def method1() end
* end * end
@ -510,7 +510,7 @@ obj_respond_to(int argc, VALUE *argv, VALUE obj)
* include A * include A
* def method3() end * def method3() end
* end * end
* *
* A.method_defined? :method1 #=> true * A.method_defined? :method1 #=> true
* C.method_defined? "method1" #=> true * C.method_defined? "method1" #=> true
* C.method_defined? "method2" #=> true * C.method_defined? "method2" #=> true
@ -530,11 +530,11 @@ rb_mod_method_defined(mod, mid)
/* /*
* call-seq: * call-seq:
* mod.public_method_defined?(symbol) => true or false * mod.public_method_defined?(symbol) => true or false
* *
* Returns +true+ if the named public method is defined by * Returns +true+ if the named public method is defined by
* _mod_ (or its included modules and, if _mod_ is a class, * _mod_ (or its included modules and, if _mod_ is a class,
* its ancestors). * its ancestors).
* *
* module A * module A
* def method1() end * def method1() end
* end * end
@ -546,7 +546,7 @@ rb_mod_method_defined(mod, mid)
* include A * include A
* def method3() end * def method3() end
* end * end
* *
* A.method_defined? :method1 #=> true * A.method_defined? :method1 #=> true
* C.public_method_defined? "method1" #=> true * C.public_method_defined? "method1" #=> true
* C.public_method_defined? "method2" #=> false * C.public_method_defined? "method2" #=> false
@ -570,11 +570,11 @@ rb_mod_public_method_defined(VALUE mod, VALUE mid)
/* /*
* call-seq: * call-seq:
* mod.private_method_defined?(symbol) => true or false * mod.private_method_defined?(symbol) => true or false
* *
* Returns +true+ if the named private method is defined by * Returns +true+ if the named private method is defined by
* _ mod_ (or its included modules and, if _mod_ is a class, * _ mod_ (or its included modules and, if _mod_ is a class,
* its ancestors). * its ancestors).
* *
* module A * module A
* def method1() end * def method1() end
* end * end
@ -586,7 +586,7 @@ rb_mod_public_method_defined(VALUE mod, VALUE mid)
* include A * include A
* def method3() end * def method3() end
* end * end
* *
* A.method_defined? :method1 #=> true * A.method_defined? :method1 #=> true
* C.private_method_defined? "method1" #=> false * C.private_method_defined? "method1" #=> false
* C.private_method_defined? "method2" #=> true * C.private_method_defined? "method2" #=> true
@ -610,11 +610,11 @@ rb_mod_private_method_defined(VALUE mod, VALUE mid)
/* /*
* call-seq: * call-seq:
* mod.protected_method_defined?(symbol) => true or false * mod.protected_method_defined?(symbol) => true or false
* *
* Returns +true+ if the named protected method is defined * Returns +true+ if the named protected method is defined
* by _mod_ (or its included modules and, if _mod_ is a * by _mod_ (or its included modules and, if _mod_ is a
* class, its ancestors). * class, its ancestors).
* *
* module A * module A
* def method1() end * def method1() end
* end * end
@ -626,7 +626,7 @@ rb_mod_private_method_defined(VALUE mod, VALUE mid)
* include A * include A
* def method3() end * def method3() end
* end * end
* *
* A.method_defined? :method1 #=> true * A.method_defined? :method1 #=> true
* C.protected_method_defined? "method1" #=> false * C.protected_method_defined? "method1" #=> false
* C.protected_method_defined? "method2" #=> true * C.protected_method_defined? "method2" #=> true
@ -745,7 +745,7 @@ rb_interrupt()
* fail * fail
* fail(string) * fail(string)
* fail(exception [, string [, array]]) * fail(exception [, string [, array]])
* *
* With no arguments, raises the exception in <code>$!</code> or raises * With no arguments, raises the exception in <code>$!</code> or raises
* a <code>RuntimeError</code> if <code>$!</code> is +nil+. * a <code>RuntimeError</code> if <code>$!</code> is +nil+.
* With a single +String+ argument, raises a * With a single +String+ argument, raises a
@ -756,7 +756,7 @@ rb_interrupt()
* message associated with the exception, and the third parameter is an * message associated with the exception, and the third parameter is an
* array of callback information. Exceptions are caught by the * array of callback information. Exceptions are caught by the
* +rescue+ clause of <code>begin...end</code> blocks. * +rescue+ clause of <code>begin...end</code> blocks.
* *
* raise "Failed to create socket" * raise "Failed to create socket"
* raise ArgumentError, "No parameters", caller * raise ArgumentError, "No parameters", caller
*/ */
@ -787,10 +787,10 @@ rb_make_exception(int argc, VALUE *argv)
mesg = Qnil; mesg = Qnil;
switch (argc) { switch (argc) {
case 0: case 0:
mesg = Qnil; mesg = Qnil;
break; break;
case 1: case 1:
if (NIL_P(argv[0])) if (NIL_P(argv[0]))
break; break;
if (TYPE(argv[0]) == T_STRING) { if (TYPE(argv[0]) == T_STRING) {
@ -800,8 +800,8 @@ rb_make_exception(int argc, VALUE *argv)
n = 0; n = 0;
goto exception_call; goto exception_call;
case 2: case 2:
case 3: case 3:
n = 1; n = 1;
exception_call: exception_call:
exception = rb_intern("exception"); exception = rb_intern("exception");
@ -810,7 +810,7 @@ rb_make_exception(int argc, VALUE *argv)
} }
mesg = rb_funcall(argv[0], exception, n, argv[1]); mesg = rb_funcall(argv[0], exception, n, argv[1]);
break; break;
default: default:
rb_raise(rb_eArgError, "wrong number of arguments"); rb_raise(rb_eArgError, "wrong number of arguments");
break; break;
} }
@ -861,11 +861,11 @@ rb_iterator_p()
* call-seq: * call-seq:
* block_given? => true or false * block_given? => true or false
* iterator? => true or false * iterator? => true or false
* *
* Returns <code>true</code> if <code>yield</code> would execute a * Returns <code>true</code> if <code>yield</code> would execute a
* block in the current context. The <code>iterator?</code> form * block in the current context. The <code>iterator?</code> form
* is mildly deprecated. * is mildly deprecated.
* *
* def try * def try
* if block_given? * if block_given?
* yield * yield
@ -969,9 +969,9 @@ rb_yield_splat(VALUE values)
/* /*
* call-seq: * call-seq:
* loop {|| block } * loop {|| block }
* *
* Repeatedly executes the block. * Repeatedly executes the block.
* *
* loop do * loop do
* print "Input: " * print "Input: "
* line = gets * line = gets
@ -1254,7 +1254,7 @@ stack_check(void)
/* /*
* call-seq: * call-seq:
* obj.method_missing(symbol [, *args] ) => result * obj.method_missing(symbol [, *args] ) => result
* *
* Invoked by Ruby when <i>obj</i> is sent a message it cannot handle. * Invoked by Ruby when <i>obj</i> is sent a message it cannot handle.
* <i>symbol</i> is the symbol for the method called, and <i>args</i> * <i>symbol</i> is the symbol for the method called, and <i>args</i>
* are any arguments that were passed to it. By default, the interpreter * are any arguments that were passed to it. By default, the interpreter
@ -1264,7 +1264,7 @@ stack_check(void)
* a class <code>Roman</code>, which responds to methods with names * a class <code>Roman</code>, which responds to methods with names
* consisting of roman numerals, returning the corresponding integer * consisting of roman numerals, returning the corresponding integer
* values. * values.
* *
* class Roman * class Roman
* def romanToInt(str) * def romanToInt(str)
* # ... * # ...
@ -1274,7 +1274,7 @@ stack_check(void)
* romanToInt(str) * romanToInt(str)
* end * end
* end * end
* *
* r = Roman.new * r = Roman.new
* r.iv #=> 4 * r.iv #=> 4
* r.xxiii #=> 23 * r.xxiii #=> 23
@ -1462,11 +1462,11 @@ send_funcall(int argc, VALUE *argv, VALUE recv, int scope)
* call-seq: * call-seq:
* obj.send(symbol [, args...]) => obj * obj.send(symbol [, args...]) => obj
* obj.__send__(symbol [, args...]) => obj * obj.__send__(symbol [, args...]) => obj
* *
* Invokes the method identified by _symbol_, passing it any * Invokes the method identified by _symbol_, passing it any
* arguments specified. You can use <code>__send__</code> if the name * arguments specified. You can use <code>__send__</code> if the name
* +send+ clashes with an existing method in _obj_. * +send+ clashes with an existing method in _obj_.
* *
* class Klass * class Klass
* def hello(*args) * def hello(*args)
* "Hello " + args.join(' ') * "Hello " + args.join(' ')
@ -1494,12 +1494,12 @@ rb_f_send(int argc, VALUE *argv, VALUE recv)
* call-seq: * call-seq:
* obj.funcall(symbol [, args...]) => obj * obj.funcall(symbol [, args...]) => obj
* obj.__send!(symbol [, args...]) => obj * obj.__send!(symbol [, args...]) => obj
* *
* Invokes the method identified by _symbol_, passing it any * Invokes the method identified by _symbol_, passing it any
* arguments specified. Unlike send, which calls private methods only * arguments specified. Unlike send, which calls private methods only
* when it is invoked in function call style, funcall always aware of * when it is invoked in function call style, funcall always aware of
* private methods. * private methods.
* *
* 1.funcall(:puts, "hello") # prints "foo" * 1.funcall(:puts, "hello") # prints "foo"
*/ */
@ -1555,13 +1555,13 @@ backtrace(int lev)
/* /*
* call-seq: * call-seq:
* caller(start=1) => array * caller(start=1) => array
* *
* Returns the current execution stack---an array containing strings in * Returns the current execution stack---an array containing strings in
* the form ``<em>file:line</em>'' or ``<em>file:line: in * the form ``<em>file:line</em>'' or ``<em>file:line: in
* `method'</em>''. The optional _start_ parameter * `method'</em>''. The optional _start_ parameter
* determines the number of initial stack entries to omit from the * determines the number of initial stack entries to omit from the
* result. * result.
* *
* def a(skip) * def a(skip)
* caller(skip) * caller(skip)
* end * end
@ -1710,7 +1710,7 @@ eval(VALUE self, VALUE src, VALUE scope, char *file, int line)
VALUE iseqval; VALUE iseqval;
if (scope != Qnil) { if (scope != Qnil) {
if (CLASS_OF(scope) == rb_cBinding) { if (CLASS_OF(scope) == rb_cBinding) {
GetBindingPtr(scope, bind); GetBindingPtr(scope, bind);
envval = bind->env; envval = bind->env;
@ -1788,14 +1788,14 @@ eval(VALUE self, VALUE src, VALUE scope, char *file, int line)
/* /*
* call-seq: * call-seq:
* eval(string [, binding [, filename [,lineno]]]) => obj * eval(string [, binding [, filename [,lineno]]]) => obj
* *
* Evaluates the Ruby expression(s) in <em>string</em>. If * Evaluates the Ruby expression(s) in <em>string</em>. If
* <em>binding</em> is given, the evaluation is performed in its * <em>binding</em> is given, the evaluation is performed in its
* context. The binding may be a <code>Binding</code> object or a * context. The binding may be a <code>Binding</code> object or a
* <code>Proc</code> object. If the optional <em>filename</em> and * <code>Proc</code> object. If the optional <em>filename</em> and
* <em>lineno</em> parameters are present, they will be used when * <em>lineno</em> parameters are present, they will be used when
* reporting syntax errors. * reporting syntax errors.
* *
* def getBinding(str) * def getBinding(str)
* return binding * return binding
* end * end
@ -1865,7 +1865,7 @@ exec_under(VALUE (*func) (VALUE), VALUE under, VALUE self, VALUE args)
while (!RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { while (!RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
} }
pcref = (NODE **) th_cfp_svar(cfp, -1); pcref = (NODE **) th_cfp_svar(cfp, -1);
stored_cref = *pcref; stored_cref = *pcref;
*pcref = th_cref_push(th, under, NOEX_PUBLIC); *pcref = th_cref_push(th, under, NOEX_PUBLIC);
@ -1890,7 +1890,7 @@ static VALUE
yield_under_i(VALUE arg) yield_under_i(VALUE arg)
{ {
int avalue = Qtrue; int avalue = Qtrue;
if (arg == Qundef) { if (arg == Qundef) {
avalue = Qfalse; avalue = Qfalse;
} }
@ -1974,7 +1974,7 @@ specific_eval(int argc, VALUE *argv, VALUE klass, VALUE self)
* call-seq: * call-seq:
* obj.instance_eval(string [, filename [, lineno]] ) => obj * obj.instance_eval(string [, filename [, lineno]] ) => obj
* obj.instance_eval {| | block } => obj * obj.instance_eval {| | block } => obj
* *
* Evaluates a string containing Ruby source code, or the given block, * Evaluates a string containing Ruby source code, or the given block,
* within the context of the receiver (_obj_). In order to set the * within the context of the receiver (_obj_). In order to set the
* context, the variable +self+ is set to _obj_ while * context, the variable +self+ is set to _obj_ while
@ -1983,7 +1983,7 @@ specific_eval(int argc, VALUE *argv, VALUE klass, VALUE self)
* that takes a +String+, the optional second and third * that takes a +String+, the optional second and third
* parameters supply a filename and starting line number that are used * parameters supply a filename and starting line number that are used
* when reporting compilation errors. * when reporting compilation errors.
* *
* class Klass * class Klass
* def initialize * def initialize
* @secret = 99 * @secret = 99
@ -2010,12 +2010,12 @@ rb_obj_instance_eval(int argc, VALUE *argv, VALUE self)
/* /*
* call-seq: * call-seq:
* obj.instance_exec(arg...) {|var...| block } => obj * obj.instance_exec(arg...) {|var...| block } => obj
* *
* Executes the given block within the context of the receiver * Executes the given block within the context of the receiver
* (_obj_). In order to set the context, the variable +self+ is set * (_obj_). In order to set the context, the variable +self+ is set
* to _obj_ while the code is executing, giving the code access to * to _obj_ while the code is executing, giving the code access to
* _obj_'s instance variables. Arguments are passed as block parameters. * _obj_'s instance variables. Arguments are passed as block parameters.
* *
* class Klass * class Klass
* def initialize * def initialize
* @secret = 99 * @secret = 99
@ -2043,21 +2043,21 @@ rb_obj_instance_exec(int argc, VALUE *argv, VALUE self)
* call-seq: * call-seq:
* mod.class_eval(string [, filename [, lineno]]) => obj * mod.class_eval(string [, filename [, lineno]]) => obj
* mod.module_eval {|| block } => obj * mod.module_eval {|| block } => obj
* *
* Evaluates the string or block in the context of _mod_. This can * Evaluates the string or block in the context of _mod_. This can
* be used to add methods to a class. <code>module_eval</code> returns * be used to add methods to a class. <code>module_eval</code> returns
* the result of evaluating its argument. The optional _filename_ * the result of evaluating its argument. The optional _filename_
* and _lineno_ parameters set the text for error messages. * and _lineno_ parameters set the text for error messages.
* *
* class Thing * class Thing
* end * end
* a = %q{def hello() "Hello there!" end} * a = %q{def hello() "Hello there!" end}
* Thing.module_eval(a) * Thing.module_eval(a)
* puts Thing.new.hello() * puts Thing.new.hello()
* Thing.module_eval("invalid code", "dummy", 123) * Thing.module_eval("invalid code", "dummy", 123)
* *
* <em>produces:</em> * <em>produces:</em>
* *
* Hello there! * Hello there!
* dummy:123:in `module_eval': undefined local variable * dummy:123:in `module_eval': undefined local variable
* or method `code' for Thing:Class * or method `code' for Thing:Class
@ -2073,19 +2073,19 @@ rb_mod_module_eval(int argc, VALUE *argv, VALUE mod)
* call-seq: * call-seq:
* mod.module_exec(arg...) {|var...| block } => obj * mod.module_exec(arg...) {|var...| block } => obj
* mod.class_exec(arg...) {|var...| block } => obj * mod.class_exec(arg...) {|var...| block } => obj
* *
* Evaluates the given block in the context of the class/module. * Evaluates the given block in the context of the class/module.
* The method defined in the block will belong to the receiver. * The method defined in the block will belong to the receiver.
* *
* class Thing * class Thing
* end * end
* Thing.class_exec{ * Thing.class_exec{
* def hello() "Hello there!" end * def hello() "Hello there!" end
* } * }
* puts Thing.new.hello() * puts Thing.new.hello()
* *
* <em>produces:</em> * <em>produces:</em>
* *
* Hello there! * Hello there!
*/ */
@ -2119,7 +2119,7 @@ set_method_visibility(VALUE self, int argc, VALUE *argv, ID ex)
* call-seq: * call-seq:
* public => self * public => self
* public(symbol, ...) => self * public(symbol, ...) => self
* *
* With no arguments, sets the default visibility for subsequently * With no arguments, sets the default visibility for subsequently
* defined methods to public. With arguments, sets the named methods to * defined methods to public. With arguments, sets the named methods to
* have public visibility. * have public visibility.
@ -2142,7 +2142,7 @@ rb_mod_public(int argc, VALUE *argv, VALUE module)
* call-seq: * call-seq:
* protected => self * protected => self
* protected(symbol, ...) => self * protected(symbol, ...) => self
* *
* With no arguments, sets the default visibility for subsequently * With no arguments, sets the default visibility for subsequently
* defined methods to protected. With arguments, sets the named methods * defined methods to protected. With arguments, sets the named methods
* to have protected visibility. * to have protected visibility.
@ -2165,11 +2165,11 @@ rb_mod_protected(int argc, VALUE *argv, VALUE module)
* call-seq: * call-seq:
* private => self * private => self
* private(symbol, ...) => self * private(symbol, ...) => self
* *
* With no arguments, sets the default visibility for subsequently * With no arguments, sets the default visibility for subsequently
* defined methods to private. With arguments, sets the named methods * defined methods to private. With arguments, sets the named methods
* to have private visibility. * to have private visibility.
* *
* module Mod * module Mod
* def a() end * def a() end
* def b() end * def b() end
@ -2196,7 +2196,7 @@ rb_mod_private(int argc, VALUE *argv, VALUE module)
/* /*
* call-seq: * call-seq:
* mod.public_class_method(symbol, ...) => mod * mod.public_class_method(symbol, ...) => mod
* *
* Makes a list of existing class methods public. * Makes a list of existing class methods public.
*/ */
@ -2210,10 +2210,10 @@ rb_mod_public_method(int argc, VALUE *argv, VALUE obj)
/* /*
* call-seq: * call-seq:
* mod.private_class_method(symbol, ...) => mod * mod.private_class_method(symbol, ...) => mod
* *
* Makes existing class methods private. Often used to hide the default * Makes existing class methods private. Often used to hide the default
* constructor <code>new</code>. * constructor <code>new</code>.
* *
* class SimpleSingleton # Not thread safe * class SimpleSingleton # Not thread safe
* private_class_method :new * private_class_method :new
* def SimpleSingleton.create(*args, &block) * def SimpleSingleton.create(*args, &block)
@ -2234,7 +2234,7 @@ rb_mod_private_method(int argc, VALUE *argv, VALUE obj)
* call-seq: * call-seq:
* public * public
* public(symbol, ...) * public(symbol, ...)
* *
* With no arguments, sets the default visibility for subsequently * With no arguments, sets the default visibility for subsequently
* defined methods to public. With arguments, sets the named methods to * defined methods to public. With arguments, sets the named methods to
* have public visibility. * have public visibility.
@ -2255,7 +2255,7 @@ top_private(int argc, VALUE *argv)
/* /*
* call-seq: * call-seq:
* module_function(symbol, ...) => self * module_function(symbol, ...) => self
* *
* Creates module functions for the named methods. These functions may * Creates module functions for the named methods. These functions may
* be called with the module as a receiver, and also become available * be called with the module as a receiver, and also become available
* as instance methods to classes that mix in the module. Module * as instance methods to classes that mix in the module. Module
@ -2263,7 +2263,7 @@ top_private(int argc, VALUE *argv)
* independently. The instance-method versions are made private. If * independently. The instance-method versions are made private. If
* used with no arguments, subsequently defined methods become module * used with no arguments, subsequently defined methods become module
* functions. * functions.
* *
* module Mod * module Mod
* def one * def one
* "This is one" * "This is one"
@ -2335,7 +2335,7 @@ rb_mod_modfunc(int argc, VALUE *argv, VALUE module)
/* /*
* call-seq: * call-seq:
* append_features(mod) => mod * append_features(mod) => mod
* *
* When this module is included in another, Ruby calls * When this module is included in another, Ruby calls
* <code>append_features</code> in this module, passing it the * <code>append_features</code> in this module, passing it the
* receiving module in _mod_. Ruby's default implementation is * receiving module in _mod_. Ruby's default implementation is
@ -2348,10 +2348,10 @@ static VALUE
rb_mod_append_features(VALUE module, VALUE include) rb_mod_append_features(VALUE module, VALUE include)
{ {
switch (TYPE(include)) { switch (TYPE(include)) {
case T_CLASS: case T_CLASS:
case T_MODULE: case T_MODULE:
break; break;
default: default:
Check_Type(include, T_CLASS); Check_Type(include, T_CLASS);
break; break;
} }
@ -2363,7 +2363,7 @@ rb_mod_append_features(VALUE module, VALUE include)
/* /*
* call-seq: * call-seq:
* include(module, ...) => self * include(module, ...) => self
* *
* Invokes <code>Module.append_features</code> on each parameter in turn. * Invokes <code>Module.append_features</code> on each parameter in turn.
*/ */
@ -2397,11 +2397,11 @@ rb_extend_object(VALUE obj, VALUE module)
/* /*
* call-seq: * call-seq:
* extend_object(obj) => obj * extend_object(obj) => obj
* *
* Extends the specified object by adding this module's constants and * Extends the specified object by adding this module's constants and
* methods (which are added as singleton methods). This is the callback * methods (which are added as singleton methods). This is the callback
* method used by <code>Object#extend</code>. * method used by <code>Object#extend</code>.
* *
* module Picky * module Picky
* def Picky.extend_object(o) * def Picky.extend_object(o)
* if String === o * if String === o
@ -2414,9 +2414,9 @@ rb_extend_object(VALUE obj, VALUE module)
* end * end
* (s = Array.new).extend Picky # Call Object.extend * (s = Array.new).extend Picky # Call Object.extend
* (s = "quick brown fox").extend Picky * (s = "quick brown fox").extend Picky
* *
* <em>produces:</em> * <em>produces:</em>
* *
* Picky added to Array * Picky added to Array
* Can't add Picky to a String * Can't add Picky to a String
*/ */
@ -2431,22 +2431,22 @@ rb_mod_extend_object(VALUE mod, VALUE obj)
/* /*
* call-seq: * call-seq:
* obj.extend(module, ...) => obj * obj.extend(module, ...) => obj
* *
* Adds to _obj_ the instance methods from each module given as a * Adds to _obj_ the instance methods from each module given as a
* parameter. * parameter.
* *
* module Mod * module Mod
* def hello * def hello
* "Hello from Mod.\n" * "Hello from Mod.\n"
* end * end
* end * end
* *
* class Klass * class Klass
* def hello * def hello
* "Hello from Klass.\n" * "Hello from Klass.\n"
* end * end
* end * end
* *
* k = Klass.new * k = Klass.new
* k.hello #=> "Hello from Klass.\n" * k.hello #=> "Hello from Klass.\n"
* k.extend(Mod) #=> #<Klass:0x401b3bc8> * k.extend(Mod) #=> #<Klass:0x401b3bc8>
@ -2473,7 +2473,7 @@ rb_obj_extend(int argc, VALUE *argv, VALUE obj)
/* /*
* call-seq: * call-seq:
* include(module, ...) => self * include(module, ...) => self
* *
* Invokes <code>Module.append_features</code> * Invokes <code>Module.append_features</code>
* on each parameter in turn. Effectively adds the methods and constants * on each parameter in turn. Effectively adds the methods and constants
* in each module to the receiver. * in each module to the receiver.
@ -2572,9 +2572,9 @@ errat_setter(VALUE val, ID id, VALUE *var)
/* /*
* call-seq: * call-seq:
* local_variables => array * local_variables => array
* *
* Returns the names of the current local variables. * Returns the names of the current local variables.
* *
* fred = 1 * fred = 1
* for i in 1..10 * for i in 1..10
* # ... * # ...
@ -2630,7 +2630,7 @@ rb_f_local_variables(void)
/* /*
* call-seq: * call-seq:
* __method__ => symbol * __method__ => symbol
* *
* Returns the name of the current method as a Symbol. * Returns the name of the current method as a Symbol.
* If called from inside of an aliased method it will return the original * If called from inside of an aliased method it will return the original
* nonaliased name. * nonaliased name.
@ -2655,7 +2655,7 @@ rb_f_method_name(void)
/* /*
* call-seq: * call-seq:
* __callee__ => symbol * __callee__ => symbol
* *
* Returns the name of the current method as Symbol. * Returns the name of the current method as Symbol.
* If called from inside of an aliased method it will return the aliased * If called from inside of an aliased method it will return the aliased
* name. * name.
@ -2683,7 +2683,7 @@ Init_eval(void)
{ {
/* TODO: fix position */ /* TODO: fix position */
GET_THREAD()->vm->mark_object_ary = rb_ary_new(); GET_THREAD()->vm->mark_object_ary = rb_ary_new();
init = rb_intern("initialize"); init = rb_intern("initialize");
eqq = rb_intern("==="); eqq = rb_intern("===");
each = rb_intern("each"); each = rb_intern("each");
@ -2729,7 +2729,7 @@ Init_eval(void)
rb_define_global_function("__method__", rb_f_method_name, 0); rb_define_global_function("__method__", rb_f_method_name, 0);
rb_define_global_function("__callee__", rb_f_callee_name, 0); rb_define_global_function("__callee__", rb_f_callee_name, 0);
rb_define_method(rb_cBasicObject, "send", rb_f_send, -1); rb_define_method(rb_cBasicObject, "send", rb_f_send, -1);
rb_define_method(rb_cBasicObject, "__send__", rb_f_send, -1); rb_define_method(rb_cBasicObject, "__send__", rb_f_send, -1);
rb_define_method(rb_cBasicObject, "__send", rb_f_send, -1); rb_define_method(rb_cBasicObject, "__send", rb_f_send, -1);

View File

@ -9,7 +9,7 @@ NORETURN(static VALUE rb_f_throw _((int, VALUE *)));
/* /*
* call-seq: * call-seq:
* throw(symbol [, obj]) * throw(symbol [, obj])
* *
* Transfers control to the end of the active +catch+ block * Transfers control to the end of the active +catch+ block
* waiting for _symbol_. Raises +NameError+ if there * waiting for _symbol_. Raises +NameError+ if there
* is no +catch+ block for the symbol. The optional second * is no +catch+ block for the symbol. The optional second
@ -61,7 +61,7 @@ rb_throw(const char *tag, VALUE val)
/* /*
* call-seq: * call-seq:
* catch(symbol) {| | block } > obj * catch(symbol) {| | block } > obj
* *
* +catch+ executes its block. If a +throw+ is * +catch+ executes its block. If a +throw+ is
* executed, Ruby searches up its stack for a +catch+ block * executed, Ruby searches up its stack for a +catch+ block
* with a tag corresponding to the +throw+'s * with a tag corresponding to the +throw+'s
@ -71,18 +71,18 @@ rb_throw(const char *tag, VALUE val)
* the value of +catch+ is the value of the last expression * the value of +catch+ is the value of the last expression
* evaluated. +catch+ expressions may be nested, and the * evaluated. +catch+ expressions may be nested, and the
* +throw+ call need not be in lexical scope. * +throw+ call need not be in lexical scope.
* *
* def routine(n) * def routine(n)
* puts n * puts n
* throw :done if n <= 0 * throw :done if n <= 0
* routine(n-1) * routine(n-1)
* end * end
* *
* *
* catch(:done) { routine(3) } * catch(:done) { routine(3) }
* *
* <em>produces:</em> * <em>produces:</em>
* *
* 3 * 3
* 2 * 2
* 1 * 1
@ -162,12 +162,12 @@ rb_exit(int status)
* exit(integer=0) * exit(integer=0)
* Kernel::exit(integer=0) * Kernel::exit(integer=0)
* Process::exit(integer=0) * Process::exit(integer=0)
* *
* Initiates the termination of the Ruby script by raising the * Initiates the termination of the Ruby script by raising the
* <code>SystemExit</code> exception. This exception may be caught. The * <code>SystemExit</code> exception. This exception may be caught. The
* optional parameter is used to return a status code to the invoking * optional parameter is used to return a status code to the invoking
* environment. * environment.
* *
* begin * begin
* exit * exit
* puts "never get here" * puts "never get here"
@ -175,22 +175,22 @@ rb_exit(int status)
* puts "rescued a SystemExit exception" * puts "rescued a SystemExit exception"
* end * end
* puts "after begin block" * puts "after begin block"
* *
* <em>produces:</em> * <em>produces:</em>
* *
* rescued a SystemExit exception * rescued a SystemExit exception
* after begin block * after begin block
* *
* Just prior to termination, Ruby executes any <code>at_exit</code> functions * Just prior to termination, Ruby executes any <code>at_exit</code> functions
* (see Kernel::at_exit) and runs any object finalizers (see * (see Kernel::at_exit) and runs any object finalizers (see
* ObjectSpace::define_finalizer). * ObjectSpace::define_finalizer).
* *
* at_exit { puts "at_exit function" } * at_exit { puts "at_exit function" }
* ObjectSpace.define_finalizer("string", proc { puts "in finalizer" }) * ObjectSpace.define_finalizer("string", proc { puts "in finalizer" })
* exit * exit
* *
* <em>produces:</em> * <em>produces:</em>
* *
* at_exit function * at_exit function
* in finalizer * in finalizer
*/ */
@ -204,13 +204,13 @@ rb_f_exit(int argc, VALUE *argv)
rb_secure(4); rb_secure(4);
if (rb_scan_args(argc, argv, "01", &status) == 1) { if (rb_scan_args(argc, argv, "01", &status) == 1) {
switch (status) { switch (status) {
case Qtrue: case Qtrue:
istatus = EXIT_SUCCESS; istatus = EXIT_SUCCESS;
break; break;
case Qfalse: case Qfalse:
istatus = EXIT_FAILURE; istatus = EXIT_FAILURE;
break; break;
default: default:
istatus = NUM2INT(status); istatus = NUM2INT(status);
#if EXIT_SUCCESS != 0 #if EXIT_SUCCESS != 0
if (istatus == 0) if (istatus == 0)
@ -232,7 +232,7 @@ rb_f_exit(int argc, VALUE *argv)
* abort * abort
* Kernel::abort * Kernel::abort
* Process::abort * Process::abort
* *
* Terminate execution immediately, effectively by calling * Terminate execution immediately, effectively by calling
* <code>Kernel.exit(1)</code>. If _msg_ is given, it is written * <code>Kernel.exit(1)</code>. If _msg_ is given, it is written
* to STDERR prior to terminating. * to STDERR prior to terminating.
@ -272,21 +272,21 @@ call_end_proc(VALUE data)
/* /*
* call-seq: * call-seq:
* at_exit { block } -> proc * at_exit { block } -> proc
* *
* Converts _block_ to a +Proc+ object (and therefore * Converts _block_ to a +Proc+ object (and therefore
* binds it at the point of call) and registers it for execution when * binds it at the point of call) and registers it for execution when
* the program exits. If multiple handlers are registered, they are * the program exits. If multiple handlers are registered, they are
* executed in reverse order of registration. * executed in reverse order of registration.
* *
* def do_at_exit(str1) * def do_at_exit(str1)
* at_exit { print str1 } * at_exit { print str1 }
* end * end
* at_exit { puts "cruel world" } * at_exit { puts "cruel world" }
* do_at_exit("goodbye ") * do_at_exit("goodbye ")
* exit * exit
* *
* <em>produces:</em> * <em>produces:</em>
* *
* goodbye cruel world * goodbye cruel world
*/ */

View File

@ -317,7 +317,7 @@ rb_remove_method(VALUE klass, const char *name)
/* /*
* call-seq: * call-seq:
* remove_method(symbol) => self * remove_method(symbol) => self
* *
* Removes the method identified by _symbol_ from the current * Removes the method identified by _symbol_ from the current
* class. For an example, see <code>Module.undef_method</code>. * class. For an example, see <code>Module.undef_method</code>.
*/ */
@ -460,8 +460,8 @@ rb_undef(VALUE klass, ID id)
VALUE obj = rb_iv_get(klass, "__attached__"); VALUE obj = rb_iv_get(klass, "__attached__");
switch (TYPE(obj)) { switch (TYPE(obj)) {
case T_MODULE: case T_MODULE:
case T_CLASS: case T_CLASS:
c = obj; c = obj;
s0 = ""; s0 = "";
} }
@ -487,12 +487,12 @@ rb_undef(VALUE klass, ID id)
/* /*
* call-seq: * call-seq:
* undef_method(symbol) => self * undef_method(symbol) => self
* *
* Prevents the current class from responding to calls to the named * Prevents the current class from responding to calls to the named
* method. Contrast this with <code>remove_method</code>, which deletes * method. Contrast this with <code>remove_method</code>, which deletes
* the method from the particular class; Ruby will still search * the method from the particular class; Ruby will still search
* superclasses and mixed-in modules for a possible receiver. * superclasses and mixed-in modules for a possible receiver.
* *
* class Parent * class Parent
* def hello * def hello
* puts "In parent" * puts "In parent"
@ -503,25 +503,25 @@ rb_undef(VALUE klass, ID id)
* puts "In child" * puts "In child"
* end * end
* end * end
* *
* *
* c = Child.new * c = Child.new
* c.hello * c.hello
* *
* *
* class Child * class Child
* remove_method :hello # remove from child, still in parent * remove_method :hello # remove from child, still in parent
* end * end
* c.hello * c.hello
* *
* *
* class Child * class Child
* undef_method :hello # prevent any calls to 'hello' * undef_method :hello # prevent any calls to 'hello'
* end * end
* c.hello * c.hello
* *
* <em>produces:</em> * <em>produces:</em>
* *
* In child * In child
* In parent * In parent
* prog.rb:23: undefined method `hello' for #<Child:0x401b3bb4> (NoMethodError) * prog.rb:23: undefined method `hello' for #<Child:0x401b3bb4> (NoMethodError)
@ -563,7 +563,7 @@ rb_alias(VALUE klass, ID name, ID def)
} }
orig_fbody->nd_cnt++; orig_fbody->nd_cnt++;
if (st_lookup(RCLASS(klass)->m_tbl, name, (st_data_t *) & node)) { if (st_lookup(RCLASS(klass)->m_tbl, name, (st_data_t *) & node)) {
if (node) { if (node) {
if (RTEST(ruby_verbose) && node->nd_cnt == 0 && node->nd_body) { if (RTEST(ruby_verbose) && node->nd_cnt == 0 && node->nd_body) {
@ -594,10 +594,10 @@ rb_alias(VALUE klass, ID name, ID def)
/* /*
* call-seq: * call-seq:
* alias_method(new_name, old_name) => self * alias_method(new_name, old_name) => self
* *
* Makes <i>new_name</i> a new copy of the method <i>old_name</i>. This can * Makes <i>new_name</i> a new copy of the method <i>old_name</i>. This can
* be used to retain access to methods that are overridden. * be used to retain access to methods that are overridden.
* *
* module Mod * module Mod
* alias_method :orig_exit, :exit * alias_method :orig_exit, :exit
* def exit(code=0) * def exit(code=0)
@ -607,9 +607,9 @@ rb_alias(VALUE klass, ID name, ID def)
* end * end
* include Mod * include Mod
* exit(99) * exit(99)
* *
* <em>produces:</em> * <em>produces:</em>
* *
* Exiting with code 99 * Exiting with code 99
*/ */

View File

@ -1225,7 +1225,7 @@ flo_ceil(VALUE num)
* *
* Rounds <i>flt</i> to a given precision in decimal digits (default 0 digits). * Rounds <i>flt</i> to a given precision in decimal digits (default 0 digits).
* Precision may be negative. Returns a a floating point number when ndigits * Precision may be negative. Returns a a floating point number when ndigits
* is more than one. * is more than one.
* *
* 1.5.round #=> 2 * 1.5.round #=> 2
* (-1.5).round #=> -2 * (-1.5).round #=> -2
@ -1624,7 +1624,7 @@ rb_num2ll(VALUE val)
if (FIXNUM_P(val)) return (LONG_LONG)FIX2LONG(val); if (FIXNUM_P(val)) return (LONG_LONG)FIX2LONG(val);
switch (TYPE(val)) { switch (TYPE(val)) {
case T_FLOAT: case T_FLOAT:
if (RFLOAT(val)->value <= (double)LLONG_MAX if (RFLOAT(val)->value <= (double)LLONG_MAX
&& RFLOAT(val)->value >= (double)LLONG_MIN) { && RFLOAT(val)->value >= (double)LLONG_MIN) {
return (LONG_LONG)(RFLOAT(val)->value); return (LONG_LONG)(RFLOAT(val)->value);
@ -1638,21 +1638,21 @@ rb_num2ll(VALUE val)
rb_raise(rb_eRangeError, "float %s out of range of long long", buf); rb_raise(rb_eRangeError, "float %s out of range of long long", buf);
} }
case T_BIGNUM: case T_BIGNUM:
return rb_big2ll(val); return rb_big2ll(val);
case T_STRING: case T_STRING:
rb_raise(rb_eTypeError, "no implicit conversion from string"); rb_raise(rb_eTypeError, "no implicit conversion from string");
return Qnil; /* not reached */ return Qnil; /* not reached */
case T_TRUE: case T_TRUE:
case T_FALSE: case T_FALSE:
rb_raise(rb_eTypeError, "no implicit conversion from boolean"); rb_raise(rb_eTypeError, "no implicit conversion from boolean");
return Qnil; /* not reached */ return Qnil; /* not reached */
default: default:
val = rb_to_int(val); val = rb_to_int(val);
return NUM2LL(val); return NUM2LL(val);
} }
} }
@ -1867,14 +1867,14 @@ static VALUE
rb_int_induced_from(VALUE klass, VALUE x) rb_int_induced_from(VALUE klass, VALUE x)
{ {
switch (TYPE(x)) { switch (TYPE(x)) {
case T_FIXNUM: case T_FIXNUM:
case T_BIGNUM: case T_BIGNUM:
return x; return x;
case T_FLOAT: case T_FLOAT:
return rb_funcall(x, id_to_i, 0); return rb_funcall(x, id_to_i, 0);
default: default:
rb_raise(rb_eTypeError, "failed to convert %s into Integer", rb_raise(rb_eTypeError, "failed to convert %s into Integer",
rb_obj_classname(x)); rb_obj_classname(x));
} }
} }
@ -1889,14 +1889,14 @@ static VALUE
rb_flo_induced_from(VALUE klass, VALUE x) rb_flo_induced_from(VALUE klass, VALUE x)
{ {
switch (TYPE(x)) { switch (TYPE(x)) {
case T_FIXNUM: case T_FIXNUM:
case T_BIGNUM: case T_BIGNUM:
return rb_funcall(x, rb_intern("to_f"), 0); return rb_funcall(x, rb_intern("to_f"), 0);
case T_FLOAT: case T_FLOAT:
return x; return x;
default: default:
rb_raise(rb_eTypeError, "failed to convert %s into Float", rb_raise(rb_eTypeError, "failed to convert %s into Float",
rb_obj_classname(x)); rb_obj_classname(x));
} }
} }

50
pack.c
View File

@ -344,13 +344,13 @@ num2i32(VALUE x)
} }
#if SIZEOF_LONG == SIZE32 #if SIZEOF_LONG == SIZE32
# define EXTEND32(x) # define EXTEND32(x)
#else #else
/* invariant in modulo 1<<31 */ /* invariant in modulo 1<<31 */
# define EXTEND32(x) do { if (!natint) {(x) = (((1L<<31)-1-(x))^~(~0L<<31));}} while(0) # define EXTEND32(x) do { if (!natint) {(x) = (((1L<<31)-1-(x))^~(~0L<<31));}} while(0)
#endif #endif
#if SIZEOF_SHORT == SIZE16 #if SIZEOF_SHORT == SIZE16
# define EXTEND16(x) # define EXTEND16(x)
#else #else
# define EXTEND16(x) do { if (!natint) {(x) = (short)(((1<<15)-1-(x))^~(~0<<15));}} while(0) # define EXTEND16(x) do { if (!natint) {(x) = (short)(((1<<15)-1-(x))^~(~0<<15));}} while(0)
#endif #endif
@ -371,7 +371,7 @@ static unsigned long utf8_to_uv(const char*,long*);
/* /*
* call-seq: * call-seq:
* arr.pack ( aTemplateString ) -> aBinaryString * arr.pack ( aTemplateString ) -> aBinaryString
* *
* Packs the contents of <i>arr</i> into a binary sequence according to * Packs the contents of <i>arr</i> into a binary sequence according to
* the directives in <i>aTemplateString</i> (see the table below) * the directives in <i>aTemplateString</i> (see the table below)
* Directives ``A,'' ``a,'' and ``Z'' may be followed by a count, * Directives ``A,'' ``a,'' and ``Z'' may be followed by a count,
@ -384,13 +384,13 @@ static unsigned long utf8_to_uv(const char*,long*);
* platform's native size for the specified type; otherwise, they use a * platform's native size for the specified type; otherwise, they use a
* platform-independent size. Spaces are ignored in the template * platform-independent size. Spaces are ignored in the template
* string. See also <code>String#unpack</code>. * string. See also <code>String#unpack</code>.
* *
* a = [ "a", "b", "c" ] * a = [ "a", "b", "c" ]
* n = [ 65, 66, 67 ] * n = [ 65, 66, 67 ]
* a.pack("A3A3A3") #=> "a b c " * a.pack("A3A3A3") #=> "a b c "
* a.pack("a3a3a3") #=> "a\000\000b\000\000c\000\000" * a.pack("a3a3a3") #=> "a\000\000b\000\000c\000\000"
* n.pack("ccc") #=> "ABC" * n.pack("ccc") #=> "ABC"
* *
* Directives for +pack+. * Directives for +pack+.
* *
* Directive Meaning * Directive Meaning
@ -1101,16 +1101,16 @@ static inline int
hex2num(char c) hex2num(char c)
{ {
switch (c) { switch (c) {
case '0': case '1': case '2': case '3': case '4': case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9': case '5': case '6': case '7': case '8': case '9':
return c - '0'; return c - '0';
case 'a': case 'b': case 'c': case 'a': case 'b': case 'c':
case 'd': case 'e': case 'f': case 'd': case 'e': case 'f':
return c - 'a' + 10; return c - 'a' + 10;
case 'A': case 'B': case 'C': case 'A': case 'B': case 'C':
case 'D': case 'E': case 'F': case 'D': case 'E': case 'F':
return c - 'A' + 10; return c - 'A' + 10;
default: default:
return -1; return -1;
} }
} }
@ -1145,11 +1145,11 @@ infected_str_new(const char *ptr, long len, VALUE str)
OBJ_INFECT(s, str); OBJ_INFECT(s, str);
return s; return s;
} }
/* /*
* call-seq: * call-seq:
* str.unpack(format) => anArray * str.unpack(format) => anArray
* *
* Decodes <i>str</i> (which may contain binary data) according to the * Decodes <i>str</i> (which may contain binary data) according to the
* format string, returning an array of each value extracted. The * format string, returning an array of each value extracted. The
* format string consists of a sequence of single-character directives, * format string consists of a sequence of single-character directives,
@ -1162,7 +1162,7 @@ infected_str_new(const char *ptr, long len, VALUE str)
* platform's native size for the specified type; otherwise, it uses a * platform's native size for the specified type; otherwise, it uses a
* platform-independent consistent size. Spaces are ignored in the * platform-independent consistent size. Spaces are ignored in the
* format string. See also <code>Array#pack</code>. * format string. See also <code>Array#pack</code>.
* *
* "abc \0\0abc \0\0".unpack('A6Z6') #=> ["abc", "abc "] * "abc \0\0abc \0\0".unpack('A6Z6') #=> ["abc", "abc "]
* "abc \0\0".unpack('a3a3') #=> ["abc", " \000\000"] * "abc \0\0".unpack('a3a3') #=> ["abc", " \000\000"]
* "abc \0abc \0".unpack('Z*Z*') #=> ["abc ", "abc "] * "abc \0abc \0".unpack('Z*Z*') #=> ["abc ", "abc "]
@ -1174,7 +1174,7 @@ infected_str_new(const char *ptr, long len, VALUE str)
* *
* This table summarizes the various formats and the Ruby classes * This table summarizes the various formats and the Ruby classes
* returned by each. * returned by each.
* *
* Format | Returns | Function * Format | Returns | Function
* -------+---------+----------------------------------------- * -------+---------+-----------------------------------------
* A | String | with trailing nulls and spaces removed * A | String | with trailing nulls and spaces removed
@ -1246,17 +1246,17 @@ infected_str_new(const char *ptr, long len, VALUE str)
* p | String | treat sizeof(char *) characters as a * p | String | treat sizeof(char *) characters as a
* | | pointer to a null-terminated string * | | pointer to a null-terminated string
* -------+---------+----------------------------------------- * -------+---------+-----------------------------------------
* Q | Integer | treat 8 characters as an unsigned * Q | Integer | treat 8 characters as an unsigned
* | | quad word (64 bits) * | | quad word (64 bits)
* -------+---------+----------------------------------------- * -------+---------+-----------------------------------------
* q | Integer | treat 8 characters as a signed * q | Integer | treat 8 characters as a signed
* | | quad word (64 bits) * | | quad word (64 bits)
* -------+---------+----------------------------------------- * -------+---------+-----------------------------------------
* S | Fixnum | treat two (different if _ used) * S | Fixnum | treat two (different if _ used)
* | | successive characters as an unsigned * | | successive characters as an unsigned
* | | short in native byte order * | | short in native byte order
* -------+---------+----------------------------------------- * -------+---------+-----------------------------------------
* s | Fixnum | Treat two (different if _ used) * s | Fixnum | Treat two (different if _ used)
* | | successive characters as a signed short * | | successive characters as a signed short
* | | in native byte order * | | in native byte order
* -------+---------+----------------------------------------- * -------+---------+-----------------------------------------
@ -1279,7 +1279,7 @@ infected_str_new(const char *ptr, long len, VALUE str)
* Z | String | with trailing nulls removed * Z | String | with trailing nulls removed
* | | upto first null with * * | | upto first null with *
* -------+---------+----------------------------------------- * -------+---------+-----------------------------------------
* @ | --- | skip to the offset given by the * @ | --- | skip to the offset given by the
* | | length argument * | | length argument
* -------+---------+----------------------------------------- * -------+---------+-----------------------------------------
*/ */
@ -1574,7 +1574,7 @@ pack_unpack(VALUE str, VALUE fmt)
} }
PACK_ITEM_ADJUST(); PACK_ITEM_ADJUST();
break; break;
case 'Q': case 'Q':
PACK_LENGTH_ADJUST_SIZE(QUAD_SIZE); PACK_LENGTH_ADJUST_SIZE(QUAD_SIZE);
while (len-- > 0) { while (len-- > 0) {
char *tmp = (char*)s; char *tmp = (char*)s;
@ -1652,7 +1652,7 @@ pack_unpack(VALUE str, VALUE fmt)
} }
PACK_ITEM_ADJUST(); PACK_ITEM_ADJUST();
break; break;
case 'E': case 'E':
PACK_LENGTH_ADJUST(double,sizeof(double)); PACK_LENGTH_ADJUST(double,sizeof(double));
while (len-- > 0) { while (len-- > 0) {
@ -1666,7 +1666,7 @@ pack_unpack(VALUE str, VALUE fmt)
} }
PACK_ITEM_ADJUST(); PACK_ITEM_ADJUST();
break; break;
case 'D': case 'D':
case 'd': case 'd':
PACK_LENGTH_ADJUST(double,sizeof(double)); PACK_LENGTH_ADJUST(double,sizeof(double));
@ -1692,7 +1692,7 @@ pack_unpack(VALUE str, VALUE fmt)
} }
PACK_ITEM_ADJUST(); PACK_ITEM_ADJUST();
break; break;
case 'G': case 'G':
PACK_LENGTH_ADJUST(double,sizeof(double)); PACK_LENGTH_ADJUST(double,sizeof(double));
while (len-- > 0) { while (len-- > 0) {
@ -1706,7 +1706,7 @@ pack_unpack(VALUE str, VALUE fmt)
} }
PACK_ITEM_ADJUST(); PACK_ITEM_ADJUST();
break; break;
case 'U': case 'U':
if (len > send - s) len = send - s; if (len > send - s) len = send - s;
while (len > 0 && s < send) { while (len > 0 && s < send) {

32
parse.y
View File

@ -171,7 +171,7 @@ vtable_add(struct vtable *tbl, ID id)
rb_bug("vtable_add: vtable is not allocated (%p)", tbl); rb_bug("vtable_add: vtable is not allocated (%p)", tbl);
} }
if (VTBL_DEBUG) printf("vtable_add: %p, %s\n", tbl, rb_id2name(id)); if (VTBL_DEBUG) printf("vtable_add: %p, %s\n", tbl, rb_id2name(id));
if (tbl->pos == tbl->capa) { if (tbl->pos == tbl->capa) {
tbl->capa = tbl->capa * 2; tbl->capa = tbl->capa * 2;
REALLOC_N(tbl->tbl, ID, tbl->capa); REALLOC_N(tbl->tbl, ID, tbl->capa);
@ -4055,7 +4055,7 @@ f_norm_arg : tCONSTANT
{ {
/*%%%*/ /*%%%*/
yyerror("formal argument cannot be a constant"); yyerror("formal argument cannot be a constant");
$$ = 0; $$ = 0;
/*% /*%
$$ = dispatch1(param_error, $1); $$ = dispatch1(param_error, $1);
%*/ %*/
@ -4064,7 +4064,7 @@ f_norm_arg : tCONSTANT
{ {
/*%%%*/ /*%%%*/
yyerror("formal argument cannot be an instance variable"); yyerror("formal argument cannot be an instance variable");
$$ = 0; $$ = 0;
/*% /*%
$$ = dispatch1(param_error, $1); $$ = dispatch1(param_error, $1);
%*/ %*/
@ -4073,7 +4073,7 @@ f_norm_arg : tCONSTANT
{ {
/*%%%*/ /*%%%*/
yyerror("formal argument cannot be a global variable"); yyerror("formal argument cannot be a global variable");
$$ = 0; $$ = 0;
/*% /*%
$$ = dispatch1(param_error, $1); $$ = dispatch1(param_error, $1);
%*/ %*/
@ -4082,7 +4082,7 @@ f_norm_arg : tCONSTANT
{ {
/*%%%*/ /*%%%*/
yyerror("formal argument cannot be a class variable"); yyerror("formal argument cannot be a class variable");
$$ = 0; $$ = 0;
/*% /*%
$$ = dispatch1(param_error, $1); $$ = dispatch1(param_error, $1);
%*/ %*/
@ -4642,7 +4642,7 @@ rb_parser_compile_string(volatile VALUE vparser, const char *f, VALUE s, int lin
struct parser_params *parser; struct parser_params *parser;
NODE *node; NODE *node;
volatile VALUE tmp; volatile VALUE tmp;
Data_Get_Struct(vparser, struct parser_params, parser); Data_Get_Struct(vparser, struct parser_params, parser);
lex_gets = lex_get_str; lex_gets = lex_get_str;
lex_gets_ptr = 0; lex_gets_ptr = 0;
@ -4688,7 +4688,7 @@ rb_parser_compile_file(volatile VALUE vparser, const char *f, VALUE file, int st
struct parser_params *parser; struct parser_params *parser;
volatile VALUE tmp; volatile VALUE tmp;
NODE *node; NODE *node;
Data_Get_Struct(vparser, struct parser_params, parser); Data_Get_Struct(vparser, struct parser_params, parser);
lex_gets = lex_io_gets; lex_gets = lex_io_gets;
lex_input = file; lex_input = file;
@ -5489,7 +5489,7 @@ parser_pragma(struct parser_params *parser, const char *str, int len)
if (!(end = pragma_marker(beg, str + len - beg))) return Qfalse; if (!(end = pragma_marker(beg, str + len - beg))) return Qfalse;
str = beg; str = beg;
len = end - beg - 3; len = end - beg - 3;
/* %r"([^\\s\'\":;]+)\\s*:\\s*(\"(?:\\\\.|[^\"])*\"|[^\"\\s;]+)[\\s;]*" */ /* %r"([^\\s\'\":;]+)\\s*:\\s*(\"(?:\\\\.|[^\"])*\"|[^\"\\s;]+)[\\s;]*" */
while (len > 0) { while (len > 0) {
#ifndef RIPPER #ifndef RIPPER
@ -6314,7 +6314,7 @@ parser_yylex(struct parser_params *parser)
lex_state = EXPR_DOT; lex_state = EXPR_DOT;
return tCOLON2; return tCOLON2;
} }
if (lex_state == EXPR_END || if (lex_state == EXPR_END ||
lex_state == EXPR_ENDARG || ISSPACE(c)) { lex_state == EXPR_ENDARG || ISSPACE(c)) {
pushback(c); pushback(c);
lex_state = EXPR_BEG; lex_state = EXPR_BEG;
@ -7915,7 +7915,7 @@ arg_dup_check(ID vid, VALUE m, VALUE list, NODE *node)
ruby_sourceline = nd_line(node); ruby_sourceline = nd_line(node);
return 1; return 1;
} }
rb_ary_push(list, sym); rb_ary_push(list, sym);
return 0; return 0;
} }
@ -8114,7 +8114,7 @@ rb_parser_append_print(NODE *node)
NODE *prelude = 0; NODE *prelude = 0;
NODE *scope = node; NODE *scope = node;
node = node->nd_body; node = node->nd_body;
if (node && (nd_type(node) == NODE_PRELUDE)) { if (node && (nd_type(node) == NODE_PRELUDE)) {
prelude = node; prelude = node;
node = node->nd_body; node = node->nd_body;
@ -8523,15 +8523,15 @@ symbols_i(VALUE sym, ID value, VALUE ary)
/* /*
* call-seq: * call-seq:
* Symbol.all_symbols => array * Symbol.all_symbols => array
* *
* Returns an array of all the symbols currently in Ruby's symbol * Returns an array of all the symbols currently in Ruby's symbol
* table. * table.
* *
* Symbol.all_symbols.size #=> 903 * Symbol.all_symbols.size #=> 903
* Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink, * Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink,
* :chown, :EOFError, :$;, :String, * :chown, :EOFError, :$;, :String,
* :LOCK_SH, :"setuid?", :$<, * :LOCK_SH, :"setuid?", :$<,
* :default_proc, :compact, :extend, * :default_proc, :compact, :extend,
* :Tms, :getwd, :$=, :ThreadGroup, * :Tms, :getwd, :$=, :ThreadGroup,
* :wait2, :$>] * :wait2, :$>]
*/ */

273
re.c
View File

@ -172,115 +172,118 @@ rb_memsearch(const void *x0, long m, const void *y0, long n)
static int reg_kcode = DEFAULT_KCODE; static int reg_kcode = DEFAULT_KCODE;
static int char_to_option(int c) static int
char_to_option(int c)
{ {
int val; int val;
switch (c) { switch (c) {
case 'i': case 'i':
val = ONIG_OPTION_IGNORECASE; val = ONIG_OPTION_IGNORECASE;
break; break;
case 'x': case 'x':
val = ONIG_OPTION_EXTEND; val = ONIG_OPTION_EXTEND;
break; break;
case 'm': case 'm':
val = ONIG_OPTION_MULTILINE; val = ONIG_OPTION_MULTILINE;
break; break;
default: default:
val = 0; val = 0;
break; break;
} }
return val; return val;
} }
extern int rb_char_to_option_kcode(int c, int *option, int *kcode) extern int
rb_char_to_option_kcode(int c, int *option, int *kcode)
{ {
*option = 0; *option = 0;
switch (c) { switch (c) {
case 'n': case 'n':
*kcode = ARG_KCODE_NONE; *kcode = ARG_KCODE_NONE;
break; break;
case 'e': case 'e':
*kcode = ARG_KCODE_EUC; *kcode = ARG_KCODE_EUC;
break; break;
case 's': case 's':
*kcode = ARG_KCODE_SJIS; *kcode = ARG_KCODE_SJIS;
break; break;
case 'u': case 'u':
*kcode = ARG_KCODE_UTF8; *kcode = ARG_KCODE_UTF8;
break; break;
default: default:
*kcode = 0; *kcode = 0;
*option = char_to_option(c); *option = char_to_option(c);
break; break;
} }
return ((*kcode == 0 && *option == 0) ? 0 : 1); return ((*kcode == 0 && *option == 0) ? 0 : 1);
} }
static int char_to_arg_kcode(int c) static int
char_to_arg_kcode(int c)
{ {
int kcode, option; int kcode, option;
if (ISUPPER(c)) c = tolower(c); if (ISUPPER(c)) c = tolower(c);
(void )rb_char_to_option_kcode(c, &option, &kcode); (void )rb_char_to_option_kcode(c, &option, &kcode);
return kcode; return kcode;
} }
static int static int
kcode_to_arg_value(unsigned int kcode) kcode_to_arg_value(unsigned int kcode)
{ {
switch (kcode & KCODE_MASK) { switch (kcode & KCODE_MASK) {
case KCODE_NONE: case KCODE_NONE:
return ARG_KCODE_NONE; return ARG_KCODE_NONE;
case KCODE_EUC: case KCODE_EUC:
return ARG_KCODE_EUC; return ARG_KCODE_EUC;
case KCODE_SJIS: case KCODE_SJIS:
return ARG_KCODE_SJIS; return ARG_KCODE_SJIS;
case KCODE_UTF8: case KCODE_UTF8:
return ARG_KCODE_UTF8; return ARG_KCODE_UTF8;
default: default:
return 0; return 0;
} }
} }
static void static void
set_re_kcode_by_option(struct RRegexp *re, int options) set_re_kcode_by_option(struct RRegexp *re, int options)
{ {
switch (options & ARG_KCODE_MASK) { switch (options & ARG_KCODE_MASK) {
case ARG_KCODE_NONE: case ARG_KCODE_NONE:
FL_UNSET(re, KCODE_MASK); FL_UNSET(re, KCODE_MASK);
FL_SET(re, KCODE_FIXED); FL_SET(re, KCODE_FIXED);
break; break;
case ARG_KCODE_EUC: case ARG_KCODE_EUC:
FL_UNSET(re, KCODE_MASK); FL_UNSET(re, KCODE_MASK);
FL_SET(re, KCODE_EUC); FL_SET(re, KCODE_EUC);
FL_SET(re, KCODE_FIXED); FL_SET(re, KCODE_FIXED);
break; break;
case ARG_KCODE_SJIS: case ARG_KCODE_SJIS:
FL_UNSET(re, KCODE_MASK); FL_UNSET(re, KCODE_MASK);
FL_SET(re, KCODE_SJIS); FL_SET(re, KCODE_SJIS);
FL_SET(re, KCODE_FIXED); FL_SET(re, KCODE_FIXED);
break; break;
case ARG_KCODE_UTF8: case ARG_KCODE_UTF8:
FL_UNSET(re, KCODE_MASK); FL_UNSET(re, KCODE_MASK);
FL_SET(re, KCODE_UTF8); FL_SET(re, KCODE_UTF8);
FL_SET(re, KCODE_FIXED); FL_SET(re, KCODE_FIXED);
break; break;
case 0: case 0:
default: default:
FL_SET(re, reg_kcode); FL_SET(re, reg_kcode);
break; break;
} }
} }
static int static int
re_to_kcode_arg_value(VALUE re) re_to_kcode_arg_value(VALUE re)
{ {
return kcode_to_arg_value(RBASIC(re)->flags); return kcode_to_arg_value(RBASIC(re)->flags);
} }
static int curr_kcode; static int curr_kcode;
@ -444,9 +447,9 @@ rb_reg_desc(const char *s, long len, VALUE re)
/* /*
* call-seq: * call-seq:
* rxp.source => str * rxp.source => str
* *
* Returns the original string of the pattern. * Returns the original string of the pattern.
* *
* /ab+c/ix.source #=> "ab+c" * /ab+c/ix.source #=> "ab+c"
*/ */
@ -483,7 +486,7 @@ rb_reg_inspect(VALUE re)
/* /*
* call-seq: * call-seq:
* rxp.to_s => str * rxp.to_s => str
* *
* Returns a string containing the regular expression and its options (using the * Returns a string containing the regular expression and its options (using the
* <code>(?xxx:yyy)</code> notation. This string can be fed back in to * <code>(?xxx:yyy)</code> notation. This string can be fed back in to
* <code>Regexp::new</code> to a regular expression with the same semantics as * <code>Regexp::new</code> to a regular expression with the same semantics as
@ -491,7 +494,7 @@ rb_reg_inspect(VALUE re)
* comparing the two, as the source of the regular expression itself may * comparing the two, as the source of the regular expression itself may
* differ, as the example shows). <code>Regexp#inspect</code> produces a * differ, as the example shows). <code>Regexp#inspect</code> produces a
* generally more readable version of <i>rxp</i>. * generally more readable version of <i>rxp</i>.
* *
* r1 = /ab+c/ix #=> /ab+c/ix * r1 = /ab+c/ix #=> /ab+c/ix
* s1 = r1.to_s #=> "(?ix-m:ab+c)" * s1 = r1.to_s #=> "(?ix-m:ab+c)"
* r2 = Regexp.new(s1) #=> /(?ix-m:ab+c)/ * r2 = Regexp.new(s1) #=> /(?ix-m:ab+c)/
@ -606,7 +609,7 @@ rb_reg_raise(const char *s, long len, const char *err, VALUE re, int ce)
/* /*
* call-seq: * call-seq:
* rxp.casefold? => true or false * rxp.casefold? => true or false
* *
* Returns the value of the case-insensitive flag. * Returns the value of the case-insensitive flag.
*/ */
@ -622,22 +625,22 @@ rb_reg_casefold_p(VALUE re)
/* /*
* call-seq: * call-seq:
* rxp.options => fixnum * rxp.options => fixnum
* *
* Returns the set of bits corresponding to the options used when creating this * Returns the set of bits corresponding to the options used when creating this
* Regexp (see <code>Regexp::new</code> for details. Note that additional bits * Regexp (see <code>Regexp::new</code> for details. Note that additional bits
* may be set in the returned options: these are used internally by the regular * may be set in the returned options: these are used internally by the regular
* expression code. These extra bits are ignored if the options are passed to * expression code. These extra bits are ignored if the options are passed to
* <code>Regexp::new</code>. * <code>Regexp::new</code>.
* *
* Regexp::IGNORECASE #=> 1 * Regexp::IGNORECASE #=> 1
* Regexp::EXTENDED #=> 2 * Regexp::EXTENDED #=> 2
* Regexp::MULTILINE #=> 4 * Regexp::MULTILINE #=> 4
* *
* /cat/.options #=> 128 * /cat/.options #=> 128
* /cat/ix.options #=> 131 * /cat/ix.options #=> 131
* Regexp.new('cat', true).options #=> 129 * Regexp.new('cat', true).options #=> 129
* Regexp.new('cat', 0, 's').options #=> 384 * Regexp.new('cat', 0, 's').options #=> 384
* *
* r = /cat/ix * r = /cat/ix
* Regexp.new(r.source, r.options) #=> /cat/ix * Regexp.new(r.source, r.options) #=> /cat/ix
*/ */
@ -653,7 +656,7 @@ rb_reg_options_m(VALUE re)
/* /*
* call-seq: * call-seq:
* rxp.kcode => str * rxp.kcode => str
* *
* Returns the character set code for the regexp. * Returns the character set code for the regexp.
*/ */
@ -769,9 +772,9 @@ match_init_copy(VALUE obj, VALUE orig)
* call-seq: * call-seq:
* mtch.length => integer * mtch.length => integer
* mtch.size => integer * mtch.size => integer
* *
* Returns the number of elements in the match array. * Returns the number of elements in the match array.
* *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m.length #=> 5 * m.length #=> 5
* m.size #=> 5 * m.size #=> 5
@ -787,10 +790,10 @@ match_size(VALUE match)
/* /*
* call-seq: * call-seq:
* mtch.offset(n) => array * mtch.offset(n) => array
* *
* Returns a two-element array containing the beginning and ending offsets of * Returns a two-element array containing the beginning and ending offsets of
* the <em>n</em>th match. * the <em>n</em>th match.
* *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m.offset(0) #=> [1, 7] * m.offset(0) #=> [1, 7]
* m.offset(4) #=> [6, 7] * m.offset(4) #=> [6, 7]
@ -815,10 +818,10 @@ match_offset(VALUE match, VALUE n)
/* /*
* call-seq: * call-seq:
* mtch.begin(n) => integer * mtch.begin(n) => integer
* *
* Returns the offset of the start of the <em>n</em>th element of the match * Returns the offset of the start of the <em>n</em>th element of the match
* array in the string. * array in the string.
* *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m.begin(0) #=> 1 * m.begin(0) #=> 1
* m.begin(2) #=> 2 * m.begin(2) #=> 2
@ -842,10 +845,10 @@ match_begin(VALUE match, VALUE n)
/* /*
* call-seq: * call-seq:
* mtch.end(n) => integer * mtch.end(n) => integer
* *
* Returns the offset of the character immediately following the end of the * Returns the offset of the character immediately following the end of the
* <em>n</em>th element of the match array in the string. * <em>n</em>th element of the match array in the string.
* *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m.end(0) #=> 7 * m.end(0) #=> 7
* m.end(2) #=> 3 * m.end(2) #=> 3
@ -1088,10 +1091,10 @@ rb_reg_last_match(VALUE match)
/* /*
* call-seq: * call-seq:
* mtch.pre_match => str * mtch.pre_match => str
* *
* Returns the portion of the original string before the current match. * Returns the portion of the original string before the current match.
* Equivalent to the special variable <code>$`</code>. * Equivalent to the special variable <code>$`</code>.
* *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m.pre_match #=> "T" * m.pre_match #=> "T"
*/ */
@ -1112,10 +1115,10 @@ rb_reg_match_pre(VALUE match)
/* /*
* call-seq: * call-seq:
* mtch.post_match => str * mtch.post_match => str
* *
* Returns the portion of the original string after the current match. * Returns the portion of the original string after the current match.
* Equivalent to the special variable <code>$'</code>. * Equivalent to the special variable <code>$'</code>.
* *
* m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie") * m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
* m.post_match #=> ": The Movie" * m.post_match #=> ": The Movie"
*/ */
@ -1203,18 +1206,18 @@ match_array(VALUE match, int start)
/* /*
* call-seq: * call-seq:
* mtch.to_a => anArray * mtch.to_a => anArray
* *
* Returns the array of matches. * Returns the array of matches.
* *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m.to_a #=> ["HX1138", "H", "X", "113", "8"] * m.to_a #=> ["HX1138", "H", "X", "113", "8"]
* *
* Because <code>to_a</code> is called when expanding * Because <code>to_a</code> is called when expanding
* <code>*</code><em>variable</em>, there's a useful assignment * <code>*</code><em>variable</em>, there's a useful assignment
* shortcut for extracting matched fields. This is slightly slower than * shortcut for extracting matched fields. This is slightly slower than
* accessing the fields directly (as an intermediate array is * accessing the fields directly (as an intermediate array is
* generated). * generated).
* *
* all,f1,f2,f3 = *(/(.)(.)(\d+)(\d)/.match("THX1138.")) * all,f1,f2,f3 = *(/(.)(.)(\d+)(\d)/.match("THX1138."))
* all #=> "HX1138" * all #=> "HX1138"
* f1 #=> "H" * f1 #=> "H"
@ -1270,13 +1273,13 @@ name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name
* mtch[start, length] => array * mtch[start, length] => array
* mtch[range] => array * mtch[range] => array
* mtch[name] => str or nil * mtch[name] => str or nil
* *
* Match Reference---<code>MatchData</code> acts as an array, and may be * Match Reference---<code>MatchData</code> acts as an array, and may be
* accessed using the normal array indexing techniques. <i>mtch</i>[0] is * accessed using the normal array indexing techniques. <i>mtch</i>[0] is
* equivalent to the special variable <code>$&</code>, and returns the entire * equivalent to the special variable <code>$&</code>, and returns the entire
* matched string. <i>mtch</i>[1], <i>mtch</i>[2], and so on return the values * matched string. <i>mtch</i>[1], <i>mtch</i>[2], and so on return the values
* of the matched backreferences (portions of the pattern between parentheses). * of the matched backreferences (portions of the pattern between parentheses).
* *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m[0] #=> "HX1138" * m[0] #=> "HX1138"
* m[1, 2] #=> ["H", "X"] * m[1, 2] #=> ["H", "X"]
@ -1340,10 +1343,10 @@ match_entry(VALUE match, long n)
if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4) if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify regexp"); rb_raise(rb_eSecurityError, "Insecure: can't modify regexp");
* mtch.select([index]*) => array * mtch.select([index]*) => array
* *
* Uses each <i>index</i> to access the matching values, returning an array of * Uses each <i>index</i> to access the matching values, returning an array of
* the corresponding matches. * the corresponding matches.
* *
* m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie") * m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
* m.to_a #=> ["HX1138", "H", "X", "113", "8"] * m.to_a #=> ["HX1138", "H", "X", "113", "8"]
* m.select(0, 2, -2) #=> ["HX1138", "X", "113"] * m.select(0, 2, -2) #=> ["HX1138", "X", "113"]
@ -1359,10 +1362,10 @@ match_values_at(int argc, VALUE *argv, VALUE match)
/* /*
* call-seq: * call-seq:
* mtch.select([index]*) => array * mtch.select([index]*) => array
* *
* Uses each <i>index</i> to access the matching values, returning an * Uses each <i>index</i> to access the matching values, returning an
* array of the corresponding matches. * array of the corresponding matches.
* *
* m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie") * m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
* m.to_a #=> ["HX1138", "H", "X", "113", "8"] * m.to_a #=> ["HX1138", "H", "X", "113", "8"]
* m.select(0, 2, -2) #=> ["HX1138", "X", "113"] * m.select(0, 2, -2) #=> ["HX1138", "X", "113"]
@ -1396,9 +1399,9 @@ match_select(int argc, VALUE *argv, VALUE match)
/* /*
* call-seq: * call-seq:
* mtch.to_s => str * mtch.to_s => str
* *
* Returns the entire matched string. * Returns the entire matched string.
* *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m.to_s #=> "HX1138" * m.to_s #=> "HX1138"
*/ */
@ -1418,9 +1421,9 @@ match_to_s(VALUE match)
/* /*
* call-seq: * call-seq:
* mtch.string => str * mtch.string => str
* *
* Returns a frozen copy of the string passed in to <code>match</code>. * Returns a frozen copy of the string passed in to <code>match</code>.
* *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m.string #=> "THX1138." * m.string #=> "THX1138."
*/ */
@ -1560,11 +1563,11 @@ rb_reg_hash(VALUE re)
* call-seq: * call-seq:
* rxp == other_rxp => true or false * rxp == other_rxp => true or false
* rxp.eql?(other_rxp) => true or false * rxp.eql?(other_rxp) => true or false
* *
* Equality---Two regexps are equal if their patterns are identical, they have * Equality---Two regexps are equal if their patterns are identical, they have
* the same character set code, and their <code>casefold?</code> values are the * the same character set code, and their <code>casefold?</code> values are the
* same. * same.
* *
* /abc/ == /abc/x #=> false * /abc/ == /abc/x #=> false
* /abc/ == /abc/i #=> false * /abc/ == /abc/i #=> false
* /abc/u == /abc/n #=> false * /abc/u == /abc/n #=> false
@ -1628,7 +1631,7 @@ rb_reg_match_pos(VALUE re, VALUE str, long pos)
/* /*
* call-seq: * call-seq:
* rxp =~ str => integer or nil * rxp =~ str => integer or nil
* *
* Match---Matches <i>rxp</i> against <i>str</i>. * Match---Matches <i>rxp</i> against <i>str</i>.
* *
* /at/ =~ "input data" #=> 7 * /at/ =~ "input data" #=> 7
@ -1643,18 +1646,18 @@ rb_reg_match(VALUE re, VALUE str)
/* /*
* call-seq: * call-seq:
* rxp === str => true or false * rxp === str => true or false
* *
* Case Equality---Synonym for <code>Regexp#=~</code> used in case statements. * Case Equality---Synonym for <code>Regexp#=~</code> used in case statements.
* *
* a = "HELLO" * a = "HELLO"
* case a * case a
* when /^[a-z]*$/; print "Lower case\n" * when /^[a-z]*$/; print "Lower case\n"
* when /^[A-Z]*$/; print "Upper case\n" * when /^[A-Z]*$/; print "Upper case\n"
* else; print "Mixed case\n" * else; print "Mixed case\n"
* end * end
* *
* <em>produces:</em> * <em>produces:</em>
* *
* Upper case * Upper case
*/ */
@ -1679,10 +1682,10 @@ rb_reg_eqq(VALUE re, VALUE str)
/* /*
* call-seq: * call-seq:
* ~ rxp => integer or nil * ~ rxp => integer or nil
* *
* Match---Matches <i>rxp</i> against the contents of <code>$_</code>. * Match---Matches <i>rxp</i> against the contents of <code>$_</code>.
* Equivalent to <code><i>rxp</i> =~ $_</code>. * Equivalent to <code><i>rxp</i> =~ $_</code>.
* *
* $_ = "input data" * $_ = "input data"
* ~ /at/ #=> 7 * ~ /at/ #=> 7
*/ */
@ -1710,13 +1713,13 @@ rb_reg_match2(VALUE re)
* call-seq: * call-seq:
* rxp.match(str) => matchdata or nil * rxp.match(str) => matchdata or nil
* rxp.match(str,pos) => matchdata or nil * rxp.match(str,pos) => matchdata or nil
* *
* Returns a <code>MatchData</code> object describing the match, or * Returns a <code>MatchData</code> object describing the match, or
* <code>nil</code> if there was no match. This is equivalent to retrieving the * <code>nil</code> if there was no match. This is equivalent to retrieving the
* value of the special variable <code>$~</code> following a normal match. * value of the special variable <code>$~</code> following a normal match.
* If the second parameter is present, it specifies the position in the string * If the second parameter is present, it specifies the position in the string
* to begin the search. * to begin the search.
* *
* /(.)(.)(.)/.match("abc")[2] #=> "b" * /(.)(.)(.)/.match("abc")[2] #=> "b"
* /(.)(.)/.match("abc", 1)[2] #=> "c" * /(.)(.)/.match("abc", 1)[2] #=> "c"
*/ */
@ -1757,7 +1760,7 @@ rb_reg_match_m(int argc, VALUE *argv, VALUE re)
* Regexp.new(regexp) => regexp * Regexp.new(regexp) => regexp
* Regexp.compile(string [, options [, lang]]) => regexp * Regexp.compile(string [, options [, lang]]) => regexp
* Regexp.compile(regexp) => regexp * Regexp.compile(regexp) => regexp
* *
* Constructs a new regular expression from <i>pattern</i>, which can be either * Constructs a new regular expression from <i>pattern</i>, which can be either
* a <code>String</code> or a <code>Regexp</code> (in which case that regexp's * a <code>String</code> or a <code>Regexp</code> (in which case that regexp's
* options are propagated, and new options may not be specified (a change as of * options are propagated, and new options may not be specified (a change as of
@ -1768,7 +1771,7 @@ rb_reg_match_m(int argc, VALUE *argv, VALUE re)
* <code>nil</code>, the regexp will be case insensitive. The <i>lang</i> * <code>nil</code>, the regexp will be case insensitive. The <i>lang</i>
* parameter enables multibyte support for the regexp: `n', `N' = none, `e', * parameter enables multibyte support for the regexp: `n', `N' = none, `e',
* `E' = EUC, `s', `S' = SJIS, `u', `U' = UTF-8. * `E' = EUC, `s', `S' = SJIS, `u', `U' = UTF-8.
* *
* r1 = Regexp.new('^a-z+:\\s+\w+') #=> /^a-z+:\s+\w+/ * r1 = Regexp.new('^a-z+:\\s+\w+') #=> /^a-z+:\s+\w+/
* r2 = Regexp.new('cat', true) #=> /cat/i * r2 = Regexp.new('cat', true) #=> /cat/i
* r3 = Regexp.new('dog', Regexp::EXTENDED) #=> /dog/x * r3 = Regexp.new('dog', Regexp::EXTENDED) #=> /dog/x
@ -1904,12 +1907,12 @@ rb_reg_quote(VALUE str)
* call-seq: * call-seq:
* Regexp.escape(str) => a_str * Regexp.escape(str) => a_str
* Regexp.quote(str) => a_str * Regexp.quote(str) => a_str
* *
* Escapes any characters that would have special meaning in a regular * Escapes any characters that would have special meaning in a regular
* expression. Returns a new escaped string, or self if no characters are * expression. Returns a new escaped string, or self if no characters are
* escaped. For any string, * escaped. For any string,
* <code>Regexp.escape(<i>str</i>)=~<i>str</i></code> will be true. * <code>Regexp.escape(<i>str</i>)=~<i>str</i></code> will be true.
* *
* Regexp.escape('\\*?{}.') #=> \\\\\*\?\{\}\. * Regexp.escape('\\*?{}.') #=> \\\\\*\?\{\}\.
*/ */
@ -1965,12 +1968,12 @@ rb_reg_options(VALUE re)
/* /*
* call-seq: * call-seq:
* Regexp.union([pattern]*) => new_str * Regexp.union([pattern]*) => new_str
* *
* Return a <code>Regexp</code> object that is the union of the given * Return a <code>Regexp</code> object that is the union of the given
* <em>pattern</em>s, i.e., will match any of its parts. The <em>pattern</em>s * <em>pattern</em>s, i.e., will match any of its parts. The <em>pattern</em>s
* can be Regexp objects, in which case their options will be preserved, or * can be Regexp objects, in which case their options will be preserved, or
* Strings. If no arguments are given, returns <code>/(?!)/</code>. * Strings. If no arguments are given, returns <code>/(?!)/</code>.
* *
* Regexp.union #=> /(?!)/ * Regexp.union #=> /(?!)/
* Regexp.union("penzance") #=> /penzance/ * Regexp.union("penzance") #=> /penzance/
* Regexp.union("skiing", "sledding") #=> /skiing|sledding/ * Regexp.union("skiing", "sledding") #=> /skiing|sledding/
@ -2279,12 +2282,12 @@ match_setter(VALUE val)
* call-seq: * call-seq:
* Regexp.last_match => matchdata * Regexp.last_match => matchdata
* Regexp.last_match(fixnum) => str * Regexp.last_match(fixnum) => str
* *
* The first form returns the <code>MatchData</code> object generated by the * The first form returns the <code>MatchData</code> object generated by the
* last successful pattern match. Equivalent to reading the global variable * last successful pattern match. Equivalent to reading the global variable
* <code>$~</code>. The second form returns the nth field in this * <code>$~</code>. The second form returns the nth field in this
* <code>MatchData</code> object. * <code>MatchData</code> object.
* *
* /c(.)t/ =~ 'cat' #=> 0 * /c(.)t/ =~ 'cat' #=> 0
* Regexp.last_match #=> #<MatchData:0x401b3d30> * Regexp.last_match #=> #<MatchData:0x401b3d30>
* Regexp.last_match(0) #=> "cat" * Regexp.last_match(0) #=> "cat"

214
thread.c
View File

@ -361,7 +361,7 @@ thread_create_core(VALUE klass, VALUE args, VALUE (*fn)(ANYARGS), void *arg)
* call-seq: * call-seq:
* Thread.start([args]*) {|args| block } => thread * Thread.start([args]*) {|args| block } => thread
* Thread.fork([args]*) {|args| block } => thread * Thread.fork([args]*) {|args| block } => thread
* *
* Basically the same as <code>Thread::new</code>. However, if class * Basically the same as <code>Thread::new</code>. However, if class
* <code>Thread</code> is subclassed, then calling <code>start</code> in that * <code>Thread</code> is subclassed, then calling <code>start</code> in that
* subclass will not invoke the subclass's <code>initialize</code> method. * subclass will not invoke the subclass's <code>initialize</code> method.
@ -390,7 +390,7 @@ thread_join(rb_thread_t *target_th, double delay)
{ {
rb_thread_t *th = GET_THREAD(); rb_thread_t *th = GET_THREAD();
double now, limit = timeofday() + delay; double now, limit = timeofday() + delay;
thread_debug("thread_join (thid: %p)\n", target_th->thread_id); thread_debug("thread_join (thid: %p)\n", target_th->thread_id);
if (target_th->status != THREAD_KILLED) { if (target_th->status != THREAD_KILLED) {
@ -440,39 +440,39 @@ thread_join(rb_thread_t *target_th, double delay)
* call-seq: * call-seq:
* thr.join => thr * thr.join => thr
* thr.join(limit) => thr * thr.join(limit) => thr
* *
* The calling thread will suspend execution and run <i>thr</i>. Does not * The calling thread will suspend execution and run <i>thr</i>. Does not
* return until <i>thr</i> exits or until <i>limit</i> seconds have passed. If * return until <i>thr</i> exits or until <i>limit</i> seconds have passed. If
* the time limit expires, <code>nil</code> will be returned, otherwise * the time limit expires, <code>nil</code> will be returned, otherwise
* <i>thr</i> is returned. * <i>thr</i> is returned.
* *
* Any threads not joined will be killed when the main program exits. If * Any threads not joined will be killed when the main program exits. If
* <i>thr</i> had previously raised an exception and the * <i>thr</i> had previously raised an exception and the
* <code>abort_on_exception</code> and <code>$DEBUG</code> flags are not set * <code>abort_on_exception</code> and <code>$DEBUG</code> flags are not set
* (so the exception has not yet been processed) it will be processed at this * (so the exception has not yet been processed) it will be processed at this
* time. * time.
* *
* a = Thread.new { print "a"; sleep(10); print "b"; print "c" } * a = Thread.new { print "a"; sleep(10); print "b"; print "c" }
* x = Thread.new { print "x"; Thread.pass; print "y"; print "z" } * x = Thread.new { print "x"; Thread.pass; print "y"; print "z" }
* x.join # Let x thread finish, a will be killed on exit. * x.join # Let x thread finish, a will be killed on exit.
* *
* <em>produces:</em> * <em>produces:</em>
* *
* axyz * axyz
* *
* The following example illustrates the <i>limit</i> parameter. * The following example illustrates the <i>limit</i> parameter.
* *
* y = Thread.new { 4.times { sleep 0.1; puts 'tick... ' }} * y = Thread.new { 4.times { sleep 0.1; puts 'tick... ' }}
* puts "Waiting" until y.join(0.15) * puts "Waiting" until y.join(0.15)
* *
* <em>produces:</em> * <em>produces:</em>
* *
* tick... * tick...
* Waiting * Waiting
* tick... * tick...
* Waitingtick... * Waitingtick...
* *
* *
* tick... * tick...
*/ */
@ -482,7 +482,7 @@ thread_join_m(int argc, VALUE *argv, VALUE self)
rb_thread_t *target_th; rb_thread_t *target_th;
double delay = DELAY_INFTY; double delay = DELAY_INFTY;
VALUE limit; VALUE limit;
GetThreadPtr(self, target_th); GetThreadPtr(self, target_th);
rb_scan_args(argc, argv, "01", &limit); rb_scan_args(argc, argv, "01", &limit);
@ -495,10 +495,10 @@ thread_join_m(int argc, VALUE *argv, VALUE self)
/* /*
* call-seq: * call-seq:
* thr.value => obj * thr.value => obj
* *
* Waits for <i>thr</i> to complete (via <code>Thread#join</code>) and returns * Waits for <i>thr</i> to complete (via <code>Thread#join</code>) and returns
* its value. * its value.
* *
* a = Thread.new { 2 + 2 } * a = Thread.new { 2 + 2 }
* a.value #=> 4 * a.value #=> 4
*/ */
@ -651,9 +651,9 @@ rb_thread_blocking_region(
/* /*
* call-seq: * call-seq:
* Thread.pass => nil * Thread.pass => nil
* *
* Invokes the thread scheduler to pass execution to another thread. * Invokes the thread scheduler to pass execution to another thread.
* *
* a = Thread.new { print "a"; Thread.pass; * a = Thread.new { print "a"; Thread.pass;
* print "b"; Thread.pass; * print "b"; Thread.pass;
* print "c" } * print "c" }
@ -662,9 +662,9 @@ rb_thread_blocking_region(
* print "z" } * print "z" }
* a.join * a.join
* b.join * b.join
* *
* <em>produces:</em> * <em>produces:</em>
* *
* axbycz * axbycz
*/ */
@ -807,16 +807,16 @@ rb_thread_fd_close(int fd)
/* /*
* call-seq: * call-seq:
* thr.raise(exception) * thr.raise(exception)
* *
* Raises an exception (see <code>Kernel::raise</code>) from <i>thr</i>. The * Raises an exception (see <code>Kernel::raise</code>) from <i>thr</i>. The
* caller does not have to be <i>thr</i>. * caller does not have to be <i>thr</i>.
* *
* Thread.abort_on_exception = true * Thread.abort_on_exception = true
* a = Thread.new { sleep(200) } * a = Thread.new { sleep(200) }
* a.raise("Gotcha") * a.raise("Gotcha")
* *
* <em>produces:</em> * <em>produces:</em>
* *
* prog.rb:3: Gotcha (RuntimeError) * prog.rb:3: Gotcha (RuntimeError)
* from prog.rb:2:in `initialize' * from prog.rb:2:in `initialize'
* from prog.rb:2:in `new' * from prog.rb:2:in `new'
@ -838,7 +838,7 @@ thread_raise_m(int argc, VALUE *argv, VALUE self)
* thr.exit => thr or nil * thr.exit => thr or nil
* thr.kill => thr or nil * thr.kill => thr or nil
* thr.terminate => thr or nil * thr.terminate => thr or nil
* *
* Terminates <i>thr</i> and schedules another thread to be run. If this thread * Terminates <i>thr</i> and schedules another thread to be run. If this thread
* is already marked to be killed, <code>exit</code> returns the * is already marked to be killed, <code>exit</code> returns the
* <code>Thread</code>. If this is the main thread, or the last thread, exits * <code>Thread</code>. If this is the main thread, or the last thread, exits
@ -875,9 +875,9 @@ rb_thread_kill(VALUE thread)
/* /*
* call-seq: * call-seq:
* Thread.kill(thread) => thread * Thread.kill(thread) => thread
* *
* Causes the given <em>thread</em> to exit (see <code>Thread::exit</code>). * Causes the given <em>thread</em> to exit (see <code>Thread::exit</code>).
* *
* count = 0 * count = 0
* a = Thread.new { loop { count += 1 } } * a = Thread.new { loop { count += 1 } }
* sleep(0.1) #=> 0 * sleep(0.1) #=> 0
@ -896,7 +896,7 @@ rb_thread_s_kill(VALUE obj, VALUE th)
/* /*
* call-seq: * call-seq:
* Thread.exit => thread * Thread.exit => thread
* *
* Terminates the currently running thread and schedules another thread to be * Terminates the currently running thread and schedules another thread to be
* run. If this thread is already marked to be killed, <code>exit</code> * run. If this thread is already marked to be killed, <code>exit</code>
* returns the <code>Thread</code>. If this is the main thread, or the last * returns the <code>Thread</code>. If this is the main thread, or the last
@ -913,15 +913,15 @@ rb_thread_exit(void)
/* /*
* call-seq: * call-seq:
* thr.wakeup => thr * thr.wakeup => thr
* *
* Marks <i>thr</i> as eligible for scheduling (it may still remain blocked on * Marks <i>thr</i> as eligible for scheduling (it may still remain blocked on
* I/O, however). Does not invoke the scheduler (see <code>Thread#run</code>). * I/O, however). Does not invoke the scheduler (see <code>Thread#run</code>).
* *
* c = Thread.new { Thread.stop; puts "hey!" } * c = Thread.new { Thread.stop; puts "hey!" }
* c.wakeup * c.wakeup
* *
* <em>produces:</em> * <em>produces:</em>
* *
* hey! * hey!
*/ */
@ -942,18 +942,18 @@ rb_thread_wakeup(VALUE thread)
/* /*
* call-seq: * call-seq:
* thr.run => thr * thr.run => thr
* *
* Wakes up <i>thr</i>, making it eligible for scheduling. If not in a critical * Wakes up <i>thr</i>, making it eligible for scheduling. If not in a critical
* section, then invokes the scheduler. * section, then invokes the scheduler.
* *
* a = Thread.new { puts "a"; Thread.stop; puts "c" } * a = Thread.new { puts "a"; Thread.stop; puts "c" }
* Thread.pass * Thread.pass
* puts "Got here" * puts "Got here"
* a.run * a.run
* a.join * a.join
* *
* <em>produces:</em> * <em>produces:</em>
* *
* a * a
* Got here * Got here
* c * c
@ -971,19 +971,19 @@ rb_thread_run(VALUE thread)
/* /*
* call-seq: * call-seq:
* Thread.stop => nil * Thread.stop => nil
* *
* Stops execution of the current thread, putting it into a ``sleep'' state, * Stops execution of the current thread, putting it into a ``sleep'' state,
* and schedules execution of another thread. Resets the ``critical'' condition * and schedules execution of another thread. Resets the ``critical'' condition
* to <code>false</code>. * to <code>false</code>.
* *
* a = Thread.new { print "a"; Thread.stop; print "c" } * a = Thread.new { print "a"; Thread.stop; print "c" }
* Thread.pass * Thread.pass
* print "b" * print "b"
* a.run * a.run
* a.join * a.join
* *
* <em>produces:</em> * <em>produces:</em>
* *
* abc * abc
*/ */
@ -1006,11 +1006,11 @@ thread_list_i(st_data_t key, st_data_t val, void *data)
GetThreadPtr((VALUE)key, th); GetThreadPtr((VALUE)key, th);
switch (th->status) { switch (th->status) {
case THREAD_RUNNABLE: case THREAD_RUNNABLE:
case THREAD_STOPPED: case THREAD_STOPPED:
case THREAD_TO_KILL: case THREAD_TO_KILL:
rb_ary_push(ary, th->self); rb_ary_push(ary, th->self);
default: default:
break; break;
} }
return ST_CONTINUE; return ST_CONTINUE;
@ -1021,17 +1021,17 @@ thread_list_i(st_data_t key, st_data_t val, void *data)
/* /*
* call-seq: * call-seq:
* Thread.list => array * Thread.list => array
* *
* Returns an array of <code>Thread</code> objects for all threads that are * Returns an array of <code>Thread</code> objects for all threads that are
* either runnable or stopped. * either runnable or stopped.
* *
* Thread.new { sleep(200) } * Thread.new { sleep(200) }
* Thread.new { 1000000.times {|i| i*i } } * Thread.new { 1000000.times {|i| i*i } }
* Thread.new { Thread.stop } * Thread.new { Thread.stop }
* Thread.list.each {|t| p t} * Thread.list.each {|t| p t}
* *
* <em>produces:</em> * <em>produces:</em>
* *
* #<Thread:0x401b3e84 sleep> * #<Thread:0x401b3e84 sleep>
* #<Thread:0x401b3f38 run> * #<Thread:0x401b3f38 run>
* #<Thread:0x401b3fb0 sleep> * #<Thread:0x401b3fb0 sleep>
@ -1055,9 +1055,9 @@ rb_thread_current(void)
/* /*
* call-seq: * call-seq:
* Thread.current => thread * Thread.current => thread
* *
* Returns the currently executing thread. * Returns the currently executing thread.
* *
* Thread.current #=> #<Thread:0x401bdf4c run> * Thread.current #=> #<Thread:0x401bdf4c run>
*/ */
@ -1083,7 +1083,7 @@ rb_thread_s_main(VALUE klass)
/* /*
* call-seq: * call-seq:
* Thread.abort_on_exception => true or false * Thread.abort_on_exception => true or false
* *
* Returns the status of the global ``abort on exception'' condition. The * Returns the status of the global ``abort on exception'' condition. The
* default is <code>false</code>. When set to <code>true</code>, or if the * default is <code>false</code>. When set to <code>true</code>, or if the
* global <code>$DEBUG</code> flag is <code>true</code> (perhaps because the * global <code>$DEBUG</code> flag is <code>true</code> (perhaps because the
@ -1102,10 +1102,10 @@ rb_thread_s_abort_exc(void)
/* /*
* call-seq: * call-seq:
* Thread.abort_on_exception= boolean => true or false * Thread.abort_on_exception= boolean => true or false
* *
* When set to <code>true</code>, all threads will abort if an exception is * When set to <code>true</code>, all threads will abort if an exception is
* raised. Returns the new state. * raised. Returns the new state.
* *
* Thread.abort_on_exception = true * Thread.abort_on_exception = true
* t1 = Thread.new do * t1 = Thread.new do
* puts "In new thread" * puts "In new thread"
@ -1113,9 +1113,9 @@ rb_thread_s_abort_exc(void)
* end * end
* sleep(1) * sleep(1)
* puts "not reached" * puts "not reached"
* *
* <em>produces:</em> * <em>produces:</em>
* *
* In new thread * In new thread
* prog.rb:4: Exception from thread (RuntimeError) * prog.rb:4: Exception from thread (RuntimeError)
* from prog.rb:2:in `initialize' * from prog.rb:2:in `initialize'
@ -1135,7 +1135,7 @@ rb_thread_s_abort_exc_set(VALUE self, VALUE val)
/* /*
* call-seq: * call-seq:
* thr.abort_on_exception => true or false * thr.abort_on_exception => true or false
* *
* Returns the status of the thread-local ``abort on exception'' condition for * Returns the status of the thread-local ``abort on exception'' condition for
* <i>thr</i>. The default is <code>false</code>. See also * <i>thr</i>. The default is <code>false</code>. See also
* <code>Thread::abort_on_exception=</code>. * <code>Thread::abort_on_exception=</code>.
@ -1153,7 +1153,7 @@ rb_thread_abort_exc(VALUE thread)
/* /*
* call-seq: * call-seq:
* thr.abort_on_exception= boolean => true or false * thr.abort_on_exception= boolean => true or false
* *
* When set to <code>true</code>, causes all threads (including the main * When set to <code>true</code>, causes all threads (including the main
* program) to abort if an exception is raised in <i>thr</i>. The process will * program) to abort if an exception is raised in <i>thr</i>. The process will
* effectively <code>exit(0)</code>. * effectively <code>exit(0)</code>.
@ -1174,10 +1174,10 @@ rb_thread_abort_exc_set(VALUE thread, VALUE val)
/* /*
* call-seq: * call-seq:
* thr.group => thgrp or nil * thr.group => thgrp or nil
* *
* Returns the <code>ThreadGroup</code> which contains <i>thr</i>, or nil if * Returns the <code>ThreadGroup</code> which contains <i>thr</i>, or nil if
* the thread is not a member of any group. * the thread is not a member of any group.
* *
* Thread.main.group #=> #<ThreadGroup:0x4029d914> * Thread.main.group #=> #<ThreadGroup:0x4029d914>
*/ */
@ -1199,15 +1199,15 @@ static const char *
thread_status_name(enum rb_thread_status status) thread_status_name(enum rb_thread_status status)
{ {
switch (status) { switch (status) {
case THREAD_RUNNABLE: case THREAD_RUNNABLE:
return "run"; return "run";
case THREAD_STOPPED: case THREAD_STOPPED:
return "sleep"; return "sleep";
case THREAD_TO_KILL: case THREAD_TO_KILL:
return "aborting"; return "aborting";
case THREAD_KILLED: case THREAD_KILLED:
return "dead"; return "dead";
default: default:
return "unknown"; return "unknown";
} }
} }
@ -1222,13 +1222,13 @@ rb_thread_dead(rb_thread_t *th)
/* /*
* call-seq: * call-seq:
* thr.status => string, false or nil * thr.status => string, false or nil
* *
* Returns the status of <i>thr</i>: ``<code>sleep</code>'' if <i>thr</i> is * Returns the status of <i>thr</i>: ``<code>sleep</code>'' if <i>thr</i> is
* sleeping or waiting on I/O, ``<code>run</code>'' if <i>thr</i> is executing, * sleeping or waiting on I/O, ``<code>run</code>'' if <i>thr</i> is executing,
* ``<code>aborting</code>'' if <i>thr</i> is aborting, <code>false</code> if * ``<code>aborting</code>'' if <i>thr</i> is aborting, <code>false</code> if
* <i>thr</i> terminated normally, and <code>nil</code> if <i>thr</i> * <i>thr</i> terminated normally, and <code>nil</code> if <i>thr</i>
* terminated with an exception. * terminated with an exception.
* *
* a = Thread.new { raise("die now") } * a = Thread.new { raise("die now") }
* b = Thread.new { Thread.stop } * b = Thread.new { Thread.stop }
* c = Thread.new { Thread.exit } * c = Thread.new { Thread.exit }
@ -1262,9 +1262,9 @@ rb_thread_status(VALUE thread)
/* /*
* call-seq: * call-seq:
* thr.alive? => true or false * thr.alive? => true or false
* *
* Returns <code>true</code> if <i>thr</i> is running or sleeping. * Returns <code>true</code> if <i>thr</i> is running or sleeping.
* *
* thr = Thread.new { } * thr = Thread.new { }
* thr.join #=> #<Thread:0x401b3fb0 dead> * thr.join #=> #<Thread:0x401b3fb0 dead>
* Thread.current.alive? #=> true * Thread.current.alive? #=> true
@ -1285,9 +1285,9 @@ rb_thread_alive_p(VALUE thread)
/* /*
* call-seq: * call-seq:
* thr.stop? => true or false * thr.stop? => true or false
* *
* Returns <code>true</code> if <i>thr</i> is dead or sleeping. * Returns <code>true</code> if <i>thr</i> is dead or sleeping.
* *
* a = Thread.new { Thread.stop } * a = Thread.new { Thread.stop }
* b = Thread.current * b = Thread.current
* a.stop? #=> true * a.stop? #=> true
@ -1310,10 +1310,10 @@ rb_thread_stop_p(VALUE thread)
/* /*
* call-seq: * call-seq:
* thr.safe_level => integer * thr.safe_level => integer
* *
* Returns the safe level in effect for <i>thr</i>. Setting thread-local safe * Returns the safe level in effect for <i>thr</i>. Setting thread-local safe
* levels can help when implementing sandboxes which run insecure code. * levels can help when implementing sandboxes which run insecure code.
* *
* thr = Thread.new { $SAFE = 3; sleep } * thr = Thread.new { $SAFE = 3; sleep }
* Thread.current.safe_level #=> 0 * Thread.current.safe_level #=> 0
* thr.safe_level #=> 3 * thr.safe_level #=> 3
@ -1373,18 +1373,18 @@ rb_thread_local_aref(VALUE thread, ID id)
/* /*
* call-seq: * call-seq:
* thr[sym] => obj or nil * thr[sym] => obj or nil
* *
* Attribute Reference---Returns the value of a thread-local variable, using * Attribute Reference---Returns the value of a thread-local variable, using
* either a symbol or a string name. If the specified variable does not exist, * either a symbol or a string name. If the specified variable does not exist,
* returns <code>nil</code>. * returns <code>nil</code>.
* *
* a = Thread.new { Thread.current["name"] = "A"; Thread.stop } * a = Thread.new { Thread.current["name"] = "A"; Thread.stop }
* b = Thread.new { Thread.current[:name] = "B"; Thread.stop } * b = Thread.new { Thread.current[:name] = "B"; Thread.stop }
* c = Thread.new { Thread.current["name"] = "C"; Thread.stop } * c = Thread.new { Thread.current["name"] = "C"; Thread.stop }
* Thread.list.each {|x| puts "#{x.inspect}: #{x[:name]}" } * Thread.list.each {|x| puts "#{x.inspect}: #{x[:name]}" }
* *
* <em>produces:</em> * <em>produces:</em>
* *
* #<Thread:0x401b3b3c sleep>: C * #<Thread:0x401b3b3c sleep>: C
* #<Thread:0x401b3bc8 sleep>: B * #<Thread:0x401b3bc8 sleep>: B
* #<Thread:0x401b3c68 sleep>: A * #<Thread:0x401b3c68 sleep>: A
@ -1423,7 +1423,7 @@ rb_thread_local_aset(VALUE thread, ID id, VALUE val)
/* /*
* call-seq: * call-seq:
* thr[sym] = obj => obj * thr[sym] = obj => obj
* *
* Attribute Assignment---Sets or creates the value of a thread-local variable, * Attribute Assignment---Sets or creates the value of a thread-local variable,
* using either a symbol or a string. See also <code>Thread#[]</code>. * using either a symbol or a string. See also <code>Thread#[]</code>.
*/ */
@ -1437,10 +1437,10 @@ rb_thread_aset(VALUE self, ID id, VALUE val)
/* /*
* call-seq: * call-seq:
* thr.key?(sym) => true or false * thr.key?(sym) => true or false
* *
* Returns <code>true</code> if the given string (or symbol) exists as a * Returns <code>true</code> if the given string (or symbol) exists as a
* thread-local variable. * thread-local variable.
* *
* me = Thread.current * me = Thread.current
* me[:oliver] = "a" * me[:oliver] = "a"
* me.key?(:oliver) #=> true * me.key?(:oliver) #=> true
@ -1483,9 +1483,9 @@ rb_thread_alone()
/* /*
* call-seq: * call-seq:
* thr.keys => array * thr.keys => array
* *
* Returns an an array of the names of the thread-local variables (as Symbols). * Returns an an array of the names of the thread-local variables (as Symbols).
* *
* thr = Thread.new do * thr = Thread.new do
* Thread.current[:cat] = 'meow' * Thread.current[:cat] = 'meow'
* Thread.current["dog"] = 'woof' * Thread.current["dog"] = 'woof'
@ -1531,16 +1531,16 @@ rb_thread_priority(VALUE thread)
/* /*
* call-seq: * call-seq:
* thr.priority= integer => thr * thr.priority= integer => thr
* *
* Sets the priority of <i>thr</i> to <i>integer</i>. Higher-priority threads * Sets the priority of <i>thr</i> to <i>integer</i>. Higher-priority threads
* will run before lower-priority threads. * will run before lower-priority threads.
* *
* count1 = count2 = 0 * count1 = count2 = 0
* a = Thread.new do * a = Thread.new do
* loop { count1 += 1 } * loop { count1 += 1 }
* end * end
* a.priority = -1 * a.priority = -1
* *
* b = Thread.new do * b = Thread.new do
* loop { count2 += 1 } * loop { count2 += 1 }
* end * end
@ -1660,7 +1660,7 @@ cmp_tv(const struct timeval *a, const struct timeval *b)
return (d != 0) ? d : (a->tv_usec - b->tv_usec); return (d != 0) ? d : (a->tv_usec - b->tv_usec);
} }
static int static int
subst(struct timeval *rest, const struct timeval *wait) subst(struct timeval *rest, const struct timeval *wait)
{ {
while (rest->tv_usec < wait->tv_usec) { while (rest->tv_usec < wait->tv_usec) {
@ -1915,7 +1915,7 @@ struct thgroup {
* threads as a group. A <code>Thread</code> can belong to only one * threads as a group. A <code>Thread</code> can belong to only one
* <code>ThreadGroup</code> at a time; adding a thread to a new group will * <code>ThreadGroup</code> at a time; adding a thread to a new group will
* remove it from any previous group. * remove it from any previous group.
* *
* Newly created threads belong to the same group as the thread from which they * Newly created threads belong to the same group as the thread from which they
* were created. * were created.
*/ */
@ -1957,10 +1957,10 @@ thgroup_list_i(st_data_t key, st_data_t val, st_data_t data)
/* /*
* call-seq: * call-seq:
* thgrp.list => array * thgrp.list => array
* *
* Returns an array of all existing <code>Thread</code> objects that belong to * Returns an array of all existing <code>Thread</code> objects that belong to
* this group. * this group.
* *
* ThreadGroup::Default.list #=> [#<Thread:0x401bdf4c run>] * ThreadGroup::Default.list #=> [#<Thread:0x401bdf4c run>]
*/ */
@ -1979,11 +1979,11 @@ thgroup_list(VALUE group)
/* /*
* call-seq: * call-seq:
* thgrp.enclose => thgrp * thgrp.enclose => thgrp
* *
* Prevents threads from being added to or removed from the receiving * Prevents threads from being added to or removed from the receiving
* <code>ThreadGroup</code>. New threads can still be started in an enclosed * <code>ThreadGroup</code>. New threads can still be started in an enclosed
* <code>ThreadGroup</code>. * <code>ThreadGroup</code>.
* *
* ThreadGroup::Default.enclose #=> #<ThreadGroup:0x4029d914> * ThreadGroup::Default.enclose #=> #<ThreadGroup:0x4029d914>
* thr = Thread::new { Thread.stop } #=> #<Thread:0x402a7210 sleep> * thr = Thread::new { Thread.stop } #=> #<Thread:0x402a7210 sleep>
* tg = ThreadGroup::new #=> #<ThreadGroup:0x402752d4> * tg = ThreadGroup::new #=> #<ThreadGroup:0x402752d4>
@ -2009,7 +2009,7 @@ thgroup_enclose(VALUE group)
/* /*
* call-seq: * call-seq:
* thgrp.enclosed? => true or false * thgrp.enclosed? => true or false
* *
* Returns <code>true</code> if <em>thgrp</em> is enclosed. See also * Returns <code>true</code> if <em>thgrp</em> is enclosed. See also
* ThreadGroup#enclose. * ThreadGroup#enclose.
*/ */
@ -2029,10 +2029,10 @@ thgroup_enclosed_p(VALUE group)
/* /*
* call-seq: * call-seq:
* thgrp.add(thread) => thgrp * thgrp.add(thread) => thgrp
* *
* Adds the given <em>thread</em> to this group, removing it from any other * Adds the given <em>thread</em> to this group, removing it from any other
* group to which it may have previously belonged. * group to which it may have previously belonged.
* *
* puts "Initial group is #{ThreadGroup::Default.list}" * puts "Initial group is #{ThreadGroup::Default.list}"
* tg = ThreadGroup.new * tg = ThreadGroup.new
* t1 = Thread.new { sleep } * t1 = Thread.new { sleep }
@ -2042,9 +2042,9 @@ thgroup_enclosed_p(VALUE group)
* tg.add(t1) * tg.add(t1)
* puts "Initial group now #{ThreadGroup::Default.list}" * puts "Initial group now #{ThreadGroup::Default.list}"
* puts "tg group now #{tg.list}" * puts "tg group now #{tg.list}"
* *
* <em>produces:</em> * <em>produces:</em>
* *
* Initial group is #<Thread:0x401bdf4c> * Initial group is #<Thread:0x401bdf4c>
* t1 is #<Thread:0x401b3c90> * t1 is #<Thread:0x401b3c90>
* t2 is #<Thread:0x401b3c18> * t2 is #<Thread:0x401b3c18>
@ -2291,7 +2291,7 @@ rb_mutex_sleep(VALUE self, VALUE timeout)
* mutex.sleep(timeout = nil) => self * mutex.sleep(timeout = nil) => self
* *
* Releases the lock and sleeps +timeout+ seconds if it is given and * Releases the lock and sleeps +timeout+ seconds if it is given and
* non-nil or forever. Raises +ThreadError+ if +mutex+ wasn't locked by * non-nil or forever. Raises +ThreadError+ if +mutex+ wasn't locked by
* the current thread. * the current thread.
*/ */
static VALUE static VALUE
@ -2668,7 +2668,7 @@ rb_clear_trace_func(void)
* call-seq: * call-seq:
* set_trace_func(proc) => proc * set_trace_func(proc) => proc
* set_trace_func(nil) => nil * set_trace_func(nil) => nil
* *
* Establishes _proc_ as the handler for tracing, or disables * Establishes _proc_ as the handler for tracing, or disables
* tracing if the parameter is +nil+. _proc_ takes up * tracing if the parameter is +nil+. _proc_ takes up
* to six parameters: an event name, a filename, a line number, an * to six parameters: an event name, a filename, a line number, an
@ -2764,23 +2764,23 @@ static char *
get_event_name(rb_event_flag_t event) get_event_name(rb_event_flag_t event)
{ {
switch (event) { switch (event) {
case RUBY_EVENT_LINE: case RUBY_EVENT_LINE:
return "line"; return "line";
case RUBY_EVENT_CLASS: case RUBY_EVENT_CLASS:
return "class"; return "class";
case RUBY_EVENT_END: case RUBY_EVENT_END:
return "end"; return "end";
case RUBY_EVENT_CALL: case RUBY_EVENT_CALL:
return "call"; return "call";
case RUBY_EVENT_RETURN: case RUBY_EVENT_RETURN:
return "return"; return "return";
case RUBY_EVENT_C_CALL: case RUBY_EVENT_C_CALL:
return "c-call"; return "c-call";
case RUBY_EVENT_C_RETURN: case RUBY_EVENT_C_RETURN:
return "c-return"; return "c-return";
case RUBY_EVENT_RAISE: case RUBY_EVENT_RAISE:
return "raise"; return "raise";
default: default:
return "unknown"; return "unknown";
} }
} }
@ -2826,7 +2826,7 @@ call_trace_func(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klas
/* /*
* +Thread+ encapsulates the behavior of a thread of * +Thread+ encapsulates the behavior of a thread of
* execution, including the main thread of the Ruby script. * execution, including the main thread of the Ruby script.
* *
* In the descriptions of the methods in this class, the parameter _sym_ * In the descriptions of the methods in this class, the parameter _sym_
* refers to a symbol, which is either a quoted string or a * refers to a symbol, which is either a quoted string or a
* +Symbol+ (such as <code>:name</code>). * +Symbol+ (such as <code>:name</code>).

View File

@ -150,7 +150,7 @@ register_cached_thread_and_wait(void)
gettimeofday(&tv, 0); gettimeofday(&tv, 0);
ts.tv_sec = tv.tv_sec + 60; ts.tv_sec = tv.tv_sec + 60;
ts.tv_nsec = tv.tv_usec * 1000; ts.tv_nsec = tv.tv_usec * 1000;
pthread_mutex_lock(&thread_cache_lock); pthread_mutex_lock(&thread_cache_lock);
{ {
entry->th_area = &th_area; entry->th_area = &th_area;
@ -335,7 +335,7 @@ native_sleep(rb_thread_t *th, struct timeval *tv)
ts.tv_nsec -= 1000000000; ts.tv_nsec -= 1000000000;
} }
} }
th->status = THREAD_STOPPED; th->status = THREAD_STOPPED;
pthread_cond_init(&th->native_thread_data.sleep_cond, 0); pthread_cond_init(&th->native_thread_data.sleep_cond, 0);

View File

@ -196,22 +196,22 @@ native_mutex_lock(rb_thread_lock_t *lock)
thread_debug("native_mutex_lock: %p\n", *lock); thread_debug("native_mutex_lock: %p\n", *lock);
result = w32_wait_events(&*lock, 1, INFINITE, 0); result = w32_wait_events(&*lock, 1, INFINITE, 0);
switch (result) { switch (result) {
case WAIT_OBJECT_0: case WAIT_OBJECT_0:
/* get mutex object */ /* get mutex object */
thread_debug("acquire mutex: %p\n", *lock); thread_debug("acquire mutex: %p\n", *lock);
return 0; return 0;
case WAIT_OBJECT_0 + 1: case WAIT_OBJECT_0 + 1:
/* interrupt */ /* interrupt */
errno = EINTR; errno = EINTR;
thread_debug("acquire mutex interrupted: %p\n", *lock); thread_debug("acquire mutex interrupted: %p\n", *lock);
return 0; return 0;
case WAIT_TIMEOUT: case WAIT_TIMEOUT:
thread_debug("timeout mutex: %p\n", *lock); thread_debug("timeout mutex: %p\n", *lock);
break; break;
case WAIT_ABANDONED: case WAIT_ABANDONED:
rb_bug("win32_mutex_lock: WAIT_ABANDONED"); rb_bug("win32_mutex_lock: WAIT_ABANDONED");
break; break;
default: default:
rb_bug("win32_mutex_lock: unknown result (%d)", result); rb_bug("win32_mutex_lock: unknown result (%d)", result);
break; break;
} }
@ -244,9 +244,9 @@ native_mutex_trylock(rb_thread_lock_t *lock)
result = w32_wait_events(&*lock, 1, 1, 0); result = w32_wait_events(&*lock, 1, 1, 0);
thread_debug("native_mutex_trylock result: %d\n", result); thread_debug("native_mutex_trylock result: %d\n", result);
switch (result) { switch (result) {
case WAIT_OBJECT_0: case WAIT_OBJECT_0:
return 0; return 0;
case WAIT_TIMEOUT: case WAIT_TIMEOUT:
return EBUSY; return EBUSY;
} }
return EINVAL; return EINVAL;

View File

@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0" #define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2007-06-04" #define RUBY_RELEASE_DATE "2007-06-05"
#define RUBY_VERSION_CODE 190 #define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20070604 #define RUBY_RELEASE_CODE 20070605
#define RUBY_PATCHLEVEL 0 #define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MAJOR 1
@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0 #define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2007 #define RUBY_RELEASE_YEAR 2007
#define RUBY_RELEASE_MONTH 6 #define RUBY_RELEASE_MONTH 6
#define RUBY_RELEASE_DAY 4 #define RUBY_RELEASE_DAY 5
#ifdef RUBY_EXTERN #ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[]; RUBY_EXTERN const char ruby_version[];

158
vm.c
View File

@ -120,7 +120,7 @@ pop_frame(rb_thread_t *th)
{ {
#if COLLECT_PROFILE #if COLLECT_PROFILE
rb_control_frame_t *cfp = th->cfp; rb_control_frame_t *cfp = th->cfp;
if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
VALUE current_time = clock(); VALUE current_time = clock();
rb_control_frame_t *cfp = th->cfp; rb_control_frame_t *cfp = th->cfp;
@ -322,7 +322,7 @@ th_make_env_each(rb_thread_t *th, rb_control_frame_t *cfp,
BUILTIN_TYPE(cfp->lfp[-1]) == T_VALUES))) { BUILTIN_TYPE(cfp->lfp[-1]) == T_VALUES))) {
rb_bug("illegal svar"); rb_bug("illegal svar");
} }
if (!RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { if (!RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
/* TODO */ /* TODO */
env->block.iseq = 0; env->block.iseq = 0;
@ -524,64 +524,64 @@ th_call0(rb_thread_t *th, VALUE klass, VALUE recv,
} }
switch (nd_type(body)) { switch (nd_type(body)) {
case RUBY_VM_METHOD_NODE:{ case RUBY_VM_METHOD_NODE:{
rb_control_frame_t *reg_cfp; rb_control_frame_t *reg_cfp;
int i; int i;
const int flag = 0; const int flag = 0;
th_set_finish_env(th); th_set_finish_env(th);
reg_cfp = th->cfp; reg_cfp = th->cfp;
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
*reg_cfp->sp++ = argv[i]; *reg_cfp->sp++ = argv[i];
} }
macro_eval_invoke_func(body->nd_body, recv, klass, blockptr, macro_eval_invoke_func(body->nd_body, recv, klass, blockptr,
argc); argc);
val = th_eval_body(th); val = th_eval_body(th);
break; break;
} }
case NODE_CFUNC: { case NODE_CFUNC: {
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, id, klass); EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, id, klass);
{ {
rb_control_frame_t *reg_cfp = th->cfp; rb_control_frame_t *reg_cfp = th->cfp;
rb_control_frame_t *cfp = rb_control_frame_t *cfp =
push_frame(th, 0, FRAME_MAGIC_CFUNC, push_frame(th, 0, FRAME_MAGIC_CFUNC,
recv, (VALUE)blockptr, 0, reg_cfp->sp, 0, 1); recv, (VALUE)blockptr, 0, reg_cfp->sp, 0, 1);
cfp->method_id = id; cfp->method_id = id;
cfp->method_klass = klass; cfp->method_klass = klass;
val = call_cfunc(body->nd_cfnc, recv, body->nd_argc, argc, argv); val = call_cfunc(body->nd_cfnc, recv, body->nd_argc, argc, argv);
if (reg_cfp != th->cfp + 1) { if (reg_cfp != th->cfp + 1) {
SDR2(reg_cfp); SDR2(reg_cfp);
SDR2(th->cfp-5); SDR2(th->cfp-5);
rb_bug("cfp consistency error - call0"); rb_bug("cfp consistency error - call0");
th->cfp = reg_cfp; th->cfp = reg_cfp;
} }
pop_frame(th); pop_frame(th);
} }
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, id, klass); EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, id, klass);
break; break;
} }
case NODE_ATTRSET:{ case NODE_ATTRSET:{
if (argc != 1) { if (argc != 1) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
argc); argc);
} }
val = rb_ivar_set(recv, body->nd_vid, argv[0]); val = rb_ivar_set(recv, body->nd_vid, argv[0]);
break; break;
} }
case NODE_IVAR: { case NODE_IVAR: {
if (argc != 0) { if (argc != 0) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)",
argc); argc);
} }
val = rb_attr_get(recv, body->nd_vid); val = rb_attr_get(recv, body->nd_vid);
break; break;
} }
case NODE_BMETHOD:{ case NODE_BMETHOD:{
val = th_invoke_bmethod(th, id, body->nd_cval, val = th_invoke_bmethod(th, id, body->nd_cval,
recv, klass, argc, (VALUE *)argv); recv, klass, argc, (VALUE *)argv);
break; break;
} }
default: default:
rb_bug("unsupported: th_call0"); rb_bug("unsupported: th_call0");
@ -895,22 +895,22 @@ lfp_svar(VALUE *lfp, int cnt)
} }
} }
switch (cnt) { switch (cnt) {
case -1: case -1:
return &val->basic.klass; return &val->basic.klass;
case 0: case 0:
return &val->v1; return &val->v1;
case 1: case 1:
return &val->v2; return &val->v2;
default:{ default:{
VALUE ary; VALUE ary;
if ((ary = val->v3) == Qnil) { if ((ary = val->v3) == Qnil) {
ary = val->v3 = rb_ary_new(); ary = val->v3 = rb_ary_new();
}
if (RARRAY_LEN(ary) <= cnt) {
rb_ary_store(ary, cnt, Qnil);
}
return &RARRAY_PTR(ary)[cnt];
} }
if (RARRAY_LEN(ary) <= cnt) {
rb_ary_store(ary, cnt, Qnil);
}
return &RARRAY_PTR(ary)[cnt];
}
} }
} }
@ -1195,7 +1195,7 @@ eval_get_ev_const(rb_thread_t *th, rb_iseq_t *iseq,
while (cref && cref->nd_next) { while (cref && cref->nd_next) {
klass = cref->nd_clss; klass = cref->nd_clss;
cref = cref->nd_next; cref = cref->nd_next;
if (klass == 0) { if (klass == 0) {
continue; continue;
} }
@ -1236,10 +1236,10 @@ eval_get_ev_const(rb_thread_t *th, rb_iseq_t *iseq,
} }
else { else {
switch (TYPE(klass)) { switch (TYPE(klass)) {
case T_CLASS: case T_CLASS:
case T_MODULE: case T_MODULE:
break; break;
default: default:
rb_raise(rb_eTypeError, "%s is not a class/module", rb_raise(rb_eTypeError, "%s is not a class/module",
RSTRING_PTR(rb_obj_as_string(klass))); RSTRING_PTR(rb_obj_as_string(klass)));
} }
@ -1361,24 +1361,24 @@ make_localjump_error(const char *mesg, VALUE value, int reason)
rb_exc_new2(rb_const_get(rb_cObject, rb_intern("LocalJumpError")), rb_exc_new2(rb_const_get(rb_cObject, rb_intern("LocalJumpError")),
mesg); mesg);
ID id; ID id;
switch (reason) { switch (reason) {
case TAG_BREAK: case TAG_BREAK:
id = rb_intern("break"); id = rb_intern("break");
break; break;
case TAG_REDO: case TAG_REDO:
id = rb_intern("redo"); id = rb_intern("redo");
break; break;
case TAG_RETRY: case TAG_RETRY:
id = rb_intern("retry"); id = rb_intern("retry");
break; break;
case TAG_NEXT: case TAG_NEXT:
id = rb_intern("next"); id = rb_intern("next");
break; break;
case TAG_RETURN: case TAG_RETURN:
id = rb_intern("return"); id = rb_intern("return");
break; break;
default: default:
id = rb_intern("noreason"); id = rb_intern("noreason");
break; break;
} }
@ -1398,28 +1398,28 @@ VALUE
th_make_jump_tag_but_local_jump(int state, VALUE val) th_make_jump_tag_but_local_jump(int state, VALUE val)
{ {
VALUE result = Qnil; VALUE result = Qnil;
if (val == Qundef) if (val == Qundef)
val = GET_THREAD()->tag->retval; val = GET_THREAD()->tag->retval;
switch (state) { switch (state) {
case 0: case 0:
break; break;
case TAG_RETURN: case TAG_RETURN:
result = make_localjump_error("unexpected return", val, state); result = make_localjump_error("unexpected return", val, state);
break; break;
case TAG_BREAK: case TAG_BREAK:
result = make_localjump_error("unexpected break", val, state); result = make_localjump_error("unexpected break", val, state);
break; break;
case TAG_NEXT: case TAG_NEXT:
result = make_localjump_error("unexpected next", val, state); result = make_localjump_error("unexpected next", val, state);
break; break;
case TAG_REDO: case TAG_REDO:
result = make_localjump_error("unexpected redo", Qnil, state); result = make_localjump_error("unexpected redo", Qnil, state);
break; break;
case TAG_RETRY: case TAG_RETRY:
result = make_localjump_error("retry outside of rescue clause", Qnil, state); result = make_localjump_error("retry outside of rescue clause", Qnil, state);
break; break;
default: default:
break; break;
} }
return result; return result;
@ -1453,7 +1453,7 @@ void
rb_vm_check_redefinition_opt_method(NODE *node) rb_vm_check_redefinition_opt_method(NODE *node)
{ {
VALUE bop; VALUE bop;
if (st_lookup(vm_opt_method_table, (st_data_t)node, &bop)) { if (st_lookup(vm_opt_method_table, (st_data_t)node, &bop)) {
yarv_redefined_flag |= bop; yarv_redefined_flag |= bop;
} }
@ -1828,7 +1828,7 @@ rb_thread_eval(rb_thread_t *th, VALUE iseqval)
{ {
VALUE val; VALUE val;
volatile VALUE tmp; volatile VALUE tmp;
th_set_top_stack(th, iseqval); th_set_top_stack(th, iseqval);
if (!rb_const_defined(rb_cObject, rb_intern("TOPLEVEL_BINDING"))) { if (!rb_const_defined(rb_cObject, rb_intern("TOPLEVEL_BINDING"))) {

View File

@ -47,40 +47,40 @@ control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp)
} }
switch (cfp->magic) { switch (cfp->magic) {
case FRAME_MAGIC_TOP: case FRAME_MAGIC_TOP:
magic = "TOP"; magic = "TOP";
break; break;
case FRAME_MAGIC_METHOD: case FRAME_MAGIC_METHOD:
magic = "METHOD"; magic = "METHOD";
break; break;
case FRAME_MAGIC_CLASS: case FRAME_MAGIC_CLASS:
magic = "CLASS"; magic = "CLASS";
break; break;
case FRAME_MAGIC_BLOCK: case FRAME_MAGIC_BLOCK:
magic = "BLOCK"; magic = "BLOCK";
break; break;
case FRAME_MAGIC_FINISH: case FRAME_MAGIC_FINISH:
magic = "FINISH"; magic = "FINISH";
break; break;
case FRAME_MAGIC_CFUNC: case FRAME_MAGIC_CFUNC:
magic = "CFUNC"; magic = "CFUNC";
break; break;
case FRAME_MAGIC_PROC: case FRAME_MAGIC_PROC:
magic = "PROC"; magic = "PROC";
break; break;
case FRAME_MAGIC_LAMBDA: case FRAME_MAGIC_LAMBDA:
magic = "LAMBDA"; magic = "LAMBDA";
break; break;
case FRAME_MAGIC_IFUNC: case FRAME_MAGIC_IFUNC:
magic = "IFUNC"; magic = "IFUNC";
break; break;
case FRAME_MAGIC_EVAL: case FRAME_MAGIC_EVAL:
magic = "EVAL"; magic = "EVAL";
break; break;
case 0: case 0:
magic = "------"; magic = "------";
break; break;
default: default:
magic = "(none)"; magic = "(none)";
break; break;
} }