зеркало из https://github.com/github/ruby.git
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x). * lib/tempfile.rb (Tempfile::make_tmpname): put dot between basename and pid. [ruby-talk:196272] * parse.y (do_block): remove -> style block. * parse.y (parser_yylex): remove tLAMBDA_ARG. * eval.c (rb_call0): binding for the return event hook should have consistent scope. [ruby-core:07928] * eval.c (proc_invoke): return behavior should depend whether it is surrounded by a lambda or a mere block. * eval.c (formal_assign): handles post splat arguments. * eval.c (rb_call0): ditto. * st.c (strhash): use FNV-1a hash. * parse.y (parser_yylex): removed experimental ';;' terminator. * eval.c (rb_node_arity): should be aware of post splat arguments. * eval.c (rb_proc_arity): ditto. * parse.y (f_args): syntax rule enhanced to support arguments after the splat. * parse.y (block_param): ditto for block parameters. * parse.y (f_post_arg): mandatory formal arguments after the splat argument. * parse.y (new_args_gen): generate nodes for mandatory formal arguments after the splat argument. * eval.c (rb_eval): dispatch mandatory formal arguments after the splat argument. * parse.y (args): allow more than one splat in the argument list. * parse.y (method_call): allow aref [] to accept all kind of method argument, including assocs, splat, and block argument. * eval.c (SETUP_ARGS0): prepare block argument as well. * lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931] * eval.c (error_line): print receivers true/false/nil specially. * eval.c (rb_proc_yield): handles parameters in yield semantics. * eval.c (nil_yield): gives LocalJumpError to denote no block error. * io.c (rb_io_getc): now takes one-character string. * string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo hashing algorithm. * string.c (rb_str_aref): str[0] now returns 1 character string, instead of a fixnum. [Ruby2] * parse.y (parser_yylex): ?c now returns 1 character string, instead of a fixnum. [Ruby2] * string.c (rb_str_aset): no longer support fixnum insertion. * eval.c (umethod_bind): should not update original class. [ruby-dev:28636] * eval.c (ev_const_get): should support constant access from within instance_eval(). [ruby-dev:28327] * time.c (time_timeval): should round for usec floating number. [ruby-core:07896] * time.c (time_add): ditto. * dir.c (sys_warning): should not call a vararg function rb_sys_warning() indirectly. [ruby-core:07886] * numeric.c (flo_divmod): the first element of Float#divmod should be an integer. [ruby-dev:28589] * test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder. * re.c (rb_reg_initialize): should not allow modifying literal regexps. frozen check moved from rb_reg_initialize_m as well. * re.c (rb_reg_initialize): should not modify untainted objects in safe levels higher than 3. * re.c (rb_memcmp): type change from char* to const void*. * dir.c (dir_close): should not close untainted dir stream. * dir.c (GetDIR): add tainted/frozen check for each dir operation. * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg): typo fixed. a patch from Florian Gross <florg at florg.net>. * eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from event_hooks. no guarantee for arbitrary hook deletion. [ruby-dev:28632] * util.c (ruby_strtod): differ addition to minimize error. [ruby-dev:28619] * util.c (ruby_strtod): should not raise ERANGE when the input string does not have any digits. [ruby-dev:28629] * eval.c (proc_invoke): should restore old ruby_frame->block. thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833] also fix [ruby-dev:28614] as well. * signal.c (trap): sig should be less then NSIG. Coverity found this bug. a patch from Kevin Tew <tewk at tewk.com>. [ruby-core:07823] * math.c (math_log2): add new method inspired by [ruby-talk:191237]. * math.c (math_log): add optional base argument to Math::log(). [ruby-talk:191308] * ext/syck/emitter.c (syck_scan_scalar): avoid accessing uninitialized array element. a patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07809] * array.c (rb_ary_fill): initialize local variables first. a patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810] * ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free type_tag. a patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07808] * ext/socket/socket.c (make_hostent_internal): accept ai_family check from Sam Roberts <sroberts at uniserve.com>. [ruby-core:07691] * util.c (ruby_strtod): should not cut off 18 digits for no reason. [ruby-core:07796] * array.c (rb_ary_fill): internalize local variable "beg" to pacify Coverity. [ruby-core:07770] * pack.c (pack_unpack): now supports CRLF newlines. a patch from <tommy at tmtm.org>. [ruby-dev:28601] * applied code clean-up patch from Stefan Huehner <stefan at huehner.org>. [ruby-core:07764] * lib/jcode.rb (String::tr_s): should have translated non squeezing character sequence (i.e. a character) as well. thanks to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090] * ext/socket/socket.c: document update patch from Sam Roberts <sroberts at uniserve.com>. [ruby-core:07701] * lib/mathn.rb (Integer): need not to remove gcd2. a patch from NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570] * parse.y (arg): too much NEW_LIST() * eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen. * eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1. [ruby-dev:28585] * parse.y (arg): use NODE_ARGSCAT for placeholder. * lib/getoptlong.rb (GetoptLong::get): RDoc update patch from mathew <meta at pobox.com>. [ruby-core:07738] * variable.c (rb_const_set): raise error when no target klass is supplied. [ruby-dev:28582] * prec.c (prec_prec_f): documentation patch from <gerardo.santana at gmail.com>. [ruby-core:07689] * bignum.c (rb_big_pow): second operand may be too big even if it's a Fixnum. [ruby-talk:187984] * README.EXT: update symbol description. [ruby-talk:188104] * COPYING: explicitly note GPLv2. [ruby-talk:187922] * parse.y: remove some obsolete syntax rules (unparenthesized method calls in argument list). * eval.c (rb_call0): insecure calling should be checked for non NODE_SCOPE method invocations too. * eval.c (rb_alias): should preserve the current safe level as well as method definition. * process.c (rb_f_sleep): remove RDoc description about SIGALRM which is not valid on the current implementation. [ruby-dev:28464] Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp> * eval.c (method_missing): should support argument splat in super. a bug in combination of super, splat and method_missing. [ruby-talk:185438] * configure.in: Solaris SunPro compiler -rapth patch from <kuwa at labs.fujitsu.com>. [ruby-dev:28443] * configure.in: remove enable_rpath=no for Solaris. [ruby-dev:28440] * ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby String object. * ruby.1: a clarification patch from David Lutterkort <dlutter at redhat.com>. [ruby-core:7508] * lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems directories. a patch from Eric Hodel <drbrain at segment7.net>. [ruby-core:07423] * eval.c (rb_clear_cache_by_class): clearing wrong cache. * ext/extmk.rb: use :remove_destination to install extension libraries to avoid SEGV. [ruby-dev:28417] * eval.c (rb_thread_fd_writable): should not re-schedule output from KILLED thread (must be error printing). * array.c (rb_ary_flatten_bang): allow specifying recursion level. [ruby-talk:182170] * array.c (rb_ary_flatten): ditto. * gc.c (add_heap): a heap_slots may overflow. a patch from Stefan Weil <weil at mail.berlios.de>. * eval.c (rb_call): use separate cache for fcall/vcall invocation. * eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local functions. * eval.c (rb_mod_local): a new method to specify newly added visibility "local". * eval.c (search_method): search for local methods which are visible only from the current class. * class.c (rb_class_local_methods): a method to list local methods. * object.c (Init_Object): add BasicObject class as a top level BlankSlate class. * ruby.h (SYM2ID): should not cast to signed long. [ruby-core:07414] * class.c (rb_include_module): allow module duplication. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
f83f236f25
Коммит
9b383bd6cf
2
COPYING
2
COPYING
|
@ -1,6 +1,6 @@
|
|||
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
||||
You can redistribute it and/or modify it under either the terms of the GPL
|
||||
(see the file GPL), or the conditions below:
|
||||
version 2 (see the file GPL), or the conditions below:
|
||||
|
||||
1. You may make and give away verbatim copies of the source form of the
|
||||
software without restriction, provided that you duplicate all of the
|
||||
|
|
408
ChangeLog
408
ChangeLog
|
@ -1,12 +1,38 @@
|
|||
Fri Jun 9 09:56:32 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* sprintf.c (rb_str_format): allow %c to print one character
|
||||
string (e.g. ?x).
|
||||
|
||||
Thu Jun 8 14:00:02 2006 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* win32/win32.[ch] (rb_w32_read, rb_w32_write): new functions.
|
||||
use recv() and send() when fd is socket. fixed: [ruby-dev:28694]
|
||||
|
||||
Wed Jun 7 16:22:51 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
|
||||
basename and pid. [ruby-talk:196272]
|
||||
|
||||
Wed Jun 7 16:16:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* parse.y (do_block): remove -> style block.
|
||||
|
||||
* parse.y (parser_yylex): remove tLAMBDA_ARG.
|
||||
|
||||
Wed Jun 7 14:51:22 2006 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* win32/win32.c (errmap): add some winsock errors.
|
||||
|
||||
Wed Jun 7 09:14:44 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_call0): binding for the return event hook should have
|
||||
consistent scope. [ruby-core:07928]
|
||||
|
||||
Tue Jun 6 23:25:49 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (proc_invoke): return behavior should depend whether it
|
||||
is surrounded by a lambda or a mere block.
|
||||
|
||||
Mon Jun 5 18:12:12 2006 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* ext/socket/socket.c (sock_s_unpack_sockaddr_in): reject
|
||||
|
@ -19,6 +45,20 @@ Sun Jun 4 20:40:19 2006 Tanaka Akira <akr@m17n.org>
|
|||
* ext/socket/socket.c: fix sockaddr_un handling.
|
||||
[ruby-dev:28677]
|
||||
|
||||
Sat Jun 3 23:53:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (formal_assign): handles post splat arguments.
|
||||
|
||||
* eval.c (rb_call0): ditto.
|
||||
|
||||
Sat Jun 3 13:10:41 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* st.c (strhash): use FNV-1a hash.
|
||||
|
||||
Fri Jun 2 20:01:24 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* parse.y (parser_yylex): removed experimental ';;' terminator.
|
||||
|
||||
Fri Jun 2 19:00:40 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||
|
||||
* ext/openssl/extconf.rb: use create_header.
|
||||
|
@ -48,17 +88,67 @@ Thu Jun 1 19:12:37 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
* win32/win32.c (rb_w32_cmdvector): backslashes inside single-quotes
|
||||
no longer has special meanings. fixed: [ruby-list:42311]
|
||||
|
||||
Thu Jun 1 17:55:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_node_arity): should be aware of post splat arguments.
|
||||
|
||||
* eval.c (rb_proc_arity): ditto.
|
||||
|
||||
Thu Jun 1 16:17:26 2006 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* win32/win32.c (rb_w32_getcwd): runtime's getcwd() will not success
|
||||
if the length of the cwd is longer than MAX_PATH.
|
||||
fixed [ruby-list:42335]
|
||||
|
||||
Thu Jun 1 16:07:48 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* parse.y (f_args): syntax rule enhanced to support arguments
|
||||
after the splat.
|
||||
|
||||
* parse.y (mlhs_basic): ditto for multiple assignments
|
||||
|
||||
* parse.y (block_param): ditto for block parameters.
|
||||
|
||||
* parse.y (f_post_arg): mandatory formal arguments after the splat
|
||||
argument.
|
||||
|
||||
* parse.y (new_args_gen): generate nodes for mandatory formal
|
||||
arguments after the splat argument.
|
||||
|
||||
* eval.c (rb_eval): dispatch mandatory formal arguments after the
|
||||
splat argument.
|
||||
|
||||
Thu Jun 1 11:33:32 2006 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* win32/win32.c (rb_w32_getcwd): set errno if not set.
|
||||
fixed [ruby-list:42346]
|
||||
|
||||
Thu Jun 1 00:45:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* parse.y (args): allow more than one splat in the argument list.
|
||||
|
||||
Wed May 31 18:38:11 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* parse.y (method_call): allow aref [] to accept all kind of
|
||||
method argument, including assocs, splat, and block argument.
|
||||
|
||||
* eval.c (SETUP_ARGS0): prepare block argument as well.
|
||||
|
||||
Tue May 30 18:13:53 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
|
||||
|
||||
Mon May 29 22:40:13 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (error_line): print receivers true/false/nil specially.
|
||||
|
||||
* eval.c (rb_proc_yield): handles parameters in yield semantics.
|
||||
|
||||
* eval.c (nil_yield): gives LocalJumpError to denote no block
|
||||
error.
|
||||
|
||||
* io.c (rb_io_getc): now takes one-character string.
|
||||
|
||||
Sat May 27 22:46:38 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (proc_invoke): save and restore block in the current frame.
|
||||
|
@ -69,6 +159,11 @@ Sat May 27 11:29:46 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
* ext/extmk.rb (extmake): remove extinit files if no statically linked
|
||||
extensions.
|
||||
|
||||
Fri May 26 19:56:46 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
|
||||
hashing algorithm.
|
||||
|
||||
Fri May 26 09:05:11 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ruby.h, lib/mkmf.rb (create_header): clear command line options for
|
||||
|
@ -103,7 +198,17 @@ Wed May 24 23:52:11 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
* configure.in (ac_install_sh): ignore dummy install-sh.
|
||||
[ruby-talk:193876]
|
||||
|
||||
Wed May 24 03:10:44 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||
Wed May 24 17:55:13 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_aref): str[0] now returns 1 character string,
|
||||
instead of a fixnum. [Ruby2]
|
||||
|
||||
* parse.y (parser_yylex): ?c now returns 1 character string,
|
||||
instead of a fixnum. [Ruby2]
|
||||
|
||||
* string.c (rb_str_aset): no longer support fixnum insertion.
|
||||
|
||||
Wed May 24 03:10:44 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||
|
||||
* ext/openssl/lib/openssl/ssl.rb
|
||||
(OpenSSL::SSL::SocketForwarder#setsockopt,getsockopt): typo fixed.
|
||||
|
@ -125,6 +230,16 @@ Mon May 22 16:32:03 2006 Tanaka Akira <akr@m17n.org>
|
|||
|
||||
[ruby-core:7917]
|
||||
|
||||
Mon May 22 15:57:39 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (umethod_bind): should not update original class.
|
||||
[ruby-dev:28636]
|
||||
|
||||
Mon May 22 13:38:57 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (ev_const_get): should support constant access from
|
||||
within instance_eval(). [ruby-dev:28327]
|
||||
|
||||
Sun May 21 09:50:31 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
|
||||
|
||||
* regexec.c: add STK_NULL_CHECK_END to IS_TO_VOID_TARGET().
|
||||
|
@ -152,15 +267,55 @@ Thu May 18 22:37:20 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
|||
|
||||
* test/webrick/test_utils.rb: test for WEBrick::Utils.timeout.
|
||||
|
||||
Thu May 18 17:51:32 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* time.c (time_timeval): should round for usec floating
|
||||
number. [ruby-core:07896]
|
||||
|
||||
* time.c (time_add): ditto.
|
||||
|
||||
Thu May 18 00:42:12 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/extmk.rb, lib/mkmf.rb: use BUILD_FILE_SEPARATOR in Makefiles.
|
||||
|
||||
Wed May 17 17:55:26 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* dir.c (sys_warning): should not call a vararg function
|
||||
rb_sys_warning() indirectly. [ruby-core:07886]
|
||||
|
||||
Tue May 16 17:23:19 2006 <sinara@blade.nagaokaut.ac.jp>
|
||||
|
||||
* numeric.c (flo_divmod): the first element of Float#divmod should
|
||||
be an integer. [ruby-dev:28589]
|
||||
|
||||
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
|
||||
|
||||
Tue May 16 15:34:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* re.c (rb_reg_initialize): should not allow modifying literal
|
||||
regexps. frozen check moved from rb_reg_initialize_m as well.
|
||||
|
||||
Tue May 16 09:20:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* re.c (rb_reg_initialize): should not modify untainted objects in
|
||||
safe levels higher than 3.
|
||||
|
||||
* re.c (rb_memcmp): type change from char* to const void*.
|
||||
|
||||
* dir.c (dir_close): should not close untainted dir stream.
|
||||
|
||||
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
|
||||
|
||||
Mon May 15 21:37:12 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
|
||||
|
||||
* re.c (rb_reg_prepare_re): don't use onig_recompile().
|
||||
|
||||
Sat May 13 16:14:05 2006 Tanaka Akira <akr@m17n.org>
|
||||
Mon May 15 17:42:39 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
|
||||
typo fixed. a patch from Florian Gross <florg at florg.net>.
|
||||
|
||||
Sat May 13 16:14:05 2006 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* lib/pp.rb (PP.mcall): new method.
|
||||
(Struct#pretty_print): call Kernel#class and Struct#members even if
|
||||
|
@ -168,11 +323,27 @@ Sat May 13 16:14:05 2006 Tanaka Akira <akr@m17n.org>
|
|||
(Struct#pretty_print_cycle): ditto.
|
||||
[ruby-core:7865]
|
||||
|
||||
Thu May 11 18:30:11 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||
Fri May 12 15:54:48 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
|
||||
event_hooks. no guarantee for arbitrary hook deletion.
|
||||
[ruby-dev:28632]
|
||||
|
||||
Thu May 11 19:57:00 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* util.c (ruby_strtod): differ addition to minimize error.
|
||||
[ruby-dev:28619]
|
||||
|
||||
Thu May 11 18:30:11 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||
|
||||
* ext/openssl/ossl_cipher.c (add_cipher_name_to_ary): should return
|
||||
value. [ruby-dev:28627]
|
||||
|
||||
Thu May 11 18:10:43 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* util.c (ruby_strtod): should not raise ERANGE when the input
|
||||
string does not have any digits. [ruby-dev:28629]
|
||||
|
||||
Wed May 10 23:40:21 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
|
||||
|
||||
* oniguruma.h: Version 4.0.3
|
||||
|
@ -203,7 +374,46 @@ Sun May 7 03:09:51 2006 Stephan Maka <stephan@spaceboyz.net>
|
|||
* lib/resolv.rb (Resolv::DNS::Requester::ConnectedUDP#initialize):
|
||||
Use AF_INET6 for nameservers containing colons.
|
||||
|
||||
Mon May 1 17:58:16 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
Sat May 6 23:40:03 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (proc_invoke): should restore old ruby_frame->block.
|
||||
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
|
||||
also fix [ruby-dev:28614] as well.
|
||||
|
||||
Sat May 6 00:38:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* signal.c (trap): sig should be less then NSIG. Coverity found
|
||||
this bug. a patch from Kevin Tew <tewk at tewk.com>.
|
||||
[ruby-core:07823]
|
||||
|
||||
Thu May 4 22:13:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* math.c (math_log2): add new method inspired by
|
||||
[ruby-talk:191237].
|
||||
|
||||
* math.c (math_log): add optional base argument to Math::log().
|
||||
[ruby-talk:191308]
|
||||
|
||||
Thu May 4 02:24:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
|
||||
uninitialized array element. a patch from Pat Eyler
|
||||
<rubypate at gmail.com>. [ruby-core:07809]
|
||||
|
||||
* array.c (rb_ary_fill): initialize local variables first. a
|
||||
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
|
||||
|
||||
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
|
||||
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
|
||||
[ruby-core:07808]
|
||||
|
||||
Wed May 3 02:12:07 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* ext/socket/socket.c (make_hostent_internal): accept ai_family
|
||||
check from Sam Roberts <sroberts at uniserve.com>.
|
||||
[ruby-core:07691]
|
||||
|
||||
Mon May 1 17:58:16 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (add_event_call_back): should not
|
||||
delete event handler when the event name is not entried.
|
||||
|
@ -218,16 +428,75 @@ Sat Apr 29 22:43:37 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
|||
* ext/openssl/ossl_asn1.c (ossl_asn1_decode0): should initialize
|
||||
flag. [ruby-core:07785]
|
||||
|
||||
Fri Apr 28 10:53:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* util.c (ruby_strtod): should not cut off 18 digits for no
|
||||
reason. [ruby-core:07796]
|
||||
|
||||
Thu Apr 27 01:38:10 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_fill): internalize local variable "beg" to
|
||||
pacify Coverity. [ruby-core:07770]
|
||||
|
||||
Wed Apr 26 16:59:24 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
|
||||
<tommy at tmtm.org>. [ruby-dev:28601]
|
||||
|
||||
Wed Apr 26 16:55:19 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* applied code clean-up patch from Stefan Huehner
|
||||
<stefan at huehner.org>. [ruby-core:07764]
|
||||
|
||||
Tue Apr 25 18:00:05 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tk/tcltklib.c (delete_slaves): maybe increment the reference
|
||||
count of a NULL Tcl_Obj [ruby-core:07759].
|
||||
|
||||
Tue Apr 25 07:55:31 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* lib/jcode.rb (String::tr_s): should have translated non
|
||||
squeezing character sequence (i.e. a character) as well. thanks
|
||||
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
|
||||
|
||||
Fri Apr 21 15:19:13 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tk/tcltklib.c (lib_eventloop_ensure): refer freed pointer
|
||||
[ruby-core:07744] and memory leak.
|
||||
|
||||
Fri Apr 21 12:14:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* ext/socket/socket.c: document update patch from Sam Roberts
|
||||
<sroberts at uniserve.com>. [ruby-core:07701]
|
||||
|
||||
Thu Apr 20 08:43:54 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
|
||||
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
|
||||
|
||||
Wed Apr 19 13:55:27 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* parse.y (arg): too much NEW_LIST()
|
||||
|
||||
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
|
||||
|
||||
Wed Apr 19 11:57:04 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
|
||||
[ruby-dev:28585]
|
||||
|
||||
* parse.y (arg): use NODE_ARGSCAT for placeholder.
|
||||
|
||||
Wed Apr 19 11:13:17 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
|
||||
mathew <meta at pobox.com>. [ruby-core:07738]
|
||||
|
||||
Wed Apr 19 10:13:27 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* variable.c (rb_const_set): raise error when no target klass is
|
||||
supplied. [ruby-dev:28582]
|
||||
|
||||
Tue Apr 18 17:40:37 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tk/lib/multi-tk.rb: add a binding to a container for a slave IP.
|
||||
|
@ -238,7 +507,21 @@ Tue Apr 18 17:40:37 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
|||
|
||||
* ext/tk/stubs.c: fix potential bugs about handling rb_argv0.
|
||||
|
||||
Sat Apr 8 18:06:28 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
Mon Apr 10 01:03:10 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* prec.c (prec_prec_f): documentation patch from
|
||||
<gerardo.santana at gmail.com>. [ruby-core:07689]
|
||||
|
||||
Sat Apr 8 02:34:34 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* bignum.c (rb_big_pow): second operand may be too big even if
|
||||
it's a Fixnum. [ruby-talk:187984]
|
||||
|
||||
Sat Apr 8 02:12:38 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* README.EXT: update symbol description. [ruby-talk:188104]
|
||||
|
||||
Sat Apr 8 18:06:28 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c: add WIN32OLE_METHOD#inspect,
|
||||
WIN32OLE_PARAM#inspect.
|
||||
|
@ -254,7 +537,11 @@ Fri Apr 7 22:11:30 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
|||
|
||||
* test/win32ole/test_win32ole_typelib.rb(test_initialize): ditto.
|
||||
|
||||
Thu Apr 6 16:43:06 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
Thu Apr 6 23:28:47 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
|
||||
|
||||
Thu Apr 6 16:43:06 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* intern.h (rb_obj_instance_exec, rb_mod_module_exec): add declaration.
|
||||
|
||||
|
@ -287,7 +574,12 @@ Wed Apr 5 00:22:54 2006 Tanaka Akira <akr@m17n.org>
|
|||
methods take pathname argument. suggested by Evan Phoenix.
|
||||
[ruby-core:7618]
|
||||
|
||||
Sat Apr 1 15:11:27 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
Tue Apr 4 22:15:41 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* parse.y: remove some obsolete syntax rules (unparenthesized
|
||||
method calls in argument list).
|
||||
|
||||
Sat Apr 1 15:11:27 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c :add WIN32OLE_TYPE#inspect,
|
||||
WIN32OLE_VARIABLE#inspect
|
||||
|
@ -337,6 +629,14 @@ Mon Mar 27 22:45:37 2006 NARUSE, Yui <naruse@ruby-lang.org>
|
|||
|
||||
* ext/nkf/nkf.c, ext/nkf/lib/kconv.rb: Add rdoc.
|
||||
|
||||
Mon Mar 27 03:17:21 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_call0): insecure calling should be checked for non
|
||||
NODE_SCOPE method invocations too.
|
||||
|
||||
* eval.c (rb_alias): should preserve the current safe level as
|
||||
well as method definition.
|
||||
|
||||
Sun Mar 26 22:02:51 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
|
||||
|
||||
* re.c: refactoring for options.
|
||||
|
@ -351,6 +651,11 @@ Fri Mar 24 21:11:02 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
|
|||
|
||||
* string.c (rb_str_gsub): ditto.
|
||||
|
||||
Fri Mar 24 17:20:03 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
|
||||
which is not valid on the current implementation. [ruby-dev:28464]
|
||||
|
||||
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
|
||||
|
||||
* re.c (rb_reg_regsub): prohibit \1, \2 ...\9 in replaced string
|
||||
|
@ -366,6 +671,12 @@ Thu Mar 23 21:06:23 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
|
|||
|
||||
* regerror.c: ditto.
|
||||
|
||||
Thu Mar 23 10:47:03 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (method_missing): should support argument splat in
|
||||
super. a bug in combination of super, splat and
|
||||
method_missing. [ruby-talk:185438]
|
||||
|
||||
Thu Mar 23 00:01:32 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
|
||||
|
||||
* re.c (rb_reg_regsub): add back reference by name \k<name> in
|
||||
|
@ -387,15 +698,25 @@ Tue Mar 21 22:14:01 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
|
|||
|
||||
* gc.c (gc_mark_children): add gc_mark() to regexp member.
|
||||
|
||||
Mon Mar 20 12:05:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* configure.in: Solaris SunPro compiler -rapth patch from
|
||||
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
|
||||
|
||||
Mon Mar 20 11:12:38 2006 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* ext/win32ole/win32ole.c (folevariant_value): could not compile
|
||||
with C90 compiler.
|
||||
|
||||
Sun Mar 19 09:46:30 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
Mon Mar 20 09:40:23 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* configure.in: remove enable_rpath=no for Solaris.
|
||||
[ruby-dev:28440]
|
||||
|
||||
Sun Mar 19 09:46:30 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
|
||||
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
|
||||
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
|
||||
String object.
|
||||
|
||||
* ext/win32ole/win32ole.c (folevariant_value): ditto.
|
||||
|
@ -421,7 +742,12 @@ Sun Mar 12 17:02:10 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
|||
* ext/win32ole/tests/testOLEPARAM.rb: test method name should not be
|
||||
duplicated.
|
||||
|
||||
Sun Mar 5 18:40:58 2006 Minero Aoki <aamine@loveruby.net>
|
||||
Sat Mar 11 14:24:06 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* ruby.1: a clarification patch from David Lutterkort
|
||||
<dlutter at redhat.com>. [ruby-core:7508]
|
||||
|
||||
Sun Mar 5 18:40:58 2006 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* lib/fileutils.rb: do not repeat command options.
|
||||
|
||||
|
@ -434,16 +760,25 @@ Sat Mar 4 15:26:40 2006 Tanaka Akira <akr@m17n.org>
|
|||
|
||||
* gc.c (id2ref): fix symbol test.
|
||||
|
||||
Fri Mar 3 21:22:42 2006 Tanaka Akira <akr@m17n.org>
|
||||
Sat Mar 4 01:08:07 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
|
||||
directories. a patch from Eric Hodel <drbrain at segment7.net>.
|
||||
[ruby-core:07423]
|
||||
|
||||
Fri Mar 3 17:59:00 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
|
||||
|
||||
Fri Mar 3 21:22:42 2006 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* lib/fileutils.rb (FileUtils.cp_r): implement :remove_destination
|
||||
option.
|
||||
|
||||
* ext/extmk.rb: use :remove_destination to install extension libraries
|
||||
to avoid SEGV.
|
||||
[ruby-dev:28417]
|
||||
to avoid SEGV. [ruby-dev:28417]
|
||||
|
||||
Fri Mar 3 14:41:04 2006 Minero Aoki <aamine@loveruby.net>
|
||||
Fri Mar 3 14:41:04 2006 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* ext/dl/.cvsignore: ignore callback.h.
|
||||
|
||||
|
@ -451,7 +786,40 @@ Fri Mar 3 14:41:04 2006 Minero Aoki <aamine@loveruby.net>
|
|||
|
||||
* ext/socket/.cvsignore: ignore constants.h.
|
||||
|
||||
Thu Mar 2 17:54:45 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
||||
Thu Mar 2 18:58:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_thread_fd_writable): should not re-schedule output
|
||||
from KILLED thread (must be error printing).
|
||||
|
||||
Thu Mar 2 09:12:05 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_flatten_bang): allow specifying recursion
|
||||
level. [ruby-talk:182170]
|
||||
|
||||
* array.c (rb_ary_flatten): ditto.
|
||||
|
||||
Thu Mar 2 08:02:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
|
||||
Weil <weil at mail.berlios.de>.
|
||||
|
||||
Wed Mar 1 17:13:37 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_call): use separate cache for fcall/vcall
|
||||
invocation.
|
||||
|
||||
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
|
||||
functions.
|
||||
|
||||
* eval.c (rb_mod_local): a new method to specify newly added
|
||||
visibility "local".
|
||||
|
||||
* eval.c (search_method): search for local methods which are
|
||||
visible only from the current class.
|
||||
|
||||
* class.c (rb_class_local_methods): a method to list local methods.
|
||||
|
||||
Thu Mar 2 17:54:45 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
||||
|
||||
* gc.c: commited magic for reducing RVALUE size on windows. (24->20byte)
|
||||
[ruby-core:7474]
|
||||
|
@ -476,6 +844,16 @@ Wed Mar 1 00:15:51 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
|||
merged Mr. Ishizuka's lib/irb/ruby-lex.rb 's patch rev 1.29.
|
||||
[ruby-talk:181631] [ruby-dev:28404]
|
||||
|
||||
Tue Feb 28 19:32:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* object.c (Init_Object): add BasicObject class as a top level
|
||||
BlankSlate class.
|
||||
|
||||
Mon Feb 27 00:19:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* ruby.h (SYM2ID): should not cast to signed long.
|
||||
[ruby-core:07414]
|
||||
|
||||
Fri Feb 24 20:21:38 2006 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
|
||||
|
||||
* test/drb/drbtest.rb (add_service_command): quote pathnames in the
|
||||
|
|
23
README.EXT
23
README.EXT
|
@ -330,17 +330,30 @@ of the innermost method (which is defined by Ruby) can be accessed.
|
|||
|
||||
2.2.2 ID or Symbol
|
||||
|
||||
You can invoke methods directly, without parsing the string. First I
|
||||
need to explain about symbols (whose data type is ID). ID is the
|
||||
integer number to represent Ruby's identifiers such as variable names.
|
||||
It can be accessed from Ruby in the form:
|
||||
You can invoke methods directly, without parsing the string. First I need
|
||||
to explain about ID. ID is the integer number to represent Ruby's
|
||||
identifiers such as variable names. The Ruby data type corresponding to ID
|
||||
is Symbol. It can be accessed from Ruby in the form:
|
||||
|
||||
:Identifier
|
||||
|
||||
You can get the symbol value from a string within C code by using
|
||||
You can get the ID value from a string within C code by using
|
||||
|
||||
rb_intern(const char *name)
|
||||
|
||||
You can retrieve ID from Ruby object (Symbol or String) given as an
|
||||
argument by using
|
||||
|
||||
rb_to_id(VALUE symbol)
|
||||
|
||||
You can convert C ID to Ruby Symbol by using
|
||||
|
||||
VALUE ID2SYM(ID id)
|
||||
|
||||
and to convert Ruby Symbol object to ID, use
|
||||
|
||||
ID SYM2ID(VALUE symbol)
|
||||
|
||||
2.2.3 Invoke Ruby method from C
|
||||
|
||||
To invoke methods directly, you can use the function below
|
||||
|
|
108
array.c
108
array.c
|
@ -17,7 +17,7 @@
|
|||
#include "st.h"
|
||||
#include "node.h"
|
||||
|
||||
VALUE rb_cArray, rb_cValues;
|
||||
VALUE rb_cArray;
|
||||
|
||||
static ID id_cmp;
|
||||
|
||||
|
@ -169,38 +169,6 @@ rb_ary_new4(long n, const VALUE *elts)
|
|||
return ary;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_values_new(long n, ...)
|
||||
{
|
||||
va_list ar;
|
||||
VALUE val;
|
||||
long i;
|
||||
|
||||
val = ary_new(rb_cValues, n);
|
||||
va_start(ar, n);
|
||||
for (i=0; i<n; i++) {
|
||||
RARRAY(val)->ptr[i] = va_arg(ar, VALUE);
|
||||
}
|
||||
va_end(ar);
|
||||
RARRAY(val)->len = n;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_values_new2(long n, const VALUE *elts)
|
||||
{
|
||||
VALUE val;
|
||||
|
||||
val = ary_new(rb_cValues, n);
|
||||
if (n > 0 && elts) {
|
||||
RARRAY(val)->len = n;
|
||||
MEMCPY(RARRAY(val)->ptr, elts, VALUE, n);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
ary_make_shared(VALUE ary)
|
||||
{
|
||||
|
@ -234,22 +202,10 @@ ary_shared_array(VALUE klass, VALUE ary)
|
|||
return val;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_values_from_ary(VALUE ary)
|
||||
{
|
||||
return ary_shared_array(rb_cValues, ary);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_ary_from_values(VALUE val)
|
||||
{
|
||||
return ary_shared_array(rb_cArray, val);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_assoc_new(VALUE car, VALUE cdr)
|
||||
{
|
||||
return rb_values_new(2, car, cdr);
|
||||
return rb_ary_new3(2, car, cdr);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -2099,7 +2055,7 @@ static VALUE
|
|||
rb_ary_fill(int argc, VALUE *argv, VALUE ary)
|
||||
{
|
||||
VALUE item, arg1, arg2;
|
||||
long beg, end, len;
|
||||
long beg = 0, end = 0, len = 0;
|
||||
VALUE *p, *pend;
|
||||
int block_p = Qfalse;
|
||||
|
||||
|
@ -2739,27 +2695,30 @@ rb_ary_nitems(VALUE ary)
|
|||
}
|
||||
|
||||
static long
|
||||
flatten(VALUE ary, long idx, VALUE ary2, VALUE memo)
|
||||
flatten(VALUE ary, long idx, VALUE ary2, VALUE memo, int level)
|
||||
{
|
||||
VALUE id;
|
||||
long i = idx;
|
||||
long n, lim = idx + RARRAY(ary2)->len;
|
||||
|
||||
level--;
|
||||
id = rb_obj_id(ary2);
|
||||
if (rb_ary_includes(memo, id)) {
|
||||
rb_raise(rb_eArgError, "tried to flatten recursive array");
|
||||
}
|
||||
rb_ary_push(memo, id);
|
||||
rb_ary_splice(ary, idx, 1, ary2);
|
||||
while (i < lim) {
|
||||
VALUE tmp;
|
||||
if (level != 0) {
|
||||
while (i < lim) {
|
||||
VALUE tmp;
|
||||
|
||||
tmp = rb_check_array_type(rb_ary_elt(ary, i));
|
||||
if (!NIL_P(tmp)) {
|
||||
n = flatten(ary, i, tmp, memo);
|
||||
i += n; lim += n;
|
||||
tmp = rb_check_array_type(rb_ary_elt(ary, i));
|
||||
if (!NIL_P(tmp)) {
|
||||
n = flatten(ary, i, tmp, memo, level);
|
||||
i += n; lim += n;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
rb_ary_pop(memo);
|
||||
|
||||
|
@ -2768,25 +2727,34 @@ flatten(VALUE ary, long idx, VALUE ary2, VALUE memo)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* array.flatten! -> array or nil
|
||||
* array.flatten! -> array or nil
|
||||
* array.flatten!(level) -> array or nil
|
||||
*
|
||||
* Flattens _self_ in place.
|
||||
* Returns <code>nil</code> if no modifications were made (i.e.,
|
||||
* <i>array</i> contains no subarrays.)
|
||||
* <i>array</i> contains no subarrays.) If the optional <i>level</i>
|
||||
* argument determins the level of recursion to flatten.
|
||||
*
|
||||
* a = [ 1, 2, [3, [4, 5] ] ]
|
||||
* a.flatten! #=> [1, 2, 3, 4, 5]
|
||||
* a.flatten! #=> nil
|
||||
* a #=> [1, 2, 3, 4, 5]
|
||||
* a.flatten! #=> [1, 2, 3, 4, 5]
|
||||
* a.flatten! #=> nil
|
||||
* a #=> [1, 2, 3, 4, 5]
|
||||
* a = [ 1, 2, [3, [4, 5] ] ]
|
||||
* a.flatten!(1) #=> [1, 2, 3, [4, 5]]
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
rb_ary_flatten_bang(VALUE ary)
|
||||
rb_ary_flatten_bang(int argc, VALUE *argv, VALUE ary)
|
||||
{
|
||||
long i = 0;
|
||||
int mod = 0;
|
||||
int level = -1;
|
||||
VALUE memo = Qnil;
|
||||
VALUE lv;
|
||||
|
||||
rb_scan_args(argc, argv, "01", &lv);
|
||||
if (!NIL_P(lv)) level = FIX2INT(lv);
|
||||
if (level == 0) return ary;
|
||||
while (i<RARRAY(ary)->len) {
|
||||
VALUE ary2 = RARRAY(ary)->ptr[i];
|
||||
VALUE tmp;
|
||||
|
@ -2796,7 +2764,7 @@ rb_ary_flatten_bang(VALUE ary)
|
|||
if (NIL_P(memo)) {
|
||||
memo = rb_ary_new();
|
||||
}
|
||||
i += flatten(ary, i, tmp, memo);
|
||||
i += flatten(ary, i, tmp, memo, level);
|
||||
mod = 1;
|
||||
}
|
||||
i++;
|
||||
|
@ -2808,22 +2776,26 @@ rb_ary_flatten_bang(VALUE ary)
|
|||
/*
|
||||
* call-seq:
|
||||
* array.flatten -> an_array
|
||||
* array.flatten(level) -> an_array
|
||||
*
|
||||
* Returns a new array that is a one-dimensional flattening of this
|
||||
* array (recursively). That is, for every element that is an array,
|
||||
* extract its elements into the new array.
|
||||
* extract its elements into the new array. If the optional
|
||||
* <i>level</i> argument determins the level of recursion to flatten.
|
||||
*
|
||||
* s = [ 1, 2, 3 ] #=> [1, 2, 3]
|
||||
* t = [ 4, 5, 6, [7, 8] ] #=> [4, 5, 6, [7, 8]]
|
||||
* a = [ s, t, 9, 10 ] #=> [[1, 2, 3], [4, 5, 6, [7, 8]], 9, 10]
|
||||
* a.flatten #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10
|
||||
* a = [ 1, 2, [3, [4, 5] ] ]
|
||||
* a.flatten(1) #=> [1, 2, 3, [4, 5]]
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
rb_ary_flatten(VALUE ary)
|
||||
rb_ary_flatten(int argc, VALUE *argv, VALUE ary)
|
||||
{
|
||||
ary = rb_ary_dup(ary);
|
||||
rb_ary_flatten_bang(ary);
|
||||
rb_ary_flatten_bang(argc, argv, ary);
|
||||
return ary;
|
||||
}
|
||||
|
||||
|
@ -2918,11 +2890,9 @@ Init_Array(void)
|
|||
rb_define_method(rb_cArray, "uniq!", rb_ary_uniq_bang, 0);
|
||||
rb_define_method(rb_cArray, "compact", rb_ary_compact, 0);
|
||||
rb_define_method(rb_cArray, "compact!", rb_ary_compact_bang, 0);
|
||||
rb_define_method(rb_cArray, "flatten", rb_ary_flatten, 0);
|
||||
rb_define_method(rb_cArray, "flatten!", rb_ary_flatten_bang, 0);
|
||||
rb_define_method(rb_cArray, "flatten", rb_ary_flatten, -1);
|
||||
rb_define_method(rb_cArray, "flatten!", rb_ary_flatten_bang, -1);
|
||||
rb_define_method(rb_cArray, "nitems", rb_ary_nitems, 0);
|
||||
|
||||
id_cmp = rb_intern("<=>");
|
||||
|
||||
rb_cValues = rb_define_class("Values", rb_cArray);
|
||||
}
|
||||
|
|
13
bignum.c
13
bignum.c
|
@ -406,7 +406,7 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
|
|||
len *= strlen(str)*sizeof(char);
|
||||
|
||||
if (len <= (sizeof(VALUE)*CHAR_BIT)) {
|
||||
unsigned long val = strtoul((char*)str, &end, base);
|
||||
unsigned long val = strtoul(str, &end, base);
|
||||
|
||||
if (*end == '_') goto bigparse;
|
||||
if (badcheck) {
|
||||
|
@ -516,7 +516,7 @@ rb_str_to_inum(VALUE str, int base, int badcheck)
|
|||
|
||||
#if HAVE_LONG_LONG
|
||||
|
||||
VALUE
|
||||
static VALUE
|
||||
rb_ull2big(unsigned LONG_LONG n)
|
||||
{
|
||||
BDIGIT_DBL num = n;
|
||||
|
@ -537,7 +537,7 @@ rb_ull2big(unsigned LONG_LONG n)
|
|||
return big;
|
||||
}
|
||||
|
||||
VALUE
|
||||
static VALUE
|
||||
rb_ll2big(LONG_LONG n)
|
||||
{
|
||||
long neg = 0;
|
||||
|
@ -595,10 +595,10 @@ rb_big2str(VALUE x, int base)
|
|||
if (FIXNUM_P(x)) {
|
||||
return rb_fix2str(x, base);
|
||||
}
|
||||
i = RBIGNUM(x)->len;
|
||||
if (BIGZEROP(x)) {
|
||||
return rb_str_new2("0");
|
||||
}
|
||||
i = RBIGNUM(x)->len;
|
||||
j = SIZEOF_BDIGITS*CHAR_BIT*i;
|
||||
switch (base) {
|
||||
case 2: break;
|
||||
|
@ -1546,6 +1546,11 @@ rb_big_pow(VALUE x, VALUE y)
|
|||
if (yy > 0) {
|
||||
VALUE z = x;
|
||||
|
||||
if (RBIGNUM(x)->len * SIZEOF_BDIGITS * yy > 1024*1024) {
|
||||
rb_warn("in a**b, b may be too big");
|
||||
d = (double)yy;
|
||||
break;
|
||||
}
|
||||
for (;;) {
|
||||
yy -= 1;
|
||||
if (yy == 0) break;
|
||||
|
|
41
class.c
41
class.c
|
@ -344,7 +344,7 @@ include_class_new(VALUE module, VALUE super)
|
|||
void
|
||||
rb_include_module(VALUE klass, VALUE module)
|
||||
{
|
||||
VALUE p, c;
|
||||
VALUE c;
|
||||
int changed = 0;
|
||||
|
||||
rb_frozen_class_p(klass);
|
||||
|
@ -362,30 +362,11 @@ rb_include_module(VALUE klass, VALUE module)
|
|||
OBJ_INFECT(klass, module);
|
||||
c = klass;
|
||||
while (module) {
|
||||
int superclass_seen = Qfalse;
|
||||
|
||||
if (RCLASS(klass)->m_tbl == RCLASS(module)->m_tbl)
|
||||
rb_raise(rb_eArgError, "cyclic include detected");
|
||||
/* ignore if the module included already in superclasses */
|
||||
for (p = RCLASS(klass)->super; p; p = RCLASS(p)->super) {
|
||||
switch (BUILTIN_TYPE(p)) {
|
||||
case T_ICLASS:
|
||||
if (RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) {
|
||||
if (!superclass_seen) {
|
||||
c = p; /* move insertion point */
|
||||
}
|
||||
goto skip;
|
||||
}
|
||||
break;
|
||||
case T_CLASS:
|
||||
superclass_seen = Qtrue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
RCLASS(c)->super = include_class_new(module, RCLASS(c)->super);
|
||||
c = RCLASS(c)->super;
|
||||
changed = 1;
|
||||
skip:
|
||||
module = RCLASS(module)->super;
|
||||
}
|
||||
if (changed) rb_clear_cache();
|
||||
|
@ -500,6 +481,7 @@ ins_methods_push(ID name, long type, VALUE ary, long visi)
|
|||
case NOEX_PRIVATE:
|
||||
case NOEX_PROTECTED:
|
||||
case NOEX_PUBLIC:
|
||||
case NOEX_LOCAL:
|
||||
visi = (type == visi);
|
||||
break;
|
||||
default:
|
||||
|
@ -536,6 +518,12 @@ ins_methods_pub_i(ID name, long type, VALUE ary)
|
|||
return ins_methods_push(name, type, ary, NOEX_PUBLIC);
|
||||
}
|
||||
|
||||
static int
|
||||
ins_methods_local_i(ID name, long type, VALUE ary)
|
||||
{
|
||||
return ins_methods_push(name, type, ary, NOEX_LOCAL);
|
||||
}
|
||||
|
||||
static int
|
||||
method_entry(ID key, NODE *body, st_table *list)
|
||||
{
|
||||
|
@ -666,6 +654,19 @@ rb_class_public_instance_methods(int argc, VALUE *argv, VALUE mod)
|
|||
return class_instance_method_list(argc, argv, mod, ins_methods_pub_i);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* mod.local_methods => array
|
||||
*
|
||||
* Returns a list of the local methods defined in <i>mod</i>.
|
||||
*/
|
||||
|
||||
VALUE
|
||||
rb_class_local_methods(VALUE mod)
|
||||
{
|
||||
return class_instance_method_list(0, 0, mod, ins_methods_local_i);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* obj.singleton_methods(all=true) => array
|
||||
|
|
10
configure.in
10
configure.in
|
@ -509,7 +509,7 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot fsync getcwd
|
|||
getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\
|
||||
getpriority getrlimit setrlimit\
|
||||
dlopen sigprocmask sigaction _setjmp vsnprintf snprintf\
|
||||
setsid telldir seekdir fchmod mktime timegm cosh sinh tanh\
|
||||
setsid telldir seekdir fchmod mktime timegm cosh sinh tanh log2\
|
||||
setuid setgid daemon select_large_fdset setenv unsetenv)
|
||||
AC_ARG_ENABLE(setreuid,
|
||||
[ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.],
|
||||
|
@ -1265,8 +1265,6 @@ if test "$enable_shared" = 'yes'; then
|
|||
LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY) lib$(RUBY_SO_NAME).so'
|
||||
if test "$GCC" = yes; then
|
||||
LIBRUBY_DLDFLAGS="$DLDFLAGS "'-Wl,-h,$(@F)'
|
||||
else
|
||||
enable_rpath=no
|
||||
fi
|
||||
XLDFLAGS="$XLDFLAGS "'-R${libdir}'
|
||||
;;
|
||||
|
@ -1307,7 +1305,11 @@ if test "$enable_shared" = 'yes'; then
|
|||
esac
|
||||
fi
|
||||
if test "$enable_rpath" = yes; then
|
||||
LIBRUBYARG_SHARED='-Wl,-R -Wl,$(libdir) -L$(libdir) -L. '"$LIBRUBYARG_SHARED"
|
||||
if test "$GCC" = yes; then
|
||||
LIBRUBYARG_SHARED='-Wl,-R -Wl,$(libdir) -L$(libdir) -L. '"$LIBRUBYARG_SHARED"
|
||||
else
|
||||
LIBRUBYARG_SHARED='-R $(libdir) -L$(libdir) -L. '"$LIBRUBYARG_SHARED"
|
||||
fi
|
||||
fi
|
||||
|
||||
XLDFLAGS="$XLDFLAGS -L."
|
||||
|
|
20
dir.c
20
dir.c
|
@ -441,7 +441,16 @@ dir_closed(void)
|
|||
rb_raise(rb_eIOError, "closed directory");
|
||||
}
|
||||
|
||||
static void
|
||||
dir_check(VALUE dir)
|
||||
{
|
||||
if (!OBJ_TAINTED(dir) && rb_safe_level() >= 4)
|
||||
rb_raise(rb_eSecurityError, "Insecure: operation on untainted Dir");
|
||||
rb_check_frozen(dir);
|
||||
}
|
||||
|
||||
#define GetDIR(obj, dirp) do {\
|
||||
dir_check(dir);\
|
||||
Data_Get_Struct(obj, struct dir_data, dirp);\
|
||||
if (dirp->dir == NULL) dir_closed();\
|
||||
} while (0)
|
||||
|
@ -647,6 +656,9 @@ dir_rewind(VALUE dir)
|
|||
{
|
||||
struct dir_data *dirp;
|
||||
|
||||
if (rb_safe_level() >= 4 && !OBJ_TAINTED(dir)) {
|
||||
rb_raise(rb_eSecurityError, "Insecure: can't close");
|
||||
}
|
||||
GetDIR(dir, dirp);
|
||||
rewinddir(dirp->dir);
|
||||
return dir;
|
||||
|
@ -903,9 +915,15 @@ dir_s_rmdir(VALUE obj, VALUE dir)
|
|||
return INT2FIX(0);
|
||||
}
|
||||
|
||||
static void
|
||||
sys_warning_1(const char* mesg)
|
||||
{
|
||||
rb_sys_warning("%s", mesg);
|
||||
}
|
||||
|
||||
#define GLOB_VERBOSE (1 << (sizeof(int) * CHAR_BIT - 1))
|
||||
#define sys_warning(val) \
|
||||
((flags & GLOB_VERBOSE) && rb_protect((VALUE (*)(VALUE))rb_sys_warning, (VALUE)(val), 0))
|
||||
((flags & GLOB_VERBOSE) && rb_protect((VALUE (*)_((VALUE)))sys_warning_1, (VALUE)(val), 0))
|
||||
|
||||
/* System call with warning */
|
||||
static int
|
||||
|
|
|
@ -27,7 +27,7 @@ static VALUE
|
|||
proc_call(VALUE proc, VALUE args)
|
||||
{
|
||||
if (TYPE(args) != T_ARRAY) {
|
||||
args = rb_values_new(1, args);
|
||||
args = rb_ary_new3(1, args);
|
||||
}
|
||||
return rb_proc_call(proc, args);
|
||||
}
|
||||
|
|
8
error.c
8
error.c
|
@ -209,7 +209,7 @@ rb_check_type(VALUE x, int t)
|
|||
if (TYPE(x) != t) {
|
||||
while (type->type >= 0) {
|
||||
if (type->type == t) {
|
||||
char *etype;
|
||||
const char *etype;
|
||||
|
||||
if (NIL_P(x)) {
|
||||
etype = "nil";
|
||||
|
@ -434,7 +434,7 @@ static VALUE
|
|||
check_backtrace(VALUE bt)
|
||||
{
|
||||
long i;
|
||||
static char *err = "backtrace must be Array of String";
|
||||
static const char *err = "backtrace must be Array of String";
|
||||
|
||||
if (!NIL_P(bt)) {
|
||||
int t = TYPE(bt);
|
||||
|
@ -683,7 +683,7 @@ name_err_mesg_to_str(VALUE obj)
|
|||
mesg = ptr[0];
|
||||
if (NIL_P(mesg)) return Qnil;
|
||||
else {
|
||||
char *desc = 0;
|
||||
const char *desc = 0;
|
||||
VALUE d = 0, args[3];
|
||||
|
||||
obj = ptr[1];
|
||||
|
@ -828,7 +828,7 @@ syserr_initialize(int argc, VALUE *argv, VALUE self)
|
|||
#if !defined(_WIN32) && !defined(__VMS)
|
||||
char *strerror();
|
||||
#endif
|
||||
char *err;
|
||||
const char *err;
|
||||
VALUE mesg, error;
|
||||
VALUE klass = rb_obj_class(self);
|
||||
|
||||
|
|
967
eval.c
967
eval.c
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -3,7 +3,8 @@
|
|||
iconv/iconv.c
|
||||
nkf/lib/kconv.rb
|
||||
nkf/nkf.c
|
||||
socket/socket.c
|
||||
stringio/stringio.c
|
||||
strscan/strscan.c
|
||||
zlib/zlib.c
|
||||
win32ole
|
||||
zlib/zlib.c
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#digest/sha1
|
||||
#digest/sha2
|
||||
#dl
|
||||
#enumerator
|
||||
#etc
|
||||
#fcntl
|
||||
#gdbm
|
||||
|
|
|
@ -302,7 +302,7 @@ VpNewRbClass(U_LONG mx, char *str, VALUE klass)
|
|||
}
|
||||
|
||||
VP_EXPORT Real *
|
||||
VpCreateRbObject(U_LONG mx, char *str)
|
||||
VpCreateRbObject(U_LONG mx, const char *str)
|
||||
{
|
||||
Real *pv = VpAlloc(mx,str);
|
||||
pv->obj = (VALUE)Data_Wrap_Struct(rb_cBigDecimal, 0, BigDecimal_delete, pv);
|
||||
|
@ -917,7 +917,7 @@ BigDecimal_round(int argc, VALUE *argv, VALUE self)
|
|||
{
|
||||
ENTER(5);
|
||||
Real *c, *a;
|
||||
int iLoc;
|
||||
int iLoc = 0;
|
||||
U_LONG mx;
|
||||
VALUE vLoc;
|
||||
VALUE vRound;
|
||||
|
@ -1578,7 +1578,7 @@ VpIsNegDoubleZero(double v)
|
|||
}
|
||||
|
||||
VP_EXPORT int
|
||||
VpException(unsigned short f,char *str,int always)
|
||||
VpException(unsigned short f, const char *str,int always)
|
||||
{
|
||||
VALUE exc;
|
||||
int fatal=0;
|
||||
|
@ -1720,7 +1720,7 @@ NaN:
|
|||
* returns number of chars needed to represent vp in specified format.
|
||||
*/
|
||||
VP_EXPORT U_LONG
|
||||
VpNumOfChars(Real *vp,char *pszFmt)
|
||||
VpNumOfChars(Real *vp,const char *pszFmt)
|
||||
{
|
||||
S_INT ex;
|
||||
U_LONG nc;
|
||||
|
@ -1873,7 +1873,7 @@ overflow:
|
|||
* NULL be returned if memory allocation is failed,or any error.
|
||||
*/
|
||||
VP_EXPORT Real *
|
||||
VpAlloc(U_LONG mx, char *szVal)
|
||||
VpAlloc(U_LONG mx, const char *szVal)
|
||||
{
|
||||
U_LONG i, ni, ipn, ipf, nf, ipe, ne, nalloc;
|
||||
char v,*psz;
|
||||
|
@ -3277,7 +3277,7 @@ VpToFString(Real *a,char *psz,int fFmt,int fPlus)
|
|||
* ne ... number of characters in exp_chr[],not including '+/-'.
|
||||
*/
|
||||
VP_EXPORT int
|
||||
VpCtoV(Real *a, char *int_chr, U_LONG ni, char *frac, U_LONG nf, char *exp_chr, U_LONG ne)
|
||||
VpCtoV(Real *a, const char *int_chr, U_LONG ni, const char *frac, U_LONG nf, const char *exp_chr, U_LONG ne)
|
||||
{
|
||||
U_LONG i, j, ind_a, ma, mi, me;
|
||||
U_LONG loc;
|
||||
|
|
|
@ -105,7 +105,7 @@ typedef struct {
|
|||
VP_EXPORT Real *
|
||||
VpNewRbClass(U_LONG mx,char *str,VALUE klass);
|
||||
|
||||
VP_EXPORT Real *VpCreateRbObject(U_LONG mx,char *str);
|
||||
VP_EXPORT Real *VpCreateRbObject(U_LONG mx,const char *str);
|
||||
|
||||
VP_EXPORT U_LONG VpBaseFig(void);
|
||||
VP_EXPORT U_LONG VpDblFig(void);
|
||||
|
@ -126,13 +126,13 @@ VP_EXPORT int VpIsRoundMode(unsigned long n);
|
|||
VP_EXPORT unsigned long VpGetRoundMode(void);
|
||||
VP_EXPORT unsigned long VpSetRoundMode(unsigned long n);
|
||||
|
||||
VP_EXPORT int VpException(unsigned short f,char *str,int always);
|
||||
VP_EXPORT int VpException(unsigned short f,const char *str,int always);
|
||||
VP_EXPORT int VpIsNegDoubleZero(double v);
|
||||
VP_EXPORT U_LONG VpNumOfChars(Real *vp,char *pszFmt);
|
||||
VP_EXPORT U_LONG VpNumOfChars(Real *vp,const char *pszFmt);
|
||||
VP_EXPORT U_LONG VpInit(U_LONG BaseVal);
|
||||
VP_EXPORT void *VpMemAlloc(U_LONG mb);
|
||||
VP_EXPORT void VpFree(Real *pv);
|
||||
VP_EXPORT Real *VpAlloc(U_LONG mx, char *szVal);
|
||||
VP_EXPORT Real *VpAlloc(U_LONG mx, const char *szVal);
|
||||
VP_EXPORT int VpAsgn(Real *c,Real *a,int isw);
|
||||
VP_EXPORT int VpAddSub(Real *c,Real *a,Real *b,int operation);
|
||||
VP_EXPORT int VpMult(Real *c,Real *a,Real *b);
|
||||
|
@ -143,7 +143,7 @@ VP_EXPORT void VpSzMantissa(Real *a,char *psz);
|
|||
VP_EXPORT int VpToSpecialString(Real *a,char *psz,int fPlus);
|
||||
VP_EXPORT void VpToString(Real *a,char *psz,int fFmt,int fPlus);
|
||||
VP_EXPORT void VpToFString(Real *a,char *psz,int fFmt,int fPlus);
|
||||
VP_EXPORT int VpCtoV(Real *a,char *int_chr,U_LONG ni,char *frac,U_LONG nf,char *exp_chr,U_LONG ne);
|
||||
VP_EXPORT int VpCtoV(Real *a,const char *int_chr,U_LONG ni,const char *frac,U_LONG nf,const char *exp_chr,U_LONG ne);
|
||||
VP_EXPORT int VpVtoD(double *d,S_LONG *e,Real *m);
|
||||
VP_EXPORT void VpDtoV(Real *m,double d);
|
||||
VP_EXPORT void VpItoV(Real *m,S_INT ival);
|
||||
|
|
|
@ -90,8 +90,7 @@ no_window()
|
|||
} while (0)
|
||||
|
||||
static void
|
||||
free_window(winp)
|
||||
struct windata *winp;
|
||||
free_window(struct windata *winp)
|
||||
{
|
||||
if (winp->window && winp->window != stdscr) delwin(winp->window);
|
||||
winp->window = 0;
|
||||
|
@ -99,9 +98,7 @@ free_window(winp)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
prep_window(class, window)
|
||||
VALUE class;
|
||||
WINDOW *window;
|
||||
prep_window(VALUE class, WINDOW *window)
|
||||
{
|
||||
VALUE obj;
|
||||
struct windata *winp;
|
||||
|
@ -178,8 +175,7 @@ curses_closed()
|
|||
|
||||
/* def clear */
|
||||
static VALUE
|
||||
curses_clear(obj)
|
||||
VALUE obj;
|
||||
curses_clear(VALUE obj)
|
||||
{
|
||||
curses_stdscr();
|
||||
wclear(stdscr);
|
||||
|
@ -197,8 +193,7 @@ curses_clrtoeol()
|
|||
|
||||
/* def refresh */
|
||||
static VALUE
|
||||
curses_refresh(obj)
|
||||
VALUE obj;
|
||||
curses_refresh(VALUE obj)
|
||||
{
|
||||
curses_stdscr();
|
||||
refresh();
|
||||
|
@ -207,8 +202,7 @@ curses_refresh(obj)
|
|||
|
||||
/* def doupdate */
|
||||
static VALUE
|
||||
curses_doupdate(obj)
|
||||
VALUE obj;
|
||||
curses_doupdate(VALUE obj)
|
||||
{
|
||||
curses_stdscr();
|
||||
#ifdef HAVE_DOUPDATE
|
||||
|
@ -221,8 +215,7 @@ curses_doupdate(obj)
|
|||
|
||||
/* def echo */
|
||||
static VALUE
|
||||
curses_echo(obj)
|
||||
VALUE obj;
|
||||
curses_echo(VALUE obj)
|
||||
{
|
||||
curses_stdscr();
|
||||
echo();
|
||||
|
@ -231,8 +224,7 @@ curses_echo(obj)
|
|||
|
||||
/* def noecho */
|
||||
static VALUE
|
||||
curses_noecho(obj)
|
||||
VALUE obj;
|
||||
curses_noecho(VALUE obj)
|
||||
{
|
||||
curses_stdscr();
|
||||
noecho();
|
||||
|
@ -241,8 +233,7 @@ curses_noecho(obj)
|
|||
|
||||
/* def raw */
|
||||
static VALUE
|
||||
curses_raw(obj)
|
||||
VALUE obj;
|
||||
curses_raw(VALUE obj)
|
||||
{
|
||||
curses_stdscr();
|
||||
raw();
|
||||
|
@ -251,8 +242,7 @@ curses_raw(obj)
|
|||
|
||||
/* def noraw */
|
||||
static VALUE
|
||||
curses_noraw(obj)
|
||||
VALUE obj;
|
||||
curses_noraw(VALUE obj)
|
||||
{
|
||||
curses_stdscr();
|
||||
noraw();
|
||||
|
@ -261,8 +251,7 @@ curses_noraw(obj)
|
|||
|
||||
/* def cbreak */
|
||||
static VALUE
|
||||
curses_cbreak(obj)
|
||||
VALUE obj;
|
||||
curses_cbreak(VALUE obj)
|
||||
{
|
||||
curses_stdscr();
|
||||
cbreak();
|
||||
|
@ -271,8 +260,7 @@ curses_cbreak(obj)
|
|||
|
||||
/* def nocbreak */
|
||||
static VALUE
|
||||
curses_nocbreak(obj)
|
||||
VALUE obj;
|
||||
curses_nocbreak(VALUE obj)
|
||||
{
|
||||
curses_stdscr();
|
||||
nocbreak();
|
||||
|
@ -281,8 +269,7 @@ curses_nocbreak(obj)
|
|||
|
||||
/* def nl */
|
||||
static VALUE
|
||||
curses_nl(obj)
|
||||
VALUE obj;
|
||||
curses_nl(VALUE obj)
|
||||
{
|
||||
curses_stdscr();
|
||||
nl();
|
||||
|
@ -291,8 +278,7 @@ curses_nl(obj)
|
|||
|
||||
/* def nonl */
|
||||
static VALUE
|
||||
curses_nonl(obj)
|
||||
VALUE obj;
|
||||
curses_nonl(VALUE obj)
|
||||
{
|
||||
curses_stdscr();
|
||||
nonl();
|
||||
|
@ -301,8 +287,7 @@ curses_nonl(obj)
|
|||
|
||||
/* def beep */
|
||||
static VALUE
|
||||
curses_beep(obj)
|
||||
VALUE obj;
|
||||
curses_beep(VALUE obj)
|
||||
{
|
||||
#ifdef HAVE_BEEP
|
||||
curses_stdscr();
|
||||
|
@ -313,8 +298,7 @@ curses_beep(obj)
|
|||
|
||||
/* def flash */
|
||||
static VALUE
|
||||
curses_flash(obj)
|
||||
VALUE obj;
|
||||
curses_flash(VALUE obj)
|
||||
{
|
||||
#ifdef HAVE_FLASH
|
||||
curses_stdscr();
|
||||
|
@ -325,9 +309,7 @@ curses_flash(obj)
|
|||
|
||||
/* def ungetch */
|
||||
static VALUE
|
||||
curses_ungetch(obj, ch)
|
||||
VALUE obj;
|
||||
VALUE ch;
|
||||
curses_ungetch(VALUE obj, VALUE ch)
|
||||
{
|
||||
#ifdef HAVE_UNGETCH
|
||||
curses_stdscr();
|
||||
|
@ -340,10 +322,7 @@ curses_ungetch(obj, ch)
|
|||
|
||||
/* def setpos(y, x) */
|
||||
static VALUE
|
||||
curses_setpos(obj, y, x)
|
||||
VALUE obj;
|
||||
VALUE y;
|
||||
VALUE x;
|
||||
curses_setpos(VALUE obj, VALUE y, VALUE x)
|
||||
{
|
||||
curses_stdscr();
|
||||
move(NUM2INT(y), NUM2INT(x));
|
||||
|
@ -352,8 +331,7 @@ curses_setpos(obj, y, x)
|
|||
|
||||
/* def standout */
|
||||
static VALUE
|
||||
curses_standout(obj)
|
||||
VALUE obj;
|
||||
curses_standout(VALUE obj)
|
||||
{
|
||||
standout();
|
||||
return Qnil;
|
||||
|
@ -361,8 +339,7 @@ curses_standout(obj)
|
|||
|
||||
/* def standend */
|
||||
static VALUE
|
||||
curses_standend(obj)
|
||||
VALUE obj;
|
||||
curses_standend(VALUE obj)
|
||||
{
|
||||
standend();
|
||||
return Qnil;
|
||||
|
@ -370,8 +347,7 @@ curses_standend(obj)
|
|||
|
||||
/* def inch */
|
||||
static VALUE
|
||||
curses_inch(obj)
|
||||
VALUE obj;
|
||||
curses_inch(VALUE obj)
|
||||
{
|
||||
curses_stdscr();
|
||||
return CH2FIX(inch());
|
||||
|
@ -379,9 +355,7 @@ curses_inch(obj)
|
|||
|
||||
/* def addch(ch) */
|
||||
static VALUE
|
||||
curses_addch(obj, ch)
|
||||
VALUE obj;
|
||||
VALUE ch;
|
||||
curses_addch(VALUE obj, VALUE ch)
|
||||
{
|
||||
curses_stdscr();
|
||||
addch(NUM2CH(ch));
|
||||
|
@ -390,9 +364,7 @@ curses_addch(obj, ch)
|
|||
|
||||
/* def insch(ch) */
|
||||
static VALUE
|
||||
curses_insch(obj, ch)
|
||||
VALUE obj;
|
||||
VALUE ch;
|
||||
curses_insch(VALUE obj, VALUE ch)
|
||||
{
|
||||
curses_stdscr();
|
||||
insch(NUM2CH(ch));
|
||||
|
@ -401,9 +373,7 @@ curses_insch(obj, ch)
|
|||
|
||||
/* def addstr(str) */
|
||||
static VALUE
|
||||
curses_addstr(obj, str)
|
||||
VALUE obj;
|
||||
VALUE str;
|
||||
curses_addstr(VALUE obj, VALUE str)
|
||||
{
|
||||
curses_stdscr();
|
||||
if (!NIL_P(str)) {
|
||||
|
@ -414,8 +384,7 @@ curses_addstr(obj, str)
|
|||
|
||||
/* def getch */
|
||||
static VALUE
|
||||
curses_getch(obj)
|
||||
VALUE obj;
|
||||
curses_getch(VALUE obj)
|
||||
{
|
||||
rb_read_check(stdin);
|
||||
curses_stdscr();
|
||||
|
@ -424,8 +393,7 @@ curses_getch(obj)
|
|||
|
||||
/* def getstr */
|
||||
static VALUE
|
||||
curses_getstr(obj)
|
||||
VALUE obj;
|
||||
curses_getstr(VALUE obj)
|
||||
{
|
||||
char rtn[1024]; /* This should be big enough.. I hope */
|
||||
|
||||
|
@ -440,8 +408,7 @@ curses_getstr(obj)
|
|||
|
||||
/* def delch */
|
||||
static VALUE
|
||||
curses_delch(obj)
|
||||
VALUE obj;
|
||||
curses_delch(VALUE obj)
|
||||
{
|
||||
delch();
|
||||
return Qnil;
|
||||
|
@ -449,8 +416,7 @@ curses_delch(obj)
|
|||
|
||||
/* def delelteln */
|
||||
static VALUE
|
||||
curses_deleteln(obj)
|
||||
VALUE obj;
|
||||
curses_deleteln(VALUE obj)
|
||||
{
|
||||
#if defined(HAVE_DELETELN) || defined(deleteln)
|
||||
deleteln();
|
||||
|
@ -460,8 +426,7 @@ curses_deleteln(obj)
|
|||
|
||||
/* def insertln */
|
||||
static VALUE
|
||||
curses_insertln(obj)
|
||||
VALUE obj;
|
||||
curses_insertln(VALUE obj)
|
||||
{
|
||||
#if defined(HAVE_INSERTLN) || defined(insertln)
|
||||
insertln();
|
||||
|
@ -471,9 +436,7 @@ curses_insertln(obj)
|
|||
|
||||
/* def keyname */
|
||||
static VALUE
|
||||
curses_keyname(obj, c)
|
||||
VALUE obj;
|
||||
VALUE c;
|
||||
curses_keyname(VALUE obj, VALUE c)
|
||||
{
|
||||
#ifdef HAVE_KEYNAME
|
||||
const char *name;
|
||||
|
@ -768,12 +731,7 @@ window_s_allocate(VALUE class)
|
|||
|
||||
/* def initialize(h, w, top, left) */
|
||||
static VALUE
|
||||
window_initialize(obj, h, w, top, left)
|
||||
VALUE obj;
|
||||
VALUE h;
|
||||
VALUE w;
|
||||
VALUE top;
|
||||
VALUE left;
|
||||
window_initialize(VALUE obj, VALUE h, VALUE w, VALUE top, VALUE left)
|
||||
{
|
||||
struct windata *winp;
|
||||
WINDOW *window;
|
||||
|
@ -791,12 +749,7 @@ window_initialize(obj, h, w, top, left)
|
|||
|
||||
/* def subwin(height, width, top, left) */
|
||||
static VALUE
|
||||
window_subwin(obj, height, width, top, left)
|
||||
VALUE obj;
|
||||
VALUE height;
|
||||
VALUE width;
|
||||
VALUE top;
|
||||
VALUE left;
|
||||
window_subwin(VALUE obj, VALUE height, VALUE width, VALUE top, VALUE left)
|
||||
{
|
||||
struct windata *winp;
|
||||
WINDOW *window;
|
||||
|
@ -816,8 +769,7 @@ window_subwin(obj, height, width, top, left)
|
|||
|
||||
/* def close */
|
||||
static VALUE
|
||||
window_close(obj)
|
||||
VALUE obj;
|
||||
window_close(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -830,8 +782,7 @@ window_close(obj)
|
|||
|
||||
/* def clear */
|
||||
static VALUE
|
||||
window_clear(obj)
|
||||
VALUE obj;
|
||||
window_clear(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -843,8 +794,7 @@ window_clear(obj)
|
|||
|
||||
/* def clrtoeol */
|
||||
static VALUE
|
||||
window_clrtoeol(obj)
|
||||
VALUE obj;
|
||||
window_clrtoeol(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -856,8 +806,7 @@ window_clrtoeol(obj)
|
|||
|
||||
/* def refresh */
|
||||
static VALUE
|
||||
window_refresh(obj)
|
||||
VALUE obj;
|
||||
window_refresh(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -869,8 +818,7 @@ window_refresh(obj)
|
|||
|
||||
/* def noutrefresh */
|
||||
static VALUE
|
||||
window_noutrefresh(obj)
|
||||
VALUE obj;
|
||||
window_noutrefresh(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -886,10 +834,7 @@ window_noutrefresh(obj)
|
|||
|
||||
/* def move(y, x) */
|
||||
static VALUE
|
||||
window_move(obj, y, x)
|
||||
VALUE obj;
|
||||
VALUE y;
|
||||
VALUE x;
|
||||
window_move(VALUE obj, VALUE y, VALUE x)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -901,10 +846,7 @@ window_move(obj, y, x)
|
|||
|
||||
/* def setpos(y, x) */
|
||||
static VALUE
|
||||
window_setpos(obj, y, x)
|
||||
VALUE obj;
|
||||
VALUE y;
|
||||
VALUE x;
|
||||
window_setpos(VALUE obj, VALUE y, VALUE x)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -915,8 +857,7 @@ window_setpos(obj, y, x)
|
|||
|
||||
/* def cury */
|
||||
static VALUE
|
||||
window_cury(obj)
|
||||
VALUE obj;
|
||||
window_cury(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
int x, y;
|
||||
|
@ -928,8 +869,7 @@ window_cury(obj)
|
|||
|
||||
/* def curx */
|
||||
static VALUE
|
||||
window_curx(obj)
|
||||
VALUE obj;
|
||||
window_curx(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
int x, y;
|
||||
|
@ -941,8 +881,7 @@ window_curx(obj)
|
|||
|
||||
/* def maxy */
|
||||
static VALUE
|
||||
window_maxy(obj)
|
||||
VALUE obj;
|
||||
window_maxy(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -962,8 +901,7 @@ window_maxy(obj)
|
|||
|
||||
/* def maxx */
|
||||
static VALUE
|
||||
window_maxx(obj)
|
||||
VALUE obj;
|
||||
window_maxx(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -983,8 +921,7 @@ window_maxx(obj)
|
|||
|
||||
/* def begy */
|
||||
static VALUE
|
||||
window_begy(obj)
|
||||
VALUE obj;
|
||||
window_begy(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
int x, y;
|
||||
|
@ -1000,8 +937,7 @@ window_begy(obj)
|
|||
|
||||
/* def begx */
|
||||
static VALUE
|
||||
window_begx(obj)
|
||||
VALUE obj;
|
||||
window_begx(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
int x, y;
|
||||
|
@ -1053,8 +989,7 @@ window_box(argc, argv, self)
|
|||
|
||||
/* def standout */
|
||||
static VALUE
|
||||
window_standout(obj)
|
||||
VALUE obj;
|
||||
window_standout(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -1065,8 +1000,7 @@ window_standout(obj)
|
|||
|
||||
/* def standend */
|
||||
static VALUE
|
||||
window_standend(obj)
|
||||
VALUE obj;
|
||||
window_standend(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -1077,8 +1011,7 @@ window_standend(obj)
|
|||
|
||||
/* def inch */
|
||||
static VALUE
|
||||
window_inch(obj)
|
||||
VALUE obj;
|
||||
window_inch(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -1088,9 +1021,7 @@ window_inch(obj)
|
|||
|
||||
/* def addch(ch) */
|
||||
static VALUE
|
||||
window_addch(obj, ch)
|
||||
VALUE obj;
|
||||
VALUE ch;
|
||||
window_addch(VALUE obj, VALUE ch)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -1102,9 +1033,7 @@ window_addch(obj, ch)
|
|||
|
||||
/* def insch(ch) */
|
||||
static VALUE
|
||||
window_insch(obj, ch)
|
||||
VALUE obj;
|
||||
VALUE ch;
|
||||
window_insch(VALUE obj, VALUE ch)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -1116,9 +1045,7 @@ window_insch(obj, ch)
|
|||
|
||||
/* def addstr(str) */
|
||||
static VALUE
|
||||
window_addstr(obj, str)
|
||||
VALUE obj;
|
||||
VALUE str;
|
||||
window_addstr(VALUE obj, VALUE str)
|
||||
{
|
||||
if (!NIL_P(str)) {
|
||||
struct windata *winp;
|
||||
|
@ -1131,9 +1058,7 @@ window_addstr(obj, str)
|
|||
|
||||
/* def <<(str) */
|
||||
static VALUE
|
||||
window_addstr2(obj, str)
|
||||
VALUE obj;
|
||||
VALUE str;
|
||||
window_addstr2(VALUE obj, VALUE str)
|
||||
{
|
||||
window_addstr(obj, str);
|
||||
return obj;
|
||||
|
@ -1141,8 +1066,7 @@ window_addstr2(obj, str)
|
|||
|
||||
/* def getch */
|
||||
static VALUE
|
||||
window_getch(obj)
|
||||
VALUE obj;
|
||||
window_getch(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -1153,8 +1077,7 @@ window_getch(obj)
|
|||
|
||||
/* def getstr */
|
||||
static VALUE
|
||||
window_getstr(obj)
|
||||
VALUE obj;
|
||||
window_getstr(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
char rtn[1024]; /* This should be big enough.. I hope */
|
||||
|
@ -1171,8 +1094,7 @@ window_getstr(obj)
|
|||
|
||||
/* def delch */
|
||||
static VALUE
|
||||
window_delch(obj)
|
||||
VALUE obj;
|
||||
window_delch(VALUE obj)
|
||||
{
|
||||
struct windata *winp;
|
||||
|
||||
|
@ -1183,8 +1105,7 @@ window_delch(obj)
|
|||
|
||||
/* def delelteln */
|
||||
static VALUE
|
||||
window_deleteln(obj)
|
||||
VALUE obj;
|
||||
window_deleteln(VALUE obj)
|
||||
{
|
||||
#if defined(HAVE_WDELETELN) || defined(wdeleteln)
|
||||
struct windata *winp;
|
||||
|
@ -1197,8 +1118,7 @@ window_deleteln(obj)
|
|||
|
||||
/* def insertln */
|
||||
static VALUE
|
||||
window_insertln(obj)
|
||||
VALUE obj;
|
||||
window_insertln(VALUE obj)
|
||||
{
|
||||
#if defined(HAVE_WINSERTLN) || defined(winsertln)
|
||||
struct windata *winp;
|
||||
|
|
|
@ -70,8 +70,7 @@ safe_setup_str(str)
|
|||
|
||||
#ifdef HAVE_GETPWENT
|
||||
static VALUE
|
||||
setup_passwd(pwd)
|
||||
struct passwd *pwd;
|
||||
setup_passwd(struct passwd *pwd)
|
||||
{
|
||||
if (pwd == 0) rb_sys_fail("/etc/passwd");
|
||||
return rb_struct_new(sPasswd,
|
||||
|
@ -119,10 +118,7 @@ setup_passwd(pwd)
|
|||
* passwd="x", uid=0, gid=0, gecos="root",dir="/root", shell="/bin/bash">
|
||||
*/
|
||||
static VALUE
|
||||
etc_getpwuid(argc, argv, obj)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE obj;
|
||||
etc_getpwuid(int argc, VALUE *argv, VALUE obj)
|
||||
{
|
||||
#if defined(HAVE_GETPWENT)
|
||||
VALUE id;
|
||||
|
@ -153,8 +149,7 @@ etc_getpwuid(argc, argv, obj)
|
|||
* passwd="x", uid=0, gid=0, gecos="root",dir="/root", shell="/bin/bash">
|
||||
*/
|
||||
static VALUE
|
||||
etc_getpwnam(obj, nam)
|
||||
VALUE obj, nam;
|
||||
etc_getpwnam(VALUE obj, VALUE nam)
|
||||
{
|
||||
#ifdef HAVE_GETPWENT
|
||||
struct passwd *pwd;
|
||||
|
@ -207,8 +202,7 @@ passwd_iterate()
|
|||
*
|
||||
*/
|
||||
static VALUE
|
||||
etc_passwd(obj)
|
||||
VALUE obj;
|
||||
etc_passwd(VALUE obj)
|
||||
{
|
||||
#ifdef HAVE_GETPWENT
|
||||
struct passwd *pw;
|
||||
|
@ -232,8 +226,7 @@ etc_passwd(obj)
|
|||
* to getpwent will return the first entry again.
|
||||
*/
|
||||
static VALUE
|
||||
etc_setpwent(obj)
|
||||
VALUE obj;
|
||||
etc_setpwent(VALUE obj)
|
||||
{
|
||||
#ifdef HAVE_GETPWENT
|
||||
setpwent();
|
||||
|
@ -245,8 +238,7 @@ etc_setpwent(obj)
|
|||
* getpwent, and closes the file.
|
||||
*/
|
||||
static VALUE
|
||||
etc_endpwent(obj)
|
||||
VALUE obj;
|
||||
etc_endpwent(VALUE obj)
|
||||
{
|
||||
#ifdef HAVE_GETPWENT
|
||||
endpwent();
|
||||
|
@ -281,8 +273,7 @@ etc_endpwent(obj)
|
|||
* - Passwd#shell contains the path to the login shell of the user as a String.
|
||||
*/
|
||||
static VALUE
|
||||
etc_getpwent(obj)
|
||||
VALUE obj;
|
||||
etc_getpwent(VALUE obj)
|
||||
{
|
||||
#ifdef HAVE_GETPWENT
|
||||
struct passwd *pw;
|
||||
|
@ -296,8 +287,7 @@ etc_getpwent(obj)
|
|||
|
||||
#ifdef HAVE_GETGRENT
|
||||
static VALUE
|
||||
setup_group(grp)
|
||||
struct group *grp;
|
||||
setup_group(struct group *grp)
|
||||
{
|
||||
VALUE mem;
|
||||
char **tbl;
|
||||
|
@ -329,8 +319,7 @@ setup_group(grp)
|
|||
*
|
||||
*/
|
||||
static VALUE
|
||||
etc_getgrgid(obj, id)
|
||||
VALUE obj, id;
|
||||
etc_getgrgid(VALUE obj, VALUE id)
|
||||
{
|
||||
#ifdef HAVE_GETGRENT
|
||||
int gid;
|
||||
|
@ -357,8 +346,7 @@ etc_getgrgid(obj, id)
|
|||
*
|
||||
*/
|
||||
static VALUE
|
||||
etc_getgrnam(obj, nam)
|
||||
VALUE obj, nam;
|
||||
etc_getgrnam(VALUE obj, VALUE nam)
|
||||
{
|
||||
#ifdef HAVE_GETGRENT
|
||||
struct group *grp;
|
||||
|
@ -412,8 +400,7 @@ group_iterate()
|
|||
*
|
||||
*/
|
||||
static VALUE
|
||||
etc_group(obj)
|
||||
VALUE obj;
|
||||
etc_group(VALUE obj)
|
||||
{
|
||||
#ifdef HAVE_GETGRENT
|
||||
struct group *grp;
|
||||
|
@ -437,8 +424,7 @@ etc_group(obj)
|
|||
* to getgrent will return the first entry again.
|
||||
*/
|
||||
static VALUE
|
||||
etc_setgrent(obj)
|
||||
VALUE obj;
|
||||
etc_setgrent(VALUE obj)
|
||||
{
|
||||
#ifdef HAVE_GETGRENT
|
||||
setgrent();
|
||||
|
@ -450,8 +436,7 @@ etc_setgrent(obj)
|
|||
* getgrent, and closes the file.
|
||||
*/
|
||||
static VALUE
|
||||
etc_endgrent(obj)
|
||||
VALUE obj;
|
||||
etc_endgrent(VALUE obj)
|
||||
{
|
||||
#ifdef HAVE_GETGRENT
|
||||
endgrent();
|
||||
|
@ -480,8 +465,7 @@ etc_endgrent(obj)
|
|||
* members of the group.
|
||||
*/
|
||||
static VALUE
|
||||
etc_getgrent(obj)
|
||||
VALUE obj;
|
||||
etc_getgrent(VALUE obj)
|
||||
{
|
||||
#ifdef HAVE_GETGRENT
|
||||
struct group *gr;
|
||||
|
|
|
@ -233,7 +233,7 @@ def parse_args()
|
|||
opts.on('--make=MAKE') do |v|
|
||||
$make = v || 'make'
|
||||
end
|
||||
opts.on('--make-flags=FLAGS', '--mflags', Shellwords) do |v|
|
||||
opts.on('--make-flags=FLAGS', '--mflags', Shellwords) do |*v|
|
||||
v.grep(/\A([-\w]+)=(.*)/) {$configure_args["--#{$1}"] = $2}
|
||||
if arg = v.first
|
||||
arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
|
||||
|
@ -258,7 +258,7 @@ def parse_args()
|
|||
$mflags.unshift(*rest) unless rest.empty?
|
||||
|
||||
def $mflags.set?(flag)
|
||||
grep(/\A-(?!-).*#{'%c' % flag}/i) { return true }
|
||||
grep(/\A-(?!-).*#{'%s' % flag}/i) { return true }
|
||||
false
|
||||
end
|
||||
def $mflags.defined?(var)
|
||||
|
|
|
@ -166,7 +166,7 @@ iconv_create(VALUE to, VALUE from, struct rb_iconv_opt_t *opt)
|
|||
}
|
||||
if (cd == (iconv_t)-1) {
|
||||
int inval = errno == EINVAL;
|
||||
char *s = inval ? "invalid encoding " : "iconv";
|
||||
const char *s = inval ? "invalid encoding " : "iconv";
|
||||
volatile VALUE msg = rb_str_new(0, strlen(s) + RSTRING(to)->len +
|
||||
RSTRING(from)->len + 8);
|
||||
|
||||
|
|
|
@ -75,8 +75,7 @@ struct wait_readable_arg {
|
|||
|
||||
#ifdef HAVE_RB_FD_INIT
|
||||
static VALUE
|
||||
wait_readable(p)
|
||||
VALUE p;
|
||||
wait_readable(VALUE p)
|
||||
{
|
||||
struct wait_readable_arg *arg = (struct wait_readable_arg *)p;
|
||||
rb_fdset_t *fds = &arg->fds;
|
||||
|
|
|
@ -1902,18 +1902,14 @@ const int score_table_F0[] = {
|
|||
SCORE_DEPEND, SCORE_NO_EXIST, SCORE_NO_EXIST, SCORE_ERROR,
|
||||
};
|
||||
|
||||
void set_code_score(ptr, score)
|
||||
struct input_code *ptr;
|
||||
int score;
|
||||
void set_code_score(struct input_code *ptr, int score)
|
||||
{
|
||||
if (ptr){
|
||||
ptr->score |= score;
|
||||
}
|
||||
}
|
||||
|
||||
void clr_code_score(ptr, score)
|
||||
struct input_code *ptr;
|
||||
int score;
|
||||
void clr_code_score(struct input_code *ptr, int score)
|
||||
{
|
||||
if (ptr){
|
||||
ptr->score &= ~score;
|
||||
|
@ -1944,8 +1940,7 @@ void code_score(ptr)
|
|||
}
|
||||
}
|
||||
|
||||
void status_disable(ptr)
|
||||
struct input_code *ptr;
|
||||
void status_disable(struct input_code *ptr)
|
||||
{
|
||||
ptr->stat = -1;
|
||||
ptr->buf[0] = -1;
|
||||
|
@ -1953,46 +1948,37 @@ struct input_code *ptr;
|
|||
if (iconv == ptr->iconv_func) set_iconv(FALSE, 0);
|
||||
}
|
||||
|
||||
void status_push_ch(ptr, c)
|
||||
struct input_code *ptr;
|
||||
int c;
|
||||
void status_push_ch(struct input_code *ptr, int c)
|
||||
{
|
||||
ptr->buf[ptr->index++] = c;
|
||||
}
|
||||
|
||||
void status_clear(ptr)
|
||||
struct input_code *ptr;
|
||||
void status_clear(struct input_code *ptr)
|
||||
{
|
||||
ptr->stat = 0;
|
||||
ptr->index = 0;
|
||||
}
|
||||
|
||||
void status_reset(ptr)
|
||||
struct input_code *ptr;
|
||||
void status_reset(struct input_code *ptr)
|
||||
{
|
||||
status_clear(ptr);
|
||||
ptr->score = SCORE_INIT;
|
||||
}
|
||||
|
||||
void status_reinit(ptr)
|
||||
struct input_code *ptr;
|
||||
void status_reinit(struct input_code *ptr)
|
||||
{
|
||||
status_reset(ptr);
|
||||
ptr->_file_stat = 0;
|
||||
}
|
||||
|
||||
void status_check(ptr, c)
|
||||
struct input_code *ptr;
|
||||
int c;
|
||||
void status_check(struct input_code *ptr, int c)
|
||||
{
|
||||
if (c <= DEL && estab_f){
|
||||
status_reset(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void s_status(ptr, c)
|
||||
struct input_code *ptr;
|
||||
int c;
|
||||
void s_status(struct input_code *ptr, int c)
|
||||
{
|
||||
switch(ptr->stat){
|
||||
case -1:
|
||||
|
@ -3062,9 +3048,7 @@ w_iconv(c2, c1, c0)
|
|||
|
||||
#if defined(UTF8_INPUT_ENABLE) || defined(UTF8_OUTPUT_ENABLE)
|
||||
void
|
||||
w16w_conv(val, p2, p1, p0)
|
||||
unsigned short val;
|
||||
int *p2, *p1, *p0;
|
||||
w16w_conv(unsigned short val, int *p2, int *p1, int *p0)
|
||||
{
|
||||
if (val < 0x80){
|
||||
*p2 = val;
|
||||
|
@ -3771,9 +3755,7 @@ s_oconv(c2, c1)
|
|||
}
|
||||
|
||||
void
|
||||
j_oconv(c2, c1)
|
||||
int c2,
|
||||
c1;
|
||||
j_oconv(int c2, int c1)
|
||||
{
|
||||
#ifdef NUMCHAR_OPTION
|
||||
if (c2 == 0 && (c1 & CLASS_MASK) == CLASS_UTF16){
|
||||
|
@ -3858,9 +3840,7 @@ j_oconv(c2, c1)
|
|||
}
|
||||
|
||||
void
|
||||
base64_conv(c2, c1)
|
||||
int c2,
|
||||
c1;
|
||||
base64_conv(int c2, int c1)
|
||||
{
|
||||
mime_prechar(c2, c1);
|
||||
(*o_base64conv)(c2,c1);
|
||||
|
@ -3871,8 +3851,7 @@ STATIC int broken_buf[3];
|
|||
STATIC int broken_counter = 0;
|
||||
STATIC int broken_last = 0;
|
||||
int
|
||||
broken_getc(f)
|
||||
FILE *f;
|
||||
broken_getc(FILE *f)
|
||||
{
|
||||
int c,c1;
|
||||
|
||||
|
@ -3911,9 +3890,7 @@ FILE *f;
|
|||
}
|
||||
|
||||
int
|
||||
broken_ungetc(c,f)
|
||||
int c;
|
||||
FILE *f;
|
||||
broken_ungetc(int c, FILE *f)
|
||||
{
|
||||
if (broken_counter<2)
|
||||
broken_buf[broken_counter++]=c;
|
||||
|
@ -3923,8 +3900,7 @@ FILE *f;
|
|||
STATIC int prev_cr = 0;
|
||||
|
||||
void
|
||||
cr_conv(c2,c1)
|
||||
int c2,c1;
|
||||
cr_conv(int c2, int c1)
|
||||
{
|
||||
if (prev_cr) {
|
||||
prev_cr = 0;
|
||||
|
@ -3972,8 +3948,7 @@ int c2,c1;
|
|||
#define char_size(c2,c1) (c2?2:1)
|
||||
|
||||
void
|
||||
fold_conv(c2,c1)
|
||||
int c2,c1;
|
||||
fold_conv(int c2, int c1)
|
||||
{
|
||||
int prev0;
|
||||
int fold_state=0;
|
||||
|
@ -4146,8 +4121,7 @@ int c2,c1;
|
|||
int z_prev2=0,z_prev1=0;
|
||||
|
||||
void
|
||||
z_conv(c2,c1)
|
||||
int c2,c1;
|
||||
z_conv(int c2, int c1)
|
||||
{
|
||||
|
||||
/* if (c2) c1 &= 0x7f; assertion */
|
||||
|
@ -4237,8 +4211,7 @@ int c2,c1;
|
|||
)
|
||||
|
||||
void
|
||||
rot_conv(c2,c1)
|
||||
int c2,c1;
|
||||
rot_conv(int c2, int c1)
|
||||
{
|
||||
if (c2==0 || c2==X0201 || c2==ISO8859_1) {
|
||||
c1 = rot13(c1);
|
||||
|
@ -4250,8 +4223,7 @@ int c2,c1;
|
|||
}
|
||||
|
||||
void
|
||||
hira_conv(c2,c1)
|
||||
int c2,c1;
|
||||
hira_conv(int c2, int c1)
|
||||
{
|
||||
if ((hira_f & 1) && c2==0x25 && 0x20<c1 && c1<0x74) {
|
||||
c2 = 0x24;
|
||||
|
@ -4263,8 +4235,7 @@ int c2,c1;
|
|||
|
||||
|
||||
void
|
||||
iso2022jp_check_conv(c2,c1)
|
||||
int c2, c1;
|
||||
iso2022jp_check_conv(int c2, int c1)
|
||||
{
|
||||
STATIC const int range[RANGE_NUM_MAX][2] = {
|
||||
{0x222f, 0x2239,},
|
||||
|
@ -4386,8 +4357,7 @@ unswitch_mime_getc()
|
|||
}
|
||||
|
||||
int
|
||||
mime_begin_strict(f)
|
||||
FILE *f;
|
||||
mime_begin_strict(FILE *f)
|
||||
{
|
||||
int c1 = 0;
|
||||
int i,j,k;
|
||||
|
@ -4437,8 +4407,7 @@ FILE *f;
|
|||
}
|
||||
|
||||
int
|
||||
mime_getc_buf(f)
|
||||
FILE *f;
|
||||
mime_getc_buf(FILE *f)
|
||||
{
|
||||
/* we don't keep eof of Fifo, becase it contains ?= as
|
||||
a terminator. It was checked in mime_integrity. */
|
||||
|
@ -4447,9 +4416,7 @@ FILE *f;
|
|||
}
|
||||
|
||||
int
|
||||
mime_ungetc_buf(c,f)
|
||||
FILE *f;
|
||||
int c;
|
||||
mime_ungetc_buf(int c, FILE *f)
|
||||
{
|
||||
if (mimebuf_f)
|
||||
(*i_mungetc_buf)(c,f);
|
||||
|
@ -4459,8 +4426,7 @@ int c;
|
|||
}
|
||||
|
||||
int
|
||||
mime_begin(f)
|
||||
FILE *f;
|
||||
mime_begin(FILE *f)
|
||||
{
|
||||
int c1;
|
||||
int i,k;
|
||||
|
@ -4518,8 +4484,7 @@ FILE *f;
|
|||
|
||||
#ifdef CHECK_OPTION
|
||||
void
|
||||
no_putc(c)
|
||||
int c;
|
||||
no_putc(int c)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
@ -4534,8 +4499,7 @@ void debug(str)
|
|||
#endif
|
||||
|
||||
void
|
||||
set_input_codename (codename)
|
||||
char *codename;
|
||||
set_input_codename (char *codename)
|
||||
{
|
||||
if (guess_f &&
|
||||
is_inputcode_set &&
|
||||
|
@ -4550,8 +4514,7 @@ set_input_codename (codename)
|
|||
|
||||
#if !defined(PERL_XS) && !defined(WIN32DLL)
|
||||
void
|
||||
print_guessed_code (filename)
|
||||
char *filename;
|
||||
print_guessed_code (char *filename)
|
||||
{
|
||||
char *codename = "BINARY";
|
||||
if (!is_inputcode_mixed) {
|
||||
|
@ -4599,31 +4562,25 @@ hex_getc(ch, f, g, u)
|
|||
}
|
||||
|
||||
int
|
||||
cap_getc(f)
|
||||
FILE *f;
|
||||
cap_getc(FILE *f)
|
||||
{
|
||||
return hex_getc(':', f, i_cgetc, i_cungetc);
|
||||
}
|
||||
|
||||
int
|
||||
cap_ungetc(c, f)
|
||||
int c;
|
||||
FILE *f;
|
||||
cap_ungetc(int c, FILE *f)
|
||||
{
|
||||
return (*i_cungetc)(c, f);
|
||||
}
|
||||
|
||||
int
|
||||
url_getc(f)
|
||||
FILE *f;
|
||||
url_getc(FILE *f)
|
||||
{
|
||||
return hex_getc('%', f, i_ugetc, i_uungetc);
|
||||
}
|
||||
|
||||
int
|
||||
url_ungetc(c, f)
|
||||
int c;
|
||||
FILE *f;
|
||||
url_ungetc(int c, FILE *f)
|
||||
{
|
||||
return (*i_uungetc)(c, f);
|
||||
}
|
||||
|
@ -4631,8 +4588,7 @@ url_ungetc(c, f)
|
|||
|
||||
#ifdef NUMCHAR_OPTION
|
||||
int
|
||||
numchar_getc(f)
|
||||
FILE *f;
|
||||
numchar_getc(FILE *f)
|
||||
{
|
||||
int (*g)() = i_ngetc;
|
||||
int (*u)() = i_nungetc;
|
||||
|
@ -4698,8 +4654,7 @@ numchar_ungetc(c, f)
|
|||
|
||||
/* Normalization Form C */
|
||||
int
|
||||
nfc_getc(f)
|
||||
FILE *f;
|
||||
nfc_getc(FILE *f)
|
||||
{
|
||||
int (*g)() = i_nfc_getc;
|
||||
int (*u)() = i_nfc_ungetc;
|
||||
|
@ -5185,8 +5140,7 @@ eof_mime()
|
|||
}
|
||||
|
||||
void
|
||||
mimeout_addchar(c)
|
||||
int c;
|
||||
mimeout_addchar(int c)
|
||||
{
|
||||
switch(mimeout_mode) {
|
||||
case 'Q':
|
||||
|
|
|
@ -56,8 +56,7 @@ static int incsize;
|
|||
static VALUE result;
|
||||
|
||||
static int
|
||||
rb_nkf_putchar(c)
|
||||
unsigned int c;
|
||||
rb_nkf_putchar(unsigned int c)
|
||||
{
|
||||
if (output_ctr >= o_len) {
|
||||
o_len += incsize;
|
||||
|
@ -78,8 +77,7 @@ rb_nkf_putchar(c)
|
|||
#include "nkf-utf8/utf8tbl.c"
|
||||
#include "nkf-utf8/nkf.c"
|
||||
|
||||
int nkf_split_options(arg)
|
||||
const char* arg;
|
||||
int nkf_split_options(const char *arg)
|
||||
{
|
||||
int count = 0;
|
||||
char option[256];
|
||||
|
@ -142,8 +140,7 @@ int nkf_split_options(arg)
|
|||
*/
|
||||
|
||||
static VALUE
|
||||
rb_nkf_kconv(obj, opt, src)
|
||||
VALUE obj, opt, src;
|
||||
rb_nkf_kconv(VALUE obj, VALUE opt, VALUE src)
|
||||
{
|
||||
char *opt_ptr, *opt_end;
|
||||
volatile VALUE v;
|
||||
|
@ -205,8 +202,7 @@ rb_nkf_kconv(obj, opt, src)
|
|||
*/
|
||||
|
||||
static VALUE
|
||||
rb_nkf_guess1(obj, src)
|
||||
VALUE obj, src;
|
||||
rb_nkf_guess1(VALUE obj, VALUE src)
|
||||
{
|
||||
unsigned char *p;
|
||||
unsigned char *pend;
|
||||
|
@ -319,8 +315,7 @@ rb_nkf_guess1(obj, src)
|
|||
*/
|
||||
|
||||
static VALUE
|
||||
rb_nkf_guess2(obj, src)
|
||||
VALUE obj, src;
|
||||
rb_nkf_guess2(VALUE obj, VALUE src)
|
||||
{
|
||||
int code = _BINARY;
|
||||
|
||||
|
|
|
@ -445,7 +445,7 @@ decode_time(unsigned char* der, int length)
|
|||
/********/
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
const char *name;
|
||||
VALUE *klass;
|
||||
} ossl_asn1_info_t;
|
||||
|
||||
|
|
|
@ -335,7 +335,7 @@ static int
|
|||
ossl_pkcs7_sym2typeid(VALUE sym)
|
||||
{
|
||||
int i, ret = Qnil;
|
||||
char *s;
|
||||
const char *s;
|
||||
|
||||
static struct {
|
||||
const char *name;
|
||||
|
|
|
@ -62,7 +62,7 @@ VALUE cSSLSocket;
|
|||
#define ossl_sslctx_get_tmp_dh_cb(o) rb_iv_get((o),"@tmp_dh_callback")
|
||||
#define ossl_sslctx_get_sess_id_ctx(o) rb_iv_get((o),"@session_id_context")
|
||||
|
||||
static char *ossl_sslctx_attrs[] = {
|
||||
static const char *ossl_sslctx_attrs[] = {
|
||||
"cert", "key", "client_ca", "ca_file", "ca_path",
|
||||
"timeout", "verify_mode", "verify_depth",
|
||||
"verify_callback", "options", "cert_store", "extra_chain_cert",
|
||||
|
@ -83,8 +83,8 @@ static char *ossl_sslctx_attrs[] = {
|
|||
#define ossl_ssl_set_key(o,v) rb_iv_set((o),"@key",(v))
|
||||
#define ossl_ssl_set_tmp_dh(o,v) rb_iv_set((o),"@tmp_dh",(v))
|
||||
|
||||
static char *ossl_ssl_attr_readers[] = { "io", "context", };
|
||||
static char *ossl_ssl_attrs[] = { "sync_close", };
|
||||
static const char *ossl_ssl_attr_readers[] = { "io", "context", };
|
||||
static const char *ossl_ssl_attrs[] = { "sync_close", };
|
||||
|
||||
/*
|
||||
* SSLContext class
|
||||
|
@ -144,7 +144,7 @@ ossl_sslctx_initialize(int argc, VALUE *argv, VALUE self)
|
|||
SSL_METHOD *method = NULL;
|
||||
SSL_CTX *ctx;
|
||||
int i;
|
||||
char *s;
|
||||
const char *s;
|
||||
|
||||
for(i = 0; i < numberof(ossl_sslctx_attrs); i++){
|
||||
char buf[32];
|
||||
|
|
|
@ -118,8 +118,7 @@ static char SlaveName[DEVICELEN];
|
|||
static VALUE eChildExited;
|
||||
|
||||
static VALUE
|
||||
echild_status(self)
|
||||
VALUE self;
|
||||
echild_status(VALUE self)
|
||||
{
|
||||
return rb_ivar_get(self, rb_intern("status"));
|
||||
}
|
||||
|
@ -131,9 +130,7 @@ struct pty_info {
|
|||
};
|
||||
|
||||
static void
|
||||
raise_from_wait(state, info)
|
||||
struct pty_info *info;
|
||||
char *state;
|
||||
raise_from_wait(char *state, struct pty_info *info)
|
||||
{
|
||||
extern VALUE rb_last_status;
|
||||
char buf[1024];
|
||||
|
@ -146,8 +143,7 @@ raise_from_wait(state, info)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
pty_syswait(info)
|
||||
struct pty_info *info;
|
||||
pty_syswait(struct pty_info *info)
|
||||
{
|
||||
int cpid, status;
|
||||
|
||||
|
@ -184,17 +180,13 @@ struct exec_info {
|
|||
};
|
||||
|
||||
static VALUE
|
||||
pty_exec(arg)
|
||||
struct exec_info *arg;
|
||||
pty_exec(struct exec_info *arg)
|
||||
{
|
||||
return rb_f_exec(arg->argc, arg->argv);
|
||||
}
|
||||
|
||||
static void
|
||||
establishShell(argc, argv, info)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
struct pty_info *info;
|
||||
establishShell(int argc, VALUE *argv, struct pty_info *info)
|
||||
{
|
||||
static int i,master,slave,currentPid;
|
||||
char *p,*getenv();
|
||||
|
@ -295,8 +287,7 @@ establishShell(argc, argv, info)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
pty_finalize_syswait(info)
|
||||
struct pty_info *info;
|
||||
pty_finalize_syswait(struct pty_info *info)
|
||||
{
|
||||
rb_thread_kill(info->thread);
|
||||
rb_funcall(info->thread, rb_intern("value"), 0);
|
||||
|
@ -310,8 +301,7 @@ pty_finalize_syswait(info)
|
|||
* or the same interface function.
|
||||
*/
|
||||
static void
|
||||
getDevice(master,slave)
|
||||
int *master,*slave;
|
||||
getDevice(int *master, int *slave)
|
||||
{
|
||||
if (openpty(master, slave, SlaveName,
|
||||
(struct termios *)0, (struct winsize *)0) == -1) {
|
||||
|
@ -321,8 +311,7 @@ getDevice(master,slave)
|
|||
#else /* HAVE_OPENPTY */
|
||||
#ifdef HAVE__GETPTY
|
||||
static void
|
||||
getDevice(master,slave)
|
||||
int *master,*slave;
|
||||
getDevice(int *master, int *slave)
|
||||
{
|
||||
char *name;
|
||||
|
||||
|
@ -335,8 +324,7 @@ getDevice(master,slave)
|
|||
}
|
||||
#else /* HAVE__GETPTY */
|
||||
static void
|
||||
getDevice(master,slave)
|
||||
int *master,*slave;
|
||||
getDevice(int *master, int *slave)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
|
@ -407,10 +395,7 @@ freeDevice()
|
|||
|
||||
/* ruby function: getpty */
|
||||
static VALUE
|
||||
pty_getpty(argc, argv, self)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE self;
|
||||
pty_getpty(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE res;
|
||||
struct pty_info info;
|
||||
|
@ -450,8 +435,7 @@ pty_getpty(argc, argv, self)
|
|||
|
||||
/* ruby function: protect_signal - obsolete */
|
||||
static VALUE
|
||||
pty_protect(self)
|
||||
VALUE self;
|
||||
pty_protect(VALUE self)
|
||||
{
|
||||
rb_warn("PTY::protect_signal is no longer needed");
|
||||
rb_yield(Qnil);
|
||||
|
@ -460,8 +444,7 @@ pty_protect(self)
|
|||
|
||||
/* ruby function: reset_signal - obsolete */
|
||||
static VALUE
|
||||
pty_reset_signal(self)
|
||||
VALUE self;
|
||||
pty_reset_signal(VALUE self)
|
||||
{
|
||||
rb_warn("PTY::reset_signal is no longer needed");
|
||||
return self;
|
||||
|
|
|
@ -50,10 +50,7 @@ readline_event()
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_readline(argc, argv, self)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE self;
|
||||
readline_readline(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE tmp, add_hist, result;
|
||||
char *prompt = NULL;
|
||||
|
@ -95,8 +92,7 @@ readline_readline(argc, argv, self)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_set_input(self, input)
|
||||
VALUE self, input;
|
||||
readline_s_set_input(VALUE self, VALUE input)
|
||||
{
|
||||
OpenFile *ifp;
|
||||
|
||||
|
@ -108,8 +104,7 @@ readline_s_set_input(self, input)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_set_output(self, output)
|
||||
VALUE self, output;
|
||||
readline_s_set_output(VALUE self, VALUE output)
|
||||
{
|
||||
OpenFile *ofp;
|
||||
|
||||
|
@ -121,9 +116,7 @@ readline_s_set_output(self, output)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_set_completion_proc(self, proc)
|
||||
VALUE self;
|
||||
VALUE proc;
|
||||
readline_s_set_completion_proc(VALUE self, VALUE proc)
|
||||
{
|
||||
rb_secure(4);
|
||||
if (!rb_respond_to(proc, rb_intern("call")))
|
||||
|
@ -132,35 +125,28 @@ readline_s_set_completion_proc(self, proc)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_get_completion_proc(self)
|
||||
VALUE self;
|
||||
readline_s_get_completion_proc(VALUE self)
|
||||
{
|
||||
rb_secure(4);
|
||||
return rb_attr_get(mReadline, completion_proc);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_set_completion_case_fold(self, val)
|
||||
VALUE self;
|
||||
VALUE val;
|
||||
readline_s_set_completion_case_fold(VALUE self, VALUE val)
|
||||
{
|
||||
rb_secure(4);
|
||||
return rb_ivar_set(mReadline, completion_case_fold, val);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_get_completion_case_fold(self)
|
||||
VALUE self;
|
||||
readline_s_get_completion_case_fold(VALUE self)
|
||||
{
|
||||
rb_secure(4);
|
||||
return rb_attr_get(mReadline, completion_case_fold);
|
||||
}
|
||||
|
||||
static char **
|
||||
readline_attempted_completion_function(text, start, end)
|
||||
const char *text;
|
||||
int start;
|
||||
int end;
|
||||
readline_attempted_completion_function(const char *text, int start, int end)
|
||||
{
|
||||
VALUE proc, ary, temp;
|
||||
char **result;
|
||||
|
@ -224,8 +210,7 @@ readline_attempted_completion_function(text, start, end)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_vi_editing_mode(self)
|
||||
VALUE self;
|
||||
readline_s_vi_editing_mode(VALUE self)
|
||||
{
|
||||
#ifdef HAVE_RL_VI_EDITING_MODE
|
||||
rb_secure(4);
|
||||
|
@ -238,8 +223,7 @@ readline_s_vi_editing_mode(self)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_emacs_editing_mode(self)
|
||||
VALUE self;
|
||||
readline_s_emacs_editing_mode(VALUE self)
|
||||
{
|
||||
#ifdef HAVE_RL_EMACS_EDITING_MODE
|
||||
rb_secure(4);
|
||||
|
@ -252,8 +236,7 @@ readline_s_emacs_editing_mode(self)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_set_completion_append_character(self, str)
|
||||
VALUE self, str;
|
||||
readline_s_set_completion_append_character(VALUE self, VALUE str)
|
||||
{
|
||||
#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
|
||||
rb_secure(4);
|
||||
|
@ -276,8 +259,7 @@ readline_s_set_completion_append_character(self, str)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_get_completion_append_character(self)
|
||||
VALUE self;
|
||||
readline_s_get_completion_append_character(VALUE self)
|
||||
{
|
||||
#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
|
||||
VALUE str;
|
||||
|
@ -296,8 +278,7 @@ readline_s_get_completion_append_character(self)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_set_basic_word_break_characters(self, str)
|
||||
VALUE self, str;
|
||||
readline_s_set_basic_word_break_characters(VALUE self, VALUE str)
|
||||
{
|
||||
#ifdef HAVE_RL_BASIC_WORD_BREAK_CHARACTERS
|
||||
static char *basic_word_break_characters = NULL;
|
||||
|
@ -323,8 +304,7 @@ readline_s_set_basic_word_break_characters(self, str)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_get_basic_word_break_characters(self, str)
|
||||
VALUE self, str;
|
||||
readline_s_get_basic_word_break_characters(VALUE self, VALUE str)
|
||||
{
|
||||
#ifdef HAVE_RL_BASIC_WORD_BREAK_CHARACTERS
|
||||
rb_secure(4);
|
||||
|
@ -338,8 +318,7 @@ readline_s_get_basic_word_break_characters(self, str)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_set_completer_word_break_characters(self, str)
|
||||
VALUE self, str;
|
||||
readline_s_set_completer_word_break_characters(VALUE self, VALUE str)
|
||||
{
|
||||
#ifdef HAVE_RL_COMPLETER_WORD_BREAK_CHARACTERS
|
||||
static char *completer_word_break_characters = NULL;
|
||||
|
@ -365,8 +344,7 @@ readline_s_set_completer_word_break_characters(self, str)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_get_completer_word_break_characters(self, str)
|
||||
VALUE self, str;
|
||||
readline_s_get_completer_word_break_characters(VALUE self, VALUE str)
|
||||
{
|
||||
#ifdef HAVE_RL_COMPLETER_WORD_BREAK_CHARACTERS
|
||||
rb_secure(4);
|
||||
|
@ -380,8 +358,7 @@ readline_s_get_completer_word_break_characters(self, str)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_set_basic_quote_characters(self, str)
|
||||
VALUE self, str;
|
||||
readline_s_set_basic_quote_characters(VALUE self, VALUE str)
|
||||
{
|
||||
#ifdef HAVE_RL_BASIC_QUOTE_CHARACTERS
|
||||
static char *basic_quote_characters = NULL;
|
||||
|
@ -408,8 +385,7 @@ readline_s_set_basic_quote_characters(self, str)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_get_basic_quote_characters(self, str)
|
||||
VALUE self, str;
|
||||
readline_s_get_basic_quote_characters(VALUE self, VALUE str)
|
||||
{
|
||||
#ifdef HAVE_RL_BASIC_QUOTE_CHARACTERS
|
||||
rb_secure(4);
|
||||
|
@ -423,8 +399,7 @@ readline_s_get_basic_quote_characters(self, str)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_set_completer_quote_characters(self, str)
|
||||
VALUE self, str;
|
||||
readline_s_set_completer_quote_characters(VALUE self, VALUE str)
|
||||
{
|
||||
#ifdef HAVE_RL_COMPLETER_QUOTE_CHARACTERS
|
||||
static char *completer_quote_characters = NULL;
|
||||
|
@ -451,8 +426,7 @@ readline_s_set_completer_quote_characters(self, str)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_get_completer_quote_characters(self, str)
|
||||
VALUE self, str;
|
||||
readline_s_get_completer_quote_characters(VALUE self, VALUE str)
|
||||
{
|
||||
#ifdef HAVE_RL_COMPLETER_QUOTE_CHARACTERS
|
||||
rb_secure(4);
|
||||
|
@ -466,8 +440,7 @@ readline_s_get_completer_quote_characters(self, str)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_set_filename_quote_characters(self, str)
|
||||
VALUE self, str;
|
||||
readline_s_set_filename_quote_characters(VALUE self, VALUE str)
|
||||
{
|
||||
#ifdef HAVE_RL_FILENAME_QUOTE_CHARACTERS
|
||||
static char *filename_quote_characters = NULL;
|
||||
|
@ -494,8 +467,7 @@ readline_s_set_filename_quote_characters(self, str)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
readline_s_get_filename_quote_characters(self, str)
|
||||
VALUE self, str;
|
||||
readline_s_get_filename_quote_characters(VALUE self, VALUE str)
|
||||
{
|
||||
#ifdef HAVE_RL_FILENAME_QUOTE_CHARACTERS
|
||||
rb_secure(4);
|
||||
|
@ -509,16 +481,13 @@ readline_s_get_filename_quote_characters(self, str)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
hist_to_s(self)
|
||||
VALUE self;
|
||||
hist_to_s(VALUE self)
|
||||
{
|
||||
return rb_str_new2("HISTORY");
|
||||
}
|
||||
|
||||
static VALUE
|
||||
hist_get(self, index)
|
||||
VALUE self;
|
||||
VALUE index;
|
||||
hist_get(VALUE self, VALUE index)
|
||||
{
|
||||
HIST_ENTRY *entry;
|
||||
int i;
|
||||
|
@ -536,10 +505,7 @@ hist_get(self, index)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
hist_set(self, index, str)
|
||||
VALUE self;
|
||||
VALUE index;
|
||||
VALUE str;
|
||||
hist_set(VALUE self, VALUE index, VALUE str)
|
||||
{
|
||||
#ifdef HAVE_REPLACE_HISTORY_ENTRY
|
||||
HIST_ENTRY *entry;
|
||||
|
@ -563,9 +529,7 @@ hist_set(self, index, str)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
hist_push(self, str)
|
||||
VALUE self;
|
||||
VALUE str;
|
||||
hist_push(VALUE self, VALUE str)
|
||||
{
|
||||
rb_secure(4);
|
||||
SafeStringValue(str);
|
||||
|
@ -574,10 +538,7 @@ hist_push(self, str)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
hist_push_method(argc, argv, self)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE self;
|
||||
hist_push_method(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE str;
|
||||
|
||||
|
@ -591,8 +552,7 @@ hist_push_method(argc, argv, self)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
rb_remove_history(index)
|
||||
int index;
|
||||
rb_remove_history(int index)
|
||||
{
|
||||
#ifdef HAVE_REMOVE_HISTORY
|
||||
HIST_ENTRY *entry;
|
||||
|
@ -614,8 +574,7 @@ rb_remove_history(index)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
hist_pop(self)
|
||||
VALUE self;
|
||||
hist_pop(VALUE self)
|
||||
{
|
||||
rb_secure(4);
|
||||
if (history_length > 0) {
|
||||
|
@ -626,8 +585,7 @@ hist_pop(self)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
hist_shift(self)
|
||||
VALUE self;
|
||||
hist_shift(VALUE self)
|
||||
{
|
||||
rb_secure(4);
|
||||
if (history_length > 0) {
|
||||
|
@ -638,8 +596,7 @@ hist_shift(self)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
hist_each(self)
|
||||
VALUE self;
|
||||
hist_each(VALUE self)
|
||||
{
|
||||
HIST_ENTRY *entry;
|
||||
int i;
|
||||
|
@ -655,25 +612,21 @@ hist_each(self)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
hist_length(self)
|
||||
VALUE self;
|
||||
hist_length(VALUE self)
|
||||
{
|
||||
rb_secure(4);
|
||||
return INT2NUM(history_length);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
hist_empty_p(self)
|
||||
VALUE self;
|
||||
hist_empty_p(VALUE self)
|
||||
{
|
||||
rb_secure(4);
|
||||
return history_length == 0 ? Qtrue : Qfalse;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
hist_delete_at(self, index)
|
||||
VALUE self;
|
||||
VALUE index;
|
||||
hist_delete_at(VALUE self, VALUE index)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -688,9 +641,7 @@ hist_delete_at(self, index)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
filename_completion_proc_call(self, str)
|
||||
VALUE self;
|
||||
VALUE str;
|
||||
filename_completion_proc_call(VALUE self, VALUE str)
|
||||
{
|
||||
VALUE result;
|
||||
char **matches;
|
||||
|
@ -715,9 +666,7 @@ filename_completion_proc_call(self, str)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
username_completion_proc_call(self, str)
|
||||
VALUE self;
|
||||
VALUE str;
|
||||
username_completion_proc_call(VALUE self, VALUE str)
|
||||
{
|
||||
VALUE result;
|
||||
char **matches;
|
||||
|
|
|
@ -265,8 +265,7 @@ static struct token_assoc {
|
|||
};
|
||||
|
||||
static ID
|
||||
ripper_token2eventid(tok)
|
||||
int tok;
|
||||
ripper_token2eventid(int tok)
|
||||
{
|
||||
struct token_assoc *a;
|
||||
|
||||
|
|
|
@ -489,8 +489,7 @@ strio_eof(self)
|
|||
|
||||
/* :nodoc: */
|
||||
static VALUE
|
||||
strio_copy(copy, orig)
|
||||
VALUE copy, orig;
|
||||
strio_copy(VALUE copy, VALUE orig)
|
||||
{
|
||||
struct StringIO *ptr;
|
||||
|
||||
|
@ -559,10 +558,7 @@ strio_set_lineno(self, lineno)
|
|||
* and _mode_ (see StringIO#new).
|
||||
*/
|
||||
static VALUE
|
||||
strio_reopen(argc, argv, self)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE self;
|
||||
strio_reopen(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
if (!OBJ_TAINTED(self)) rb_secure(4);
|
||||
if (argc == 1 && TYPE(*argv) != T_STRING) {
|
||||
|
@ -717,9 +713,7 @@ strio_getc(self)
|
|||
}
|
||||
|
||||
static void
|
||||
strio_extend(ptr, pos, len)
|
||||
struct StringIO *ptr;
|
||||
long pos, len;
|
||||
strio_extend(struct StringIO *ptr, long pos, long len)
|
||||
{
|
||||
long olen;
|
||||
|
||||
|
@ -1149,10 +1143,7 @@ strio_read(argc, argv, self)
|
|||
* returning +nil+, as well as IO#sysread does.
|
||||
*/
|
||||
static VALUE
|
||||
strio_sysread(argc, argv, self)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE self;
|
||||
strio_sysread(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE val = strio_read(argc, argv, self);
|
||||
if (NIL_P(val) || RSTRING(val)->len == 0) {
|
||||
|
|
|
@ -263,8 +263,7 @@ strscan_s_mustc(self)
|
|||
* Reset the scan pointer (index 0) and clear matching data.
|
||||
*/
|
||||
static VALUE
|
||||
strscan_reset(self)
|
||||
VALUE self;
|
||||
strscan_reset(VALUE self)
|
||||
{
|
||||
struct strscanner *p;
|
||||
|
||||
|
@ -600,8 +599,7 @@ strscan_scan_until(self, re)
|
|||
* s.exist? /e/ # -> nil
|
||||
*/
|
||||
static VALUE
|
||||
strscan_exist_p(self, re)
|
||||
VALUE self, re;
|
||||
strscan_exist_p(VALUE self, VALUE re)
|
||||
{
|
||||
return strscan_do_scan(self, re, 0, 0, 0);
|
||||
}
|
||||
|
@ -962,8 +960,7 @@ strscan_matched_size(self)
|
|||
* This method is obsolete; use #matched_size instead.
|
||||
*/
|
||||
static VALUE
|
||||
strscan_matchedsize(self)
|
||||
VALUE self;
|
||||
strscan_matchedsize(VALUE self)
|
||||
{
|
||||
rb_warning("StringScanner#matchedsize is obsolete; use #matched_size instead");
|
||||
return strscan_matched_size(self);
|
||||
|
@ -1084,8 +1081,7 @@ strscan_rest_size(self)
|
|||
* This method is obsolete; use #rest_size instead.
|
||||
*/
|
||||
static VALUE
|
||||
strscan_restsize(self)
|
||||
VALUE self;
|
||||
strscan_restsize(VALUE self)
|
||||
{
|
||||
rb_warning("StringScanner#restsize is obsolete; use #rest_size instead");
|
||||
return strscan_rest_size(self);
|
||||
|
|
|
@ -282,7 +282,7 @@ syck_emitter_clear( SyckEmitter *e )
|
|||
* Raw write to the emitter buffer.
|
||||
*/
|
||||
void
|
||||
syck_emitter_write( SyckEmitter *e, char *str, long len )
|
||||
syck_emitter_write( SyckEmitter *e, const char *str, long len )
|
||||
{
|
||||
long at;
|
||||
ASSERT( str != NULL )
|
||||
|
@ -438,7 +438,7 @@ end_emit:
|
|||
* and the implicit tag which would be assigned to this node. If a tag is
|
||||
* required, write the tag.
|
||||
*/
|
||||
void syck_emit_tag( SyckEmitter *e, char *tag, char *ignore )
|
||||
void syck_emit_tag( SyckEmitter *e, const char *tag, const char *ignore )
|
||||
{
|
||||
SyckLevel *lvl;
|
||||
if ( tag == NULL ) return;
|
||||
|
@ -457,7 +457,7 @@ void syck_emit_tag( SyckEmitter *e, char *tag, char *ignore )
|
|||
int skip = 4 + strlen( YAML_DOMAIN ) + 1;
|
||||
syck_emitter_write( e, tag + skip, taglen - skip );
|
||||
} else {
|
||||
char *subd = tag + 4;
|
||||
const char *subd = tag + 4;
|
||||
while ( *subd != ':' && *subd != '\0' ) subd++;
|
||||
if ( *subd == ':' ) {
|
||||
if ( subd - tag > ( strlen( YAML_DOMAIN ) + 5 ) &&
|
||||
|
@ -559,7 +559,7 @@ syck_scan_scalar( int req_width, char *cursor, long len )
|
|||
}
|
||||
if ( ( cursor[0] == '-' || cursor[0] == ':' ||
|
||||
cursor[0] == '?' || cursor[0] == ',' ) &&
|
||||
( cursor[1] == ' ' || cursor[1] == '\n' || len == 1 ) )
|
||||
( len == 1 || cursor[1] == ' ' || cursor[1] == '\n' ) )
|
||||
{
|
||||
flags |= SCAN_INDIC_S;
|
||||
}
|
||||
|
@ -1221,7 +1221,7 @@ syck_emitter_mark_node( SyckEmitter *e, st_data_t n )
|
|||
if ( ! st_lookup( e->anchors, (st_data_t)oid, (st_data_t *)&anchor_name ) )
|
||||
{
|
||||
int idx = 0;
|
||||
char *anc = ( e->anchor_format == NULL ? DEFAULT_ANCHOR_FORMAT : e->anchor_format );
|
||||
const char *anc = ( e->anchor_format == NULL ? DEFAULT_ANCHOR_FORMAT : e->anchor_format );
|
||||
|
||||
/*
|
||||
* Second time hitting this object, let's give it an anchor
|
||||
|
|
|
@ -155,7 +155,7 @@ syck_xprivate( char *type_id, int type_len )
|
|||
}
|
||||
|
||||
char *
|
||||
syck_taguri( char *domain, char *type_id, int type_len )
|
||||
syck_taguri( const char *domain, const char *type_id, int type_len )
|
||||
{
|
||||
char *uri = S_ALLOC_N( char, strlen( domain ) + type_len + 14 );
|
||||
uri[0] = '\0';
|
||||
|
|
|
@ -1585,7 +1585,7 @@ yy201: ++YYCURSOR;
|
|||
|
||||
/* Remove ending fragment and compare types */
|
||||
int
|
||||
syck_tagcmp( char *tag1, char *tag2 )
|
||||
syck_tagcmp( const char *tag1, const char *tag2 )
|
||||
{
|
||||
if ( tag1 == tag2 ) return 1;
|
||||
if ( tag1 == NULL || tag2 == NULL ) return 0;
|
||||
|
|
|
@ -100,13 +100,13 @@ syck_alloc_str()
|
|||
}
|
||||
|
||||
SyckNode *
|
||||
syck_new_str( char *str, enum scalar_style style )
|
||||
syck_new_str( const char *str, enum scalar_style style )
|
||||
{
|
||||
return syck_new_str2( str, strlen( str ), style );
|
||||
}
|
||||
|
||||
SyckNode *
|
||||
syck_new_str2( char *str, long len, enum scalar_style style )
|
||||
syck_new_str2( const char *str, long len, enum scalar_style style )
|
||||
{
|
||||
SyckNode *n;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ syck_assert( char *file_name, unsigned line_num )
|
|||
* Allocates and copies a string
|
||||
*/
|
||||
char *
|
||||
syck_strndup( char *buf, long len )
|
||||
syck_strndup( const char *buf, long len )
|
||||
{
|
||||
char *new = S_ALLOC_N( char, len + 1 );
|
||||
S_MEMZERO( new, char, len + 1 );
|
||||
|
|
|
@ -346,8 +346,8 @@ void syck_hdlr_remove_anchor( SyckParser *, char * );
|
|||
SyckNode *syck_hdlr_get_anchor( SyckParser *, char * );
|
||||
void syck_add_transfer( char *, SyckNode *, int );
|
||||
char *syck_xprivate( char *, int );
|
||||
char *syck_taguri( char *, char *, int );
|
||||
int syck_tagcmp( char *, char * );
|
||||
char *syck_taguri( const char *, const char *, int );
|
||||
int syck_tagcmp( const char *, const char * );
|
||||
int syck_add_sym( SyckParser *, char * );
|
||||
int syck_lookup_sym( SyckParser *, SYMID, char ** );
|
||||
int syck_try_implicit( SyckNode * );
|
||||
|
@ -358,7 +358,7 @@ char *syck_match_implicit( char *, size_t );
|
|||
/*
|
||||
* API prototypes
|
||||
*/
|
||||
char *syck_strndup( char *, long );
|
||||
char *syck_strndup( const char *, long );
|
||||
long syck_io_file_read( char *, SyckIoFile *, long, long );
|
||||
long syck_io_str_read( char *, SyckIoStr *, long, long );
|
||||
char *syck_base64enc( char *, long );
|
||||
|
@ -370,7 +370,7 @@ void syck_output_handler( SyckEmitter *, SyckOutputHandler );
|
|||
void syck_emitter_handler( SyckEmitter *, SyckEmitterHandler );
|
||||
void syck_free_emitter( SyckEmitter * );
|
||||
void syck_emitter_clear( SyckEmitter * );
|
||||
void syck_emitter_write( SyckEmitter *, char *, long );
|
||||
void syck_emitter_write( SyckEmitter *, const char *, long );
|
||||
void syck_emitter_escape( SyckEmitter *, char *, long );
|
||||
void syck_emitter_flush( SyckEmitter *, long );
|
||||
void syck_emit( SyckEmitter *, st_data_t );
|
||||
|
@ -383,7 +383,7 @@ void syck_emit_seq( SyckEmitter *, char *, enum seq_style );
|
|||
void syck_emit_item( SyckEmitter *, st_data_t );
|
||||
void syck_emit_map( SyckEmitter *, char *, enum map_style );
|
||||
void syck_emit_end( SyckEmitter * );
|
||||
void syck_emit_tag( SyckEmitter *, char *, char * );
|
||||
void syck_emit_tag( SyckEmitter *, const char *, const char * );
|
||||
void syck_emit_indent( SyckEmitter * );
|
||||
SyckLevel *syck_emitter_current_level( SyckEmitter * );
|
||||
SyckLevel *syck_emitter_parent_level( SyckEmitter * );
|
||||
|
@ -421,8 +421,8 @@ SyckNode *syck_alloc_seq();
|
|||
SyckNode *syck_alloc_str();
|
||||
void syck_free_node( SyckNode * );
|
||||
void syck_free_members( SyckNode * );
|
||||
SyckNode *syck_new_str( char *, enum scalar_style );
|
||||
SyckNode *syck_new_str2( char *, long, enum scalar_style );
|
||||
SyckNode *syck_new_str( const char *, enum scalar_style );
|
||||
SyckNode *syck_new_str2( const char *, long, enum scalar_style );
|
||||
void syck_replace_str( SyckNode *, char *, enum scalar_style );
|
||||
void syck_replace_str2( SyckNode *, char *, long, enum scalar_style );
|
||||
void syck_str_blow_away_commas( SyckNode * );
|
||||
|
|
|
@ -145,6 +145,7 @@ syck_yaml2byte_handler(p, n)
|
|||
strcat( type_tag, "!" );
|
||||
strcat( type_tag, n->type_id );
|
||||
bytestring_append( val, YAMLBYTE_TRANSFER, type_tag, NULL);
|
||||
S_FREE(type_tag);
|
||||
}
|
||||
}
|
||||
switch (n->kind)
|
||||
|
|
|
@ -6217,7 +6217,11 @@ lib_fromUTF8_core(ip_obj, src, encodename)
|
|||
char *s;
|
||||
int len;
|
||||
|
||||
<<<<<<< tcltklib.c
|
||||
StringValue(str);
|
||||
=======
|
||||
StringValue(str);
|
||||
>>>>>>> 1.45
|
||||
s = Tcl_GetByteArrayFromObj(Tcl_NewStringObj(RSTRING(str)->ptr,
|
||||
RSTRING(str)->len),
|
||||
&len);
|
||||
|
|
500
ext/zlib/zlib.c
500
ext/zlib/zlib.c
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
8
gc.c
8
gc.c
|
@ -412,6 +412,7 @@ add_heap(void)
|
|||
if (himem < pend) himem = pend;
|
||||
heaps_used++;
|
||||
heap_slots *= 1.8;
|
||||
if (heap_slots <= 0) heap_slots = HEAP_MIN_SLOTS;
|
||||
|
||||
while (p < pend) {
|
||||
p->as.free.flags = 0;
|
||||
|
@ -832,6 +833,7 @@ gc_mark_children(VALUE ptr, int lev)
|
|||
case NODE_MODULE:
|
||||
case NODE_ALIAS:
|
||||
case NODE_VALIAS:
|
||||
case NODE_BLOCK_PASS:
|
||||
gc_mark((VALUE)obj->as.node.u1.node, lev);
|
||||
/* fall through */
|
||||
case NODE_METHOD: /* 2 */
|
||||
|
@ -863,12 +865,10 @@ gc_mark_children(VALUE ptr, int lev)
|
|||
case NODE_COLON2:
|
||||
case NODE_SPLAT:
|
||||
case NODE_TO_ARY:
|
||||
case NODE_SVALUE:
|
||||
ptr = (VALUE)obj->as.node.u1.node;
|
||||
goto again;
|
||||
|
||||
case NODE_SCOPE: /* 2,3 */
|
||||
case NODE_BLOCK_PASS:
|
||||
case NODE_CDECL:
|
||||
gc_mark((VALUE)obj->as.node.u3.node, lev);
|
||||
ptr = (VALUE)obj->as.node.u2.node;
|
||||
|
@ -2066,7 +2066,7 @@ Init_GC(void)
|
|||
rb_global_variable(&nomem_error);
|
||||
nomem_error = rb_exc_new2(rb_eNoMemError, "failed to allocate memory");
|
||||
|
||||
rb_define_method(rb_cBasicObject, "__id__", rb_obj_id, 0);
|
||||
rb_define_method(rb_cBasicObject, "object_id", rb_obj_id, 0);
|
||||
rb_define_method(rb_mKernel, "hash", rb_obj_id, 0);
|
||||
rb_define_method(rb_mKernel, "__id__", rb_obj_id, 0);
|
||||
rb_define_method(rb_mKernel, "object_id", rb_obj_id, 0);
|
||||
}
|
||||
|
|
30
hash.c
30
hash.c
|
@ -33,7 +33,7 @@ rb_hash_freeze(VALUE hash)
|
|||
VALUE rb_cHash;
|
||||
|
||||
static VALUE envtbl;
|
||||
static ID id_hash, id_call, id_default;
|
||||
static ID id_hash, id_yield, id_default;
|
||||
|
||||
static VALUE
|
||||
eql(VALUE *args)
|
||||
|
@ -474,7 +474,7 @@ rb_hash_default(int argc, VALUE *argv, VALUE hash)
|
|||
|
||||
rb_scan_args(argc, argv, "01", &key);
|
||||
if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
|
||||
return rb_funcall(RHASH(hash)->ifnone, id_call, 2, hash, key);
|
||||
return rb_funcall(RHASH(hash)->ifnone, id_yield, 2, hash, key);
|
||||
}
|
||||
return RHASH(hash)->ifnone;
|
||||
}
|
||||
|
@ -656,7 +656,7 @@ rb_hash_shift(VALUE hash)
|
|||
return rb_assoc_new(var.key, var.val);
|
||||
}
|
||||
else if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
|
||||
return rb_funcall(RHASH(hash)->ifnone, id_call, 2, hash, Qnil);
|
||||
return rb_funcall(RHASH(hash)->ifnone, id_yield, 2, hash, Qnil);
|
||||
}
|
||||
else {
|
||||
return RHASH(hash)->ifnone;
|
||||
|
@ -986,7 +986,7 @@ static int
|
|||
each_pair_i(VALUE key, VALUE value)
|
||||
{
|
||||
if (key == Qundef) return ST_CONTINUE;
|
||||
rb_yield_values(2, key, value);
|
||||
rb_yield(rb_assoc_new(key, value));
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -994,11 +994,11 @@ each_pair_i(VALUE key, VALUE value)
|
|||
* call-seq:
|
||||
* hsh.each_pair {| key_value_array | block } -> hsh
|
||||
*
|
||||
* Calls <i>block</i> once for each key in <i>hsh</i>, passing the key
|
||||
* and value as parameters.
|
||||
* Calls <i>block</i> once for each key in <i>hsh</i>, passing the
|
||||
* key and value to the block as a two-element array.
|
||||
*
|
||||
* h = { "a" => 100, "b" => 200 }
|
||||
* h.each_pair {|key, value| puts "#{key} is #{value}" }
|
||||
* h.each_pair {|(key, value)| puts "#{key} is #{value}" }
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
|
@ -1019,7 +1019,7 @@ static int
|
|||
each_i(VALUE key, VALUE value)
|
||||
{
|
||||
if (key == Qundef) return ST_CONTINUE;
|
||||
rb_yield(rb_assoc_new(key, value));
|
||||
rb_yield_values(2, key, value);
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -1027,11 +1027,9 @@ each_i(VALUE key, VALUE value)
|
|||
* call-seq:
|
||||
* hsh.each {| key, value | block } -> hsh
|
||||
*
|
||||
* Calls <i>block</i> once for each key in <i>hsh</i>, passing the key
|
||||
* and value to the block as a two-element array. Because of the assignment
|
||||
* semantics of block parameters, these elements will be split out if the
|
||||
* block has two formal parameters. Also see <code>Hash.each_pair</code>, which
|
||||
* will be marginally more efficient for blocks with two parameters.
|
||||
* Calls <i>block</i> once for each key in <i>hsh</i>, passing the key-value
|
||||
* pair as parameters. Also see <code>Hash#each_pair</code>, which
|
||||
* passes the key and value to the block as a two-element array.
|
||||
*
|
||||
* h = { "a" => 100, "b" => 200 }
|
||||
* h.each {|key, value| puts "#{key} is #{value}" }
|
||||
|
@ -1893,14 +1891,14 @@ static VALUE
|
|||
env_each(VALUE ehash)
|
||||
{
|
||||
RETURN_ENUMERATOR(ehash, 0, 0);
|
||||
return env_each_i(ehash, Qfalse);
|
||||
return env_each_i(ehash, Qtrue);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
env_each_pair(VALUE ehash)
|
||||
{
|
||||
RETURN_ENUMERATOR(ehash, 0, 0);
|
||||
return env_each_i(ehash, Qtrue);
|
||||
return env_each_i(ehash, Qfalse);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -2273,7 +2271,7 @@ void
|
|||
Init_Hash(void)
|
||||
{
|
||||
id_hash = rb_intern("hash");
|
||||
id_call = rb_intern("call");
|
||||
id_yield = rb_intern("yield");
|
||||
id_default = rb_intern("default");
|
||||
|
||||
rb_cHash = rb_define_class("Hash", rb_cObject);
|
||||
|
|
|
@ -25,7 +25,7 @@ def parse_args()
|
|||
opt.on('--dest-dir=DIR') {|dir| $destdir = dir}
|
||||
opt.on('--make=COMMAND') {|make| $make = make}
|
||||
opt.on('--mantype=MAN') {|man| $mantype = man}
|
||||
opt.on('--make-flags=FLAGS', '--mflags', Shellwords) do |v|
|
||||
opt.on('--make-flags=FLAGS', '--mflags', Shellwords) do |*v|
|
||||
if arg = v.first
|
||||
arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
|
||||
end
|
||||
|
@ -38,7 +38,7 @@ def parse_args()
|
|||
$mflags.unshift(*rest) unless rest.empty?
|
||||
|
||||
def $mflags.set?(flag)
|
||||
grep(/\A-(?!-).*#{'%c' % flag}/i) { return true }
|
||||
grep(/\A-(?!-).*#{'%s' % flag}/i) { return true }
|
||||
false
|
||||
end
|
||||
|
||||
|
|
7
intern.h
7
intern.h
|
@ -128,6 +128,7 @@ VALUE rb_class_instance_methods(int, VALUE*, VALUE);
|
|||
VALUE rb_class_public_instance_methods(int, VALUE*, VALUE);
|
||||
VALUE rb_class_protected_instance_methods(int, VALUE*, VALUE);
|
||||
VALUE rb_class_private_instance_methods(int, VALUE*, VALUE);
|
||||
VALUE rb_class_local_methods(VALUE);
|
||||
VALUE rb_obj_singleton_methods(int, VALUE*, VALUE);
|
||||
void rb_define_method_id(VALUE, ID, VALUE (*)(ANYARGS), int);
|
||||
void rb_frozen_class_p(VALUE);
|
||||
|
@ -425,9 +426,9 @@ VALUE rb_range_new(VALUE, VALUE, int);
|
|||
VALUE rb_range_beg_len(VALUE, long*, long*, long, int);
|
||||
VALUE rb_length_by_each(VALUE);
|
||||
/* re.c */
|
||||
int rb_memcmp(char*,char*,long);
|
||||
int rb_memcicmp(char*,char*,long);
|
||||
long rb_memsearch(char*,long,char*,long);
|
||||
int rb_memcmp(const void*,const void*,long);
|
||||
int rb_memcicmp(const void*,const void*,long);
|
||||
long rb_memsearch(const void*,long,const void*,long);
|
||||
VALUE rb_reg_nth_defined(int, VALUE);
|
||||
VALUE rb_reg_nth_match(int, VALUE);
|
||||
VALUE rb_reg_last_match(VALUE);
|
||||
|
|
84
io.c
84
io.c
|
@ -1095,7 +1095,8 @@ static VALUE
|
|||
rb_io_inspect(VALUE obj)
|
||||
{
|
||||
OpenFile *fptr;
|
||||
char *cname, *st = "";
|
||||
char *cname;
|
||||
const char *st = "";
|
||||
|
||||
fptr = RFILE(rb_io_taint_check(obj))->fptr;
|
||||
if (!fptr || !fptr->path) return rb_any_to_s(obj);
|
||||
|
@ -1962,18 +1963,6 @@ rb_io_each_byte(VALUE io)
|
|||
return io;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ios.getc => fixnum or nil
|
||||
*
|
||||
* Gets the next 8-bit byte (0..255) from <em>ios</em>. Returns
|
||||
* <code>nil</code> if called at end of file.
|
||||
*
|
||||
* f = File.new("testfile")
|
||||
* f.getc #=> 84
|
||||
* f.getc #=> 104
|
||||
*/
|
||||
|
||||
VALUE
|
||||
rb_io_getc(VALUE io)
|
||||
{
|
||||
|
@ -1992,6 +1981,38 @@ rb_io_getc(VALUE io)
|
|||
return INT2FIX(c & 0xff);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ios.getc => string or nil
|
||||
*
|
||||
* Reads a one-character string from <em>ios</em>. Returns
|
||||
* <code>nil</code> if called at end of file.
|
||||
*
|
||||
* f = File.new("testfile")
|
||||
* f.getc #=> "8"
|
||||
* f.getc #=> "1"
|
||||
*/
|
||||
|
||||
VALUE
|
||||
rb_io_getc_m(VALUE io)
|
||||
{
|
||||
char ch;
|
||||
OpenFile *fptr;
|
||||
int c;
|
||||
|
||||
GetOpenFile(io, fptr);
|
||||
rb_io_check_readable(fptr);
|
||||
|
||||
READ_CHECK(fptr);
|
||||
c = io_getc(fptr);
|
||||
|
||||
if (c < 0) {
|
||||
return Qnil;
|
||||
}
|
||||
ch = c & 0xff;
|
||||
return rb_str_new(&ch, 1);
|
||||
}
|
||||
|
||||
int
|
||||
rb_getc(FILE *f)
|
||||
{
|
||||
|
@ -2009,7 +2030,7 @@ rb_getc(FILE *f)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* ios.readchar => fixnum
|
||||
* ios.readchar => string
|
||||
*
|
||||
* Reads a character as with <code>IO#getc</code>, but raises an
|
||||
* <code>EOFError</code> on end of file.
|
||||
|
@ -2028,7 +2049,7 @@ rb_io_readchar(VALUE io)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* ios.ungetc(integer) => nil
|
||||
* ios.ungetc(string) => nil
|
||||
*
|
||||
* Pushes back one character (passed as a parameter) onto <em>ios</em>,
|
||||
* such that a subsequent buffered read will return it. Only one character
|
||||
|
@ -2037,20 +2058,30 @@ rb_io_readchar(VALUE io)
|
|||
* back). Has no effect with unbuffered reads (such as <code>IO#sysread</code>).
|
||||
*
|
||||
* f = File.new("testfile") #=> #<File:testfile>
|
||||
* c = f.getc #=> 84
|
||||
* c = f.getc #=> "8"
|
||||
* f.ungetc(c) #=> nil
|
||||
* f.getc #=> 84
|
||||
* f.getc #=> "8"
|
||||
*/
|
||||
|
||||
VALUE
|
||||
rb_io_ungetc(VALUE io, VALUE c)
|
||||
{
|
||||
OpenFile *fptr;
|
||||
int cc = NUM2INT(c);
|
||||
int cc;
|
||||
|
||||
GetOpenFile(io, fptr);
|
||||
rb_io_check_readable(fptr);
|
||||
|
||||
if (NIL_P(c)) return Qnil;
|
||||
if (FIXNUM_P(c)) {
|
||||
cc = FIX2INT(c);
|
||||
}
|
||||
else {
|
||||
SafeStringValue(c);
|
||||
if (RSTRING(c)->len > 1) {
|
||||
rb_warn("IO#ungetc pushes back only one byte");
|
||||
}
|
||||
cc = (unsigned char)RSTRING(c)->ptr[0];
|
||||
}
|
||||
if (io_ungetc(cc, fptr) == EOF && cc != EOF) {
|
||||
rb_raise(rb_eIOError, "ungetc failed");
|
||||
}
|
||||
|
@ -2912,8 +2943,9 @@ popen_redirect(struct popen_arg *p)
|
|||
|
||||
#ifdef HAVE_FORK
|
||||
static int
|
||||
popen_exec(struct popen_arg *p)
|
||||
popen_exec(void *pp)
|
||||
{
|
||||
struct popen_arg *p = (struct popen_arg*)pp;
|
||||
int fd;
|
||||
|
||||
popen_redirect(p);
|
||||
|
@ -5316,23 +5348,23 @@ argf_readpartial(int argc, VALUE *argv)
|
|||
static VALUE
|
||||
argf_getc(void)
|
||||
{
|
||||
VALUE byte;
|
||||
VALUE ch;
|
||||
|
||||
retry:
|
||||
if (!next_argv()) return Qnil;
|
||||
if (TYPE(current_file) != T_FILE) {
|
||||
byte = rb_funcall3(current_file, rb_intern("getc"), 0, 0);
|
||||
ch = rb_funcall3(current_file, rb_intern("getc"), 0, 0);
|
||||
}
|
||||
else {
|
||||
byte = rb_io_getc(current_file);
|
||||
ch = rb_io_getc(current_file);
|
||||
}
|
||||
if (NIL_P(byte) && next_p != -1) {
|
||||
if (NIL_P(ch) && next_p != -1) {
|
||||
argf_close(current_file);
|
||||
next_p = 1;
|
||||
goto retry;
|
||||
}
|
||||
|
||||
return byte;
|
||||
return ch;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -5646,7 +5678,7 @@ Init_IO(void)
|
|||
rb_define_method(rb_cIO, "write", io_write, 1);
|
||||
rb_define_method(rb_cIO, "gets", rb_io_gets_m, -1);
|
||||
rb_define_method(rb_cIO, "readline", rb_io_readline, -1);
|
||||
rb_define_method(rb_cIO, "getc", rb_io_getc, 0);
|
||||
rb_define_method(rb_cIO, "getc", rb_io_getc_m, 0);
|
||||
rb_define_method(rb_cIO, "readchar", rb_io_readchar, 0);
|
||||
rb_define_method(rb_cIO, "ungetc",rb_io_ungetc, 1);
|
||||
rb_define_method(rb_cIO, "<<", rb_io_addstr, 1);
|
||||
|
|
|
@ -20,6 +20,7 @@ fileutils.rb
|
|||
find.rb
|
||||
forwardable.rb
|
||||
generator.rb
|
||||
getoptlong.rb
|
||||
logger.rb
|
||||
matrix.rb
|
||||
net
|
||||
|
|
|
@ -726,6 +726,8 @@ class CGI
|
|||
when /shift_jis/ni
|
||||
content = NKF::nkf('-s', content)
|
||||
options["language"] = "ja" unless options.has_key?("language")
|
||||
when /utf-8/ni
|
||||
content = NKF::nkf('-w', content)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
# array, like this:
|
||||
#
|
||||
# class RecordCollection
|
||||
# extends Forwardable
|
||||
# extend Forwardable
|
||||
# def_delegator :@records, :[], :record_number
|
||||
# end
|
||||
#
|
||||
|
@ -101,7 +101,7 @@
|
|||
# all of which delegate to @records, this is how you can do it:
|
||||
#
|
||||
# class RecordCollection
|
||||
# # extends Forwardable, but we did that above
|
||||
# # extend Forwardable, but we did that above
|
||||
# def_delegators :@records, :size, :<<, :map
|
||||
# end
|
||||
# f = Foo.new
|
||||
|
|
|
@ -1,17 +1,94 @@
|
|||
# -*- Ruby -*-
|
||||
# Copyright (C) 1998, 1999, 2000 Motoyuki Kasahara
|
||||
#
|
||||
# You may redistribute it and/or modify it under the same license
|
||||
# GetoptLong for Ruby
|
||||
#
|
||||
# Copyright (C) 1998, 1999, 2000 Motoyuki Kasahara.
|
||||
#
|
||||
# You may redistribute and/or modify this library under the same license
|
||||
# terms as Ruby.
|
||||
#
|
||||
# See GetoptLong for documentation.
|
||||
#
|
||||
# Additional documents and the latest version of `getoptlong.rb' can be
|
||||
# found at http://www.sra.co.jp/people/m-kasahr/ruby/getoptlong/
|
||||
|
||||
# The GetoptLong class allows you to parse command line options similarly to
|
||||
# the GNU getopt_long() C library call. Note, however, that GetoptLong is a
|
||||
# pure Ruby implementation.
|
||||
#
|
||||
# Documents and latest version of `getoptlong.rb' are found at:
|
||||
# http://www.sra.co.jp/people/m-kasahr/ruby/getoptlong/
|
||||
# GetoptLong allows for POSIX-style options like <tt>--file</tt> as well
|
||||
# as single letter options like <tt>-f</tt>
|
||||
#
|
||||
|
||||
# The empty option <tt>--</tt> (two minus symbols) is used to end option
|
||||
# processing. This can be particularly important if options have optional
|
||||
# arguments.
|
||||
#
|
||||
# Parse command line options just like GNU getopt_long().
|
||||
# Here is a simple example of usage:
|
||||
#
|
||||
# # == Synopsis
|
||||
# #
|
||||
# # hello: greets user, demonstrates command line parsing
|
||||
# #
|
||||
# # == Usage
|
||||
# #
|
||||
# # hello [OPTION] ... DIR
|
||||
# #
|
||||
# # -h, --help:
|
||||
# # show help
|
||||
# #
|
||||
# # --repeat x, -n x:
|
||||
# # repeat x times
|
||||
# #
|
||||
# # --name [name]:
|
||||
# # greet user by name, if name not supplied default is John
|
||||
# #
|
||||
# # DIR: The directory in which to issue the greeting.
|
||||
#
|
||||
# require 'getoptlong'
|
||||
# require 'rdoc/usage'
|
||||
#
|
||||
# opts = GetoptLong.new(
|
||||
# [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
||||
# [ '--repeat', '-n', GetoptLong::REQUIRED_ARGUMENT ],
|
||||
# [ '--name', GetoptLong::OPTIONAL_ARGUMENT ]
|
||||
# )
|
||||
#
|
||||
# dir = nil
|
||||
# name = nil
|
||||
# repetitions = 1
|
||||
# opts.each do |opt, arg|
|
||||
# case opt
|
||||
# when '--help'
|
||||
# RDoc::usage
|
||||
# when '--repeat'
|
||||
# repetitions = arg.to_i
|
||||
# when '--name'
|
||||
# if arg == ''
|
||||
# name = 'John'
|
||||
# else
|
||||
# name = arg
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# if ARGV.length != 1
|
||||
# puts "Missing dir argument (try --help)"
|
||||
# exit 0
|
||||
# end
|
||||
#
|
||||
# dir = ARGV.shift
|
||||
#
|
||||
# Dir.chdir(dir)
|
||||
# for i in (1..repetitions)
|
||||
# print "Hello"
|
||||
# if name
|
||||
# print ", #{name}"
|
||||
# end
|
||||
# puts
|
||||
# end
|
||||
#
|
||||
# Example command line:
|
||||
#
|
||||
# hello -n 6 --name -- /tmp
|
||||
#
|
||||
class GetoptLong
|
||||
#
|
||||
|
@ -40,13 +117,20 @@ class GetoptLong
|
|||
class InvalidOption < Error; end
|
||||
|
||||
#
|
||||
# The arguments are passed to new() as an array of arrays. Each
|
||||
# subarray has a number of option names which carry the same
|
||||
# meaning, and a ARGUMENT_FLAG, being one of
|
||||
# GetoptLong::NO_ARGUMENT, GetoptLong::REQUIRED_ARGUMENT or
|
||||
# GetoptLong::OPTIONAL_ARGUMENT. These determine whether the
|
||||
# option takes an argument or not, or whether it is optional The
|
||||
# actual processing is done later with #each().
|
||||
# Set up option processing.
|
||||
#
|
||||
# The options to support are passed to new() as an array of arrays.
|
||||
# Each sub-array contains any number of String option names which carry
|
||||
# the same meaning, and one of the following flags:
|
||||
#
|
||||
# GetoptLong::NO_ARGUMENT :: Option does not take an argument.
|
||||
#
|
||||
# GetoptLong::REQUIRED_ARGUMENT :: Option always takes an argument.
|
||||
#
|
||||
# GetoptLong::OPTIONAL_ARGUMENT :: Option may or may not take an argument.
|
||||
#
|
||||
# The first option name is considered to be the preferred (canonical) name.
|
||||
# Other than that, the elements of each sub-array can be in any order.
|
||||
#
|
||||
def initialize(*arguments)
|
||||
#
|
||||
|
@ -109,11 +193,53 @@ class GetoptLong
|
|||
end
|
||||
|
||||
#
|
||||
# Set the handling of the ordering of options. The supplied
|
||||
# argument ordering must be a member of ORDERINGS, i.e one of
|
||||
# GetoptLong::REQUIRE_ORDER, GetoptLong::PERMUTE,
|
||||
# GetoptLong::RETURN_IN_ORDER. A RuntimeError is raised if
|
||||
# option processing has already started.
|
||||
# Set the handling of the ordering of options and arguments.
|
||||
# A RuntimeError is raised if option processing has already started.
|
||||
#
|
||||
# The supplied value must be a member of GetoptLong::ORDERINGS. It alters
|
||||
# the processing of options as follows:
|
||||
#
|
||||
# <b>REQUIRE_ORDER</b> :
|
||||
#
|
||||
# Options are required to occur before non-options.
|
||||
#
|
||||
# Processing of options ends as soon as a word is encountered that has not
|
||||
# been preceded by an appropriate option flag.
|
||||
#
|
||||
# For example, if -a and -b are options which do not take arguments,
|
||||
# parsing command line arguments of '-a one -b two' would result in
|
||||
# 'one', '-b', 'two' being left in ARGV, and only ('-a', '') being
|
||||
# processed as an option/arg pair.
|
||||
#
|
||||
# This is the default ordering, if the environment variable
|
||||
# POSIXLY_CORRECT is set. (This is for compatibility with GNU getopt_long.)
|
||||
#
|
||||
# <b>PERMUTE</b> :
|
||||
#
|
||||
# Options can occur anywhere in the command line parsed. This is the
|
||||
# default behavior.
|
||||
#
|
||||
# Every sequence of words which can be interpreted as an option (with or
|
||||
# without argument) is treated as an option; non-option words are skipped.
|
||||
#
|
||||
# For example, if -a does not require an argument and -b optionally takes
|
||||
# an argument, parsing '-a one -b two three' would result in ('-a','') and
|
||||
# ('-b', 'two') being processed as option/arg pairs, and 'one','three'
|
||||
# being left in ARGV.
|
||||
#
|
||||
# If the ordering is set to PERMUTE but the environment variable
|
||||
# POSIXLY_CORRECT is set, REQUIRE_ORDER is used instead. This is for
|
||||
# compatibility with GNU getopt_long.
|
||||
#
|
||||
# <b>RETURN_IN_ORDER</b> :
|
||||
#
|
||||
# All words on the command line are processed as options. Words not
|
||||
# preceded by a short or long option flag are passed as arguments
|
||||
# with an option of '' (empty string).
|
||||
#
|
||||
# For example, if -a requires an argument but -b does not, a command line
|
||||
# of '-a one -b two three' would result in option/arg pairs of ('-a', 'one')
|
||||
# ('-b', ''), ('', 'two'), ('', 'three') being processed.
|
||||
#
|
||||
def ordering=(ordering)
|
||||
#
|
||||
|
@ -144,7 +270,9 @@ class GetoptLong
|
|||
attr_reader :ordering
|
||||
|
||||
#
|
||||
# Set options
|
||||
# Set options. Takes the same argument as GetoptLong.new.
|
||||
#
|
||||
# Raises a RuntimeError if option processing has already started.
|
||||
#
|
||||
def set_options(*arguments)
|
||||
#
|
||||
|
@ -233,7 +361,7 @@ class GetoptLong
|
|||
alias quiet? quiet
|
||||
|
||||
#
|
||||
# Terminate option processing.
|
||||
# Explicitly terminate option processing.
|
||||
#
|
||||
def terminate
|
||||
return nil if @status == STATUS_TERMINATED
|
||||
|
@ -253,7 +381,7 @@ class GetoptLong
|
|||
end
|
||||
|
||||
#
|
||||
# Examine whether option processing is terminated or not.
|
||||
# Returns true if option processing has terminated, false otherwise.
|
||||
#
|
||||
def terminated?
|
||||
return @status == STATUS_TERMINATED
|
||||
|
@ -286,16 +414,22 @@ class GetoptLong
|
|||
#
|
||||
alias error? error
|
||||
|
||||
#
|
||||
# Return an error message.
|
||||
# Return the appropriate error message in POSIX-defined format.
|
||||
# If no error has occurred, returns nil.
|
||||
#
|
||||
def error_message
|
||||
return @error_message
|
||||
end
|
||||
|
||||
#
|
||||
# Get next option name and its argument as an array.
|
||||
# Return nil if the processing is complete (as determined by
|
||||
# Get next option name and its argument, as an Array of two elements.
|
||||
#
|
||||
# The option name is always converted to the first (preferred)
|
||||
# name given in the original options to GetoptLong.new.
|
||||
#
|
||||
# Example: ['--option', 'value']
|
||||
#
|
||||
# Returns nil if the processing is complete (as determined by
|
||||
# STATUS_TERMINATED).
|
||||
#
|
||||
def get
|
||||
|
@ -462,9 +596,15 @@ class GetoptLong
|
|||
#
|
||||
alias get_option get
|
||||
|
||||
# Iterator version of `get'.
|
||||
#
|
||||
# Iterator version of `get', passes the option and the
|
||||
# corresponding argument to the supplied block for processing.
|
||||
# The block is called repeatedly with two arguments:
|
||||
# The first is the option name.
|
||||
# The second is the argument which followed it (if any).
|
||||
# Example: ('--opt', 'value')
|
||||
#
|
||||
# The option name is always converted to the first (preferred)
|
||||
# name given in the original options to GetoptLong.new.
|
||||
#
|
||||
def each
|
||||
loop do
|
||||
|
|
|
@ -174,7 +174,7 @@ class String
|
|||
def tr_s!(from, to)
|
||||
return self.delete!(from) if to.length == 0
|
||||
|
||||
pattern = SqueezePatternCache[from] ||= /([#{_regex_quote(from)}])\1+/
|
||||
pattern = SqueezePatternCache[from] ||= /([#{_regex_quote(from)}])\1*/
|
||||
if from[0] == ?^
|
||||
last = /.$/.match(to)[0]
|
||||
self.gsub!(pattern, last)
|
||||
|
|
|
@ -16,14 +16,6 @@ require "matrix.rb"
|
|||
|
||||
class Integer
|
||||
|
||||
remove_method(:gcd2)
|
||||
def gcd2(other)
|
||||
min = self.abs
|
||||
max = other.abs
|
||||
min, max = max % min, min while min > 0
|
||||
max
|
||||
end
|
||||
|
||||
def Integer.from_prime_division(pd)
|
||||
value = 1
|
||||
for prime, index in pd
|
||||
|
|
25
lib/mkmf.rb
25
lib/mkmf.rb
|
@ -786,21 +786,26 @@ def find_executable(bin, path = nil)
|
|||
end
|
||||
end
|
||||
|
||||
def arg_config(config, *defaults, &block)
|
||||
$arg_config << [config, *defaults]
|
||||
defaults << nil if !block and defaults.empty?
|
||||
def arg_config(config, default=nil, &block)
|
||||
$arg_config << [config, default]
|
||||
defaults = []
|
||||
if default
|
||||
defaults << default
|
||||
elsif !block
|
||||
defaults << nil
|
||||
end
|
||||
$configure_args.fetch(config.tr('_', '-'), *defaults, &block)
|
||||
end
|
||||
|
||||
def with_config(config, *defaults)
|
||||
def with_config(config, default=nil)
|
||||
config = config.sub(/^--with[-_]/, '')
|
||||
val = arg_config("--with-"+config) do
|
||||
if arg_config("--without-"+config)
|
||||
false
|
||||
elsif block_given?
|
||||
yield(config, *defaults)
|
||||
yield(config, default)
|
||||
else
|
||||
break *defaults
|
||||
break default
|
||||
end
|
||||
end
|
||||
case val
|
||||
|
@ -813,15 +818,15 @@ def with_config(config, *defaults)
|
|||
end
|
||||
end
|
||||
|
||||
def enable_config(config, *defaults)
|
||||
def enable_config(config, default=nil)
|
||||
if arg_config("--enable-"+config)
|
||||
true
|
||||
elsif arg_config("--disable-"+config)
|
||||
false
|
||||
elsif block_given?
|
||||
yield(config, *defaults)
|
||||
yield(config, default)
|
||||
else
|
||||
return *defaults
|
||||
return default
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1105,7 +1110,7 @@ EXTSTATIC = #{$static || ""}
|
|||
STATIC_LIB = #{staticlib unless $static.nil?}
|
||||
|
||||
}
|
||||
install_dirs.each {|d| mfile.print("%-14s= %s\n" % d) if /^[[:upper:]]/ =~ d[0]}
|
||||
install_dirs.each {|*d| mfile.print("%-14s= %s\n" % d) if /^[[:upper:]]/ =~ d[0]}
|
||||
n = ($extout ? '$(RUBYARCHDIR)/' : '') + '$(TARGET).'
|
||||
mfile.print %{
|
||||
TARGET_SO = #{($extout ? '$(RUBYARCHDIR)/' : '')}$(DLLIB)
|
||||
|
|
|
@ -357,7 +357,7 @@ class OptionParser
|
|||
if conv
|
||||
val = conv.call(*val)
|
||||
else
|
||||
val = *val
|
||||
val = val[0]
|
||||
end
|
||||
return arg, block, val
|
||||
else
|
||||
|
@ -622,7 +622,7 @@ class OptionParser
|
|||
if list = __send__(id)
|
||||
val = list.fetch(key) {return nil}
|
||||
return val unless block_given?
|
||||
yield(val)
|
||||
yield(*val)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -848,7 +848,7 @@ class OptionParser
|
|||
# :nodoc:
|
||||
def add_officious
|
||||
list = base()
|
||||
Officious.each_pair do |opt, block|
|
||||
Officious.each do |opt, block|
|
||||
list.long[opt] ||= block.call(self)
|
||||
end
|
||||
end
|
||||
|
@ -1319,7 +1319,7 @@ class OptionParser
|
|||
end
|
||||
begin
|
||||
opt, sw, val = sw.parse(rest, argv) {|*exc| raise(*exc)}
|
||||
sw.call(val) if sw
|
||||
sw.call(*val) if sw
|
||||
rescue ParseError
|
||||
raise $!.set_option(arg, rest)
|
||||
end
|
||||
|
@ -1458,9 +1458,9 @@ class OptionParser
|
|||
yielded with the found value when succeeded.
|
||||
=end #'#"#`#
|
||||
def search(id, key)
|
||||
visit(:search, id, key) do |k|
|
||||
visit(:search, id, key) do |*k|
|
||||
return k unless block_given?
|
||||
return yield(k)
|
||||
return yield(*k)
|
||||
end
|
||||
end
|
||||
private :search
|
||||
|
|
|
@ -2555,7 +2555,7 @@ module RDoc
|
|||
break
|
||||
when TkCOMMA
|
||||
else
|
||||
warn("unexpected token: '#{tk2.inspect}'") if $DEBBUG
|
||||
warn("unexpected token: '#{tk2.inspect}'") if $DEBUG
|
||||
break
|
||||
end
|
||||
end
|
||||
|
|
|
@ -41,5 +41,11 @@ module RI
|
|||
|
||||
# This is the search path for 'ri'
|
||||
PATH = [ SYSDIR, SITEDIR, HOMEDIR ].find_all {|p| p && File.directory?(p)}
|
||||
|
||||
begin
|
||||
require 'rubygems'
|
||||
Dir["#{Gem.path}/doc/*/ri"].each { |path| RI::Paths::PATH << path }
|
||||
rescue LoadError
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,8 +6,7 @@ require 'test/unit/assertions'
|
|||
require 'runit/error'
|
||||
|
||||
module RUNIT
|
||||
module Assert
|
||||
include Test::Unit::Assertions
|
||||
module AssertMixin
|
||||
|
||||
def setup_assert
|
||||
end
|
||||
|
@ -70,4 +69,8 @@ module RUNIT
|
|||
/assertions\.rb/.match(caller[1])
|
||||
end
|
||||
end
|
||||
module Assert
|
||||
include Test::Unit::Assertions
|
||||
include AssertMixin
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ require 'test/unit/testcase'
|
|||
|
||||
module RUNIT
|
||||
class TestCase < Test::Unit::TestCase
|
||||
include RUNIT::Assert
|
||||
include RUNIT::AssertMixin
|
||||
|
||||
def self.suite
|
||||
method_names = instance_methods(true)
|
||||
|
|
|
@ -67,7 +67,7 @@ class Tempfile < DelegateClass(File)
|
|||
end
|
||||
|
||||
def make_tmpname(basename, n)
|
||||
sprintf('%s%d.%d', basename, $$, n)
|
||||
sprintf('%s.%d.%d', basename, $$, n)
|
||||
end
|
||||
private :make_tmpname
|
||||
|
||||
|
|
|
@ -304,7 +304,7 @@ w_float(double d, struct dump_arg *arg)
|
|||
static void
|
||||
w_symbol(ID id, struct dump_arg *arg)
|
||||
{
|
||||
char *sym = rb_id2name(id);
|
||||
const char *sym = rb_id2name(id);
|
||||
st_data_t num;
|
||||
|
||||
if (st_lookup(arg->symbols, id, &num)) {
|
||||
|
@ -872,7 +872,7 @@ r_symbol(struct load_arg *arg)
|
|||
return r_symreal(arg);
|
||||
}
|
||||
|
||||
static char*
|
||||
static const char*
|
||||
r_unique(struct load_arg *arg)
|
||||
{
|
||||
return rb_id2name(r_symbol(arg));
|
||||
|
|
46
math.c
46
math.c
|
@ -300,16 +300,55 @@ math_exp(VALUE obj, VALUE x)
|
|||
*/
|
||||
|
||||
static VALUE
|
||||
math_log(VALUE obj, VALUE x)
|
||||
math_log(int argc, VALUE *argv)
|
||||
{
|
||||
double d;
|
||||
VALUE x, base;
|
||||
double d, b;
|
||||
|
||||
rb_scan_args(argc, argv, "11", &x, &base);
|
||||
Need_Float(x);
|
||||
errno = 0;
|
||||
d = log(RFLOAT(x)->value);
|
||||
if (errno) {
|
||||
rb_sys_fail("log");
|
||||
}
|
||||
if (!NIL_P(base)) {
|
||||
Need_Float(base);
|
||||
d /= log(RFLOAT(base)->value);
|
||||
}
|
||||
if (errno) {
|
||||
rb_sys_fail("log");
|
||||
}
|
||||
return rb_float_new(d);
|
||||
}
|
||||
|
||||
#ifndef HAVE_LOG2
|
||||
double
|
||||
log2(double x)
|
||||
{
|
||||
return log10(x)/log10(2.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* Math.log2(numeric) => float
|
||||
*
|
||||
* Returns the base 2 logarithm of <i>numeric</i>.
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
math_log2(VALUE obj, VALUE x)
|
||||
{
|
||||
extern double log2(double);
|
||||
double d;
|
||||
|
||||
Need_Float(x);
|
||||
errno = 0;
|
||||
d = log2(RFLOAT(x)->value);
|
||||
if (errno) {
|
||||
rb_sys_fail("log2");
|
||||
}
|
||||
return rb_float_new(d);
|
||||
}
|
||||
|
||||
|
@ -485,7 +524,8 @@ Init_Math(void)
|
|||
rb_define_module_function(rb_mMath, "atanh", math_atanh, 1);
|
||||
|
||||
rb_define_module_function(rb_mMath, "exp", math_exp, 1);
|
||||
rb_define_module_function(rb_mMath, "log", math_log, 1);
|
||||
rb_define_module_function(rb_mMath, "log", math_log, -1);
|
||||
rb_define_module_function(rb_mMath, "log2", math_log2, 1);
|
||||
rb_define_module_function(rb_mMath, "log10", math_log10, 1);
|
||||
rb_define_module_function(rb_mMath, "sqrt", math_sqrt, 1);
|
||||
|
||||
|
|
|
@ -314,9 +314,7 @@ static int BSD__sfvwrite(fp, uio)
|
|||
* then reset it so that it can be reused.
|
||||
*/
|
||||
static int
|
||||
BSD__sprint(fp, uio)
|
||||
FILE *fp;
|
||||
register struct __suio *uio;
|
||||
BSD__sprint(FILE *fp, register struct __suio *uio)
|
||||
{
|
||||
register int err;
|
||||
|
||||
|
@ -337,10 +335,7 @@ BSD__sprint(fp, uio)
|
|||
* worries about ungetc buffers and so forth.
|
||||
*/
|
||||
static int
|
||||
BSD__sbprintf(fp, fmt, ap)
|
||||
register FILE *fp;
|
||||
const char *fmt;
|
||||
va_list ap;
|
||||
BSD__sbprintf(register FILE *fp, const char *fmt, va_list ap)
|
||||
{
|
||||
/* We don't support files. */
|
||||
return 0;
|
||||
|
@ -361,11 +356,7 @@ BSD__sbprintf(fp, fmt, ap)
|
|||
* use the given digits.
|
||||
*/
|
||||
static char *
|
||||
BSD__ultoa(val, endp, base, octzero, xdigs)
|
||||
register u_long val;
|
||||
char *endp;
|
||||
int base, octzero;
|
||||
char *xdigs;
|
||||
BSD__ultoa(register u_long val, char *endp, int base, int octzero, char *xdigs)
|
||||
{
|
||||
register char *cp = endp;
|
||||
register long sval;
|
||||
|
@ -464,10 +455,7 @@ static int exponent __P((char *, int, int));
|
|||
#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */
|
||||
#define FPT 0x100 /* Floating point number */
|
||||
static int
|
||||
BSD_vfprintf(fp, fmt0, ap)
|
||||
FILE *fp;
|
||||
const char *fmt0;
|
||||
va_list ap;
|
||||
BSD_vfprintf(FILE *fp, const char *fmt0, va_list ap)
|
||||
{
|
||||
register char *fmt; /* format string */
|
||||
register int ch; /* character from fmt */
|
||||
|
|
|
@ -38,9 +38,11 @@ vars = {}
|
|||
has_version = false
|
||||
File.foreach "config.status" do |line|
|
||||
next if /^#/ =~ line
|
||||
if /^s[%,]@program_transform_name@[%,]s,(.*)/ =~ line
|
||||
line.gsub!(/\|#_!!_#\|/, '')
|
||||
if /^s[%,]@program_transform_name@[%,]s(\\?.)(.*)\1[%,]/ =~ line
|
||||
next if $install_name
|
||||
ptn = $1.sub(/\$\$/, '$').split(/,/) #'
|
||||
sep = Regexp.quote($1)
|
||||
ptn = $2.sub(/\$\$/, '$').split(/#{sep}/,2)
|
||||
v_fast << " CONFIG[\"ruby_install_name\"] = \"" + "ruby".sub(/#{ptn[0]}/,ptn[1]) + "\"\n"
|
||||
elsif /^s[%,]@(\w+)@[%,](.*)[%,]/ =~ line
|
||||
name = $1
|
||||
|
|
9
node.h
9
node.h
|
@ -86,11 +86,11 @@ enum node_type {
|
|||
NODE_DREGX,
|
||||
NODE_DREGX_ONCE,
|
||||
NODE_ARGS,
|
||||
NODE_POSTARG,
|
||||
NODE_ARGSCAT,
|
||||
NODE_ARGSPUSH,
|
||||
NODE_SPLAT,
|
||||
NODE_TO_ARY,
|
||||
NODE_SVALUE,
|
||||
NODE_BLOCK_ARG,
|
||||
NODE_BLOCK_PASS,
|
||||
NODE_DEFN,
|
||||
|
@ -311,11 +311,11 @@ typedef struct RNode {
|
|||
#define NEW_SUPER(a) NEW_NODE(NODE_SUPER,0,0,a)
|
||||
#define NEW_ZSUPER() NEW_NODE(NODE_ZSUPER,0,0,0)
|
||||
#define NEW_ARGS(f,o,r) NEW_NODE(NODE_ARGS,o,r,f)
|
||||
#define NEW_POSTARG(r,m) NEW_NODE(NODE_POSTARG,m,0,r)
|
||||
#define NEW_ARGSCAT(a,b) NEW_NODE(NODE_ARGSCAT,a,b,0)
|
||||
#define NEW_ARGSPUSH(a,b) NEW_NODE(NODE_ARGSPUSH,a,b,0)
|
||||
#define NEW_SPLAT(a) NEW_NODE(NODE_SPLAT,a,0,0)
|
||||
#define NEW_TO_ARY(a) NEW_NODE(NODE_TO_ARY,a,0,0)
|
||||
#define NEW_SVALUE(a) NEW_NODE(NODE_SVALUE,a,0,0)
|
||||
#define NEW_BLOCK_ARG(v) NEW_NODE(NODE_BLOCK_ARG,v,0,local_cnt(v))
|
||||
#define NEW_BLOCK_PASS(b) NEW_NODE(NODE_BLOCK_PASS,0,b,0)
|
||||
#define NEW_ALIAS(n,o) NEW_NODE(NODE_ALIAS,n,o,0)
|
||||
|
@ -345,10 +345,11 @@ typedef struct RNode {
|
|||
#define NOEX_NOSUPER 1
|
||||
#define NOEX_PRIVATE 2
|
||||
#define NOEX_PROTECTED 4
|
||||
#define NOEX_MASK 6
|
||||
#define NOEX_LOCAL 8
|
||||
#define NOEX_MASK 14
|
||||
|
||||
#define NOEX_UNDEF NOEX_NOSUPER
|
||||
#define NOEX_RECV 8
|
||||
#define NOEX_RECV 16
|
||||
|
||||
VALUE rb_parser_new(void);
|
||||
VALUE rb_parser_end_seen_p(VALUE);
|
||||
|
|
27
numeric.c
27
numeric.c
|
@ -284,21 +284,21 @@ num_div(VALUE x, VALUE y)
|
|||
* ------+-----+---------------+---------+-------------+---------------
|
||||
* -13 | -4 | 3, -1 | 3 | -1 | -1
|
||||
* ------+-----+---------------+---------+-------------+---------------
|
||||
* 11.5 | 4 | 2.0, 3.5 | 2.875 | 3.5 | 3.5
|
||||
* 11.5 | 4 | 2, 3.5 | 2.875 | 3.5 | 3.5
|
||||
* ------+-----+---------------+---------+-------------+---------------
|
||||
* 11.5 | -4 | -3.0, -0.5 | -2.875 | -0.5 | 3.5
|
||||
* 11.5 | -4 | -3, -0.5 | -2.875 | -0.5 | 3.5
|
||||
* ------+-----+---------------+---------+-------------+---------------
|
||||
* -11.5 | 4 | -3.0 0.5 | -2.875 | 0.5 | -3.5
|
||||
* -11.5 | 4 | -3, 0.5 | -2.875 | 0.5 | -3.5
|
||||
* ------+-----+---------------+---------+-------------+---------------
|
||||
* -11.5 | -4 | 2.0 -3.5 | 2.875 | -3.5 | -3.5
|
||||
* -11.5 | -4 | 2, -3.5 | 2.875 | -3.5 | -3.5
|
||||
*
|
||||
*
|
||||
* Examples
|
||||
* 11.divmod(3) #=> [3, 2]
|
||||
* 11.divmod(-3) #=> [-4, -1]
|
||||
* 11.divmod(3.5) #=> [3.0, 0.5]
|
||||
* (-11).divmod(3.5) #=> [-4.0, 3.0]
|
||||
* (11.5).divmod(3.5) #=> [3.0, 1.0]
|
||||
* 11.divmod(3.5) #=> [3, 0.5]
|
||||
* (-11).divmod(3.5) #=> [-4, 3.0]
|
||||
* (11.5).divmod(3.5) #=> [3, 1.0]
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
@ -696,7 +696,7 @@ flo_mod(VALUE x, VALUE y)
|
|||
static VALUE
|
||||
flo_divmod(VALUE x, VALUE y)
|
||||
{
|
||||
double fy, div, mod;
|
||||
double fy, div, mod, val;
|
||||
volatile VALUE a, b;
|
||||
|
||||
switch (TYPE(y)) {
|
||||
|
@ -713,7 +713,13 @@ flo_divmod(VALUE x, VALUE y)
|
|||
return rb_num_coerce_bin(x, y);
|
||||
}
|
||||
flodivmod(RFLOAT(x)->value, fy, &div, &mod);
|
||||
a = rb_float_new(div);
|
||||
if (FIXABLE(div)) {
|
||||
val = div;
|
||||
a = LONG2FIX(val);
|
||||
}
|
||||
else {
|
||||
a = rb_dbl2big(div);
|
||||
}
|
||||
b = rb_float_new(mod);
|
||||
return rb_assoc_new(a, b);
|
||||
}
|
||||
|
@ -1722,7 +1728,6 @@ int_succ(VALUE num)
|
|||
* receiver's value.
|
||||
*
|
||||
* 65.chr #=> "A"
|
||||
* ?a.chr #=> "a"
|
||||
* 230.chr #=> "\346"
|
||||
*/
|
||||
|
||||
|
@ -2603,7 +2608,7 @@ fix_abs(VALUE fix)
|
|||
static VALUE
|
||||
fix_id2name(VALUE fix)
|
||||
{
|
||||
char *name = rb_id2name(FIX2UINT(fix));
|
||||
const char *name = rb_id2name(FIX2UINT(fix));
|
||||
if (name) return rb_str_new2(name);
|
||||
return Qnil;
|
||||
}
|
||||
|
|
45
object.c
45
object.c
|
@ -20,6 +20,7 @@
|
|||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
VALUE rb_cBasicObject;
|
||||
VALUE rb_mKernel;
|
||||
VALUE rb_cObject;
|
||||
VALUE rb_cModule;
|
||||
|
@ -266,7 +267,7 @@ static int
|
|||
inspect_i(ID id, VALUE value, VALUE str)
|
||||
{
|
||||
VALUE str2;
|
||||
char *ivname;
|
||||
const char *ivname;
|
||||
|
||||
/* need not to show internal data */
|
||||
if (CLASS_OF(value) == 0) return ST_CONTINUE;
|
||||
|
@ -698,8 +699,7 @@ nil_to_s(VALUE obj)
|
|||
*/
|
||||
|
||||
static VALUE
|
||||
nil_to_a(obj)
|
||||
VALUE obj;
|
||||
nil_to_a(VALUE obj)
|
||||
{
|
||||
return rb_ary_new2(0);
|
||||
}
|
||||
|
@ -1007,7 +1007,7 @@ static VALUE
|
|||
sym_inspect(VALUE sym)
|
||||
{
|
||||
VALUE str;
|
||||
char *name;
|
||||
const char *name;
|
||||
ID id = SYM2ID(sym);
|
||||
|
||||
name = rb_id2name(id);
|
||||
|
@ -1374,7 +1374,7 @@ rb_obj_alloc(VALUE klass)
|
|||
{
|
||||
VALUE obj;
|
||||
|
||||
if (RCLASS(klass)->super == 0) {
|
||||
if (RCLASS(klass)->super == 0 && klass != rb_cBasicObject) {
|
||||
rb_raise(rb_eTypeError, "can't instantiate uninitialized class");
|
||||
}
|
||||
if (FL_TEST(klass, FL_SINGLETON)) {
|
||||
|
@ -2258,7 +2258,7 @@ rb_f_array(VALUE obj, VALUE arg)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
boot_defclass(char *name, VALUE super)
|
||||
boot_defclass(const char *name, VALUE super)
|
||||
{
|
||||
extern st_table *rb_class_tbl;
|
||||
VALUE obj = rb_class_boot(super);
|
||||
|
@ -2309,9 +2309,12 @@ VALUE ruby_top_self;
|
|||
* that follows, the vertical arrows represent inheritance, and the
|
||||
* parentheses meta-classes. All metaclasses are instances
|
||||
* of the class `Class'.
|
||||
*
|
||||
* +------------------+
|
||||
* | |
|
||||
*
|
||||
* +-----------------+
|
||||
* | |
|
||||
* BasicObject-->(BasicObject) |
|
||||
* ^ ^ |
|
||||
* | | |
|
||||
* Object---->(Object) |
|
||||
* ^ ^ ^ ^ |
|
||||
* | | | | |
|
||||
|
@ -2331,10 +2334,12 @@ VALUE ruby_top_self;
|
|||
|
||||
|
||||
/*
|
||||
* <code>Object</code> is the parent class of all classes in Ruby. Its
|
||||
* <code>BasicObject</code> is the parent class of all classes in Ruby.
|
||||
* It's an explicit blank class. <code>Object</code>, the root of Ruby's
|
||||
* class hierarchy is a direct subclass of <code>BasicObject</code>. Its
|
||||
* methods are therefore available to all objects unless explicitly
|
||||
* overridden.
|
||||
*
|
||||
*
|
||||
* <code>Object</code> mixes in the <code>Kernel</code> module, making
|
||||
* the built-in kernel functions globally accessible. Although the
|
||||
* instance methods of <code>Object</code> are defined by the
|
||||
|
@ -2351,18 +2356,23 @@ Init_Object(void)
|
|||
{
|
||||
VALUE metaclass;
|
||||
|
||||
rb_cObject = boot_defclass("Object", 0);
|
||||
rb_cBasicObject = boot_defclass("BasicObject", 0);
|
||||
rb_cObject = boot_defclass("Object", rb_cBasicObject);
|
||||
rb_cModule = boot_defclass("Module", rb_cObject);
|
||||
rb_cClass = boot_defclass("Class", rb_cModule);
|
||||
|
||||
metaclass = rb_make_metaclass(rb_cObject, rb_cClass);
|
||||
metaclass = rb_make_metaclass(rb_cBasicObject, rb_cClass);
|
||||
metaclass = rb_make_metaclass(rb_cObject, metaclass);
|
||||
metaclass = rb_make_metaclass(rb_cModule, metaclass);
|
||||
metaclass = rb_make_metaclass(rb_cClass, metaclass);
|
||||
|
||||
rb_define_private_method(rb_cBasicObject, "initialize", rb_obj_dummy, 0);
|
||||
rb_define_alloc_func(rb_cBasicObject, rb_class_allocate_instance);
|
||||
rb_define_method(rb_cBasicObject, "==", rb_obj_equal, 1);
|
||||
rb_define_method(rb_cBasicObject, "equal?", rb_obj_equal, 1);
|
||||
|
||||
rb_mKernel = rb_define_module("Kernel");
|
||||
rb_include_module(rb_cObject, rb_mKernel);
|
||||
rb_define_alloc_func(rb_cObject, rb_class_allocate_instance);
|
||||
rb_define_private_method(rb_cObject, "initialize", rb_obj_dummy, 0);
|
||||
rb_define_private_method(rb_cClass, "inherited", rb_obj_dummy, 1);
|
||||
rb_define_private_method(rb_cModule, "included", rb_obj_dummy, 1);
|
||||
rb_define_private_method(rb_cModule, "extended", rb_obj_dummy, 1);
|
||||
|
@ -2370,10 +2380,7 @@ Init_Object(void)
|
|||
rb_define_private_method(rb_cModule, "method_removed", rb_obj_dummy, 1);
|
||||
rb_define_private_method(rb_cModule, "method_undefined", rb_obj_dummy, 1);
|
||||
|
||||
|
||||
rb_define_method(rb_mKernel, "nil?", rb_false, 0);
|
||||
rb_define_method(rb_mKernel, "==", rb_obj_equal, 1);
|
||||
rb_define_method(rb_mKernel, "equal?", rb_obj_equal, 1);
|
||||
rb_define_method(rb_mKernel, "===", rb_equal, 1);
|
||||
rb_define_method(rb_mKernel, "=~", rb_obj_pattern_match, 1);
|
||||
|
||||
|
@ -2477,6 +2484,8 @@ Init_Object(void)
|
|||
rb_class_protected_instance_methods, -1); /* in class.c */
|
||||
rb_define_method(rb_cModule, "private_instance_methods",
|
||||
rb_class_private_instance_methods, -1); /* in class.c */
|
||||
rb_define_method(rb_cModule, "local_methods",
|
||||
rb_class_local_methods, 0); /* in class.c */
|
||||
|
||||
rb_define_method(rb_cModule, "constants", rb_mod_constants, 0); /* in variable.c */
|
||||
rb_define_method(rb_cModule, "const_get", rb_mod_const_get, -1);
|
||||
|
|
6
pack.c
6
pack.c
|
@ -1286,7 +1286,7 @@ infected_str_new(const char *ptr, long len, VALUE str)
|
|||
static VALUE
|
||||
pack_unpack(VALUE str, VALUE fmt)
|
||||
{
|
||||
static char *hexdigits = "0123456789abcdef0123456789ABCDEFx";
|
||||
static const char *hexdigits = "0123456789abcdef0123456789ABCDEFx";
|
||||
char *s, *send;
|
||||
char *p, *pend;
|
||||
VALUE ary;
|
||||
|
@ -1320,7 +1320,7 @@ pack_unpack(VALUE str, VALUE fmt)
|
|||
}
|
||||
star = 0;
|
||||
if (*p == '_' || *p == '!') {
|
||||
char *natstr = "sSiIlL";
|
||||
const char *natstr = "sSiIlL";
|
||||
|
||||
if (strchr(natstr, type)) {
|
||||
#ifdef NATINT_PACK
|
||||
|
@ -1818,6 +1818,8 @@ pack_unpack(VALUE str, VALUE fmt)
|
|||
while (s < send) {
|
||||
if (*s == '=') {
|
||||
if (++s == send) break;
|
||||
if (s+1 < send && *s == '\r' && *(s+1) == '\n')
|
||||
s++;
|
||||
if (*s != '\n') {
|
||||
if ((c1 = hex2num(*s)) == -1) break;
|
||||
if (++s == send) break;
|
||||
|
|
682
parse.y
682
parse.y
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
4
prec.c
4
prec.c
|
@ -55,9 +55,9 @@ prec_prec_i(VALUE x)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* num.prec_f => Integer
|
||||
* num.prec_f => Float
|
||||
*
|
||||
* Returns an +Float+ converted from _num_. It is equivalent
|
||||
* Returns a +Float+ converted from _num_. It is equivalent
|
||||
* to <code>prec(Float)</code>.
|
||||
*/
|
||||
|
||||
|
|
28
process.c
28
process.c
|
@ -1296,10 +1296,7 @@ proc_syswait(pid)
|
|||
* +chfunc+ must not raise any exceptions.
|
||||
*/
|
||||
int
|
||||
rb_fork(status, chfunc, charg)
|
||||
int *status;
|
||||
int (*chfunc)(void *);
|
||||
void *charg;
|
||||
rb_fork(int *status, int (*chfunc)(void*), void *charg)
|
||||
{
|
||||
int pid, err, state = 0;
|
||||
#ifdef FD_CLOEXEC
|
||||
|
@ -1627,12 +1624,11 @@ rb_f_spawn(int argc, VALUE *argv)
|
|||
* call-seq:
|
||||
* sleep([duration]) => fixnum
|
||||
*
|
||||
* Suspends the current thread for _duration_ seconds (which may be
|
||||
* any number, including a +Float+ with fractional seconds). Returns the actual
|
||||
* number of seconds slept (rounded), which may be less than that asked
|
||||
* for if the thread was interrupted by a +SIGALRM+, or if
|
||||
* another thread calls <code>Thread#run</code>. Zero arguments
|
||||
* causes +sleep+ to sleep forever.
|
||||
* Suspends the current thread for _duration_ seconds (which may be any number,
|
||||
* including a +Float+ with fractional seconds). Returns the actual number of
|
||||
* seconds slept (rounded), which may be less than that asked for if another
|
||||
* thread calls <code>Thread#run</code>. Zero arguments causes +sleep+ to sleep
|
||||
* forever.
|
||||
*
|
||||
* Time.new #=> Wed Apr 09 08:56:32 CDT 2003
|
||||
* sleep 1.2 #=> 1
|
||||
|
@ -3314,8 +3310,7 @@ p_uid_have_saved_id(void)
|
|||
|
||||
#if defined(HAVE_SETRESUID) || defined(HAVE_SETEUID) || defined(_POSIX_SAVED_IDS)
|
||||
static VALUE
|
||||
p_uid_sw_ensure(id)
|
||||
int id;
|
||||
p_uid_sw_ensure(int id)
|
||||
{
|
||||
under_uid_switch = 0;
|
||||
return rb_seteuid_core(id);
|
||||
|
@ -3336,8 +3331,7 @@ p_uid_sw_ensure(id)
|
|||
*/
|
||||
|
||||
static VALUE
|
||||
p_uid_switch(obj)
|
||||
VALUE obj;
|
||||
p_uid_switch(VALUE obj)
|
||||
{
|
||||
int uid, euid;
|
||||
|
||||
|
@ -3423,8 +3417,7 @@ p_gid_have_saved_id(void)
|
|||
|
||||
#if defined(HAVE_SETRESGID) || defined(HAVE_SETEGID) || defined(_POSIX_SAVED_IDS)
|
||||
static VALUE
|
||||
p_gid_sw_ensure(id)
|
||||
int id;
|
||||
p_gid_sw_ensure(int id)
|
||||
{
|
||||
under_gid_switch = 0;
|
||||
return rb_setegid_core(id);
|
||||
|
@ -3445,8 +3438,7 @@ p_gid_sw_ensure(id)
|
|||
*/
|
||||
|
||||
static VALUE
|
||||
p_gid_switch(obj)
|
||||
VALUE obj;
|
||||
p_gid_switch(VALUE obj)
|
||||
{
|
||||
int gid, egid;
|
||||
|
||||
|
|
3
range.c
3
range.c
|
@ -654,8 +654,7 @@ range_include(VALUE range, VALUE val)
|
|||
*/
|
||||
|
||||
static VALUE
|
||||
range_cover(range, val)
|
||||
VALUE range, val;
|
||||
range_cover(VALUE range, VALUE val)
|
||||
{
|
||||
VALUE beg, end;
|
||||
|
||||
|
|
38
re.c
38
re.c
|
@ -76,8 +76,9 @@ static const char casetable[] = {
|
|||
#endif
|
||||
|
||||
int
|
||||
rb_memcicmp(char *p1, char *p2, long len)
|
||||
rb_memcicmp(const void *x, const void *y, long len)
|
||||
{
|
||||
const unsigned char *p1 = x, *p2 = y;
|
||||
int tmp;
|
||||
|
||||
while (len--) {
|
||||
|
@ -88,7 +89,7 @@ rb_memcicmp(char *p1, char *p2, long len)
|
|||
}
|
||||
|
||||
int
|
||||
rb_memcmp(char *p1, char *p2, long len)
|
||||
rb_memcmp(const void *p1, const void *p2, long len)
|
||||
{
|
||||
if (!ruby_ignorecase) {
|
||||
return memcmp(p1, p2, len);
|
||||
|
@ -97,10 +98,10 @@ rb_memcmp(char *p1, char *p2, long len)
|
|||
}
|
||||
|
||||
long
|
||||
rb_memsearch(char *x0, long m, char *y0, long n)
|
||||
rb_memsearch(const void *x0, long m, const void *y0, long n)
|
||||
{
|
||||
unsigned char *x = (unsigned char *)x0, *y = (unsigned char *)y0;
|
||||
unsigned char *s, *e;
|
||||
const unsigned char *x = x0, *y = y0;
|
||||
const unsigned char *s, *e;
|
||||
long i;
|
||||
int d;
|
||||
unsigned long hx, hy;
|
||||
|
@ -151,7 +152,9 @@ rb_memsearch(char *x0, long m, char *y0, long n)
|
|||
return s-y;
|
||||
}
|
||||
|
||||
#define REG_LITERAL FL_USER5
|
||||
#define REG_CASESTATE FL_USER0
|
||||
|
||||
#define KCODE_NONE 0
|
||||
#define KCODE_EUC FL_USER1
|
||||
#define KCODE_SJIS FL_USER2
|
||||
|
@ -167,10 +170,8 @@ rb_memsearch(char *x0, long m, char *y0, long n)
|
|||
#define ARG_KCODE_UTF8 (ARG_KCODE_UNIT * 4)
|
||||
#define ARG_KCODE_MASK (ARG_KCODE_UNIT * 7)
|
||||
|
||||
|
||||
static int reg_kcode = DEFAULT_KCODE;
|
||||
|
||||
|
||||
static int char_to_option(int c)
|
||||
{
|
||||
int val;
|
||||
|
@ -505,13 +506,13 @@ rb_reg_to_s(VALUE re)
|
|||
int options, opt;
|
||||
const int embeddable = ONIG_OPTION_MULTILINE|ONIG_OPTION_IGNORECASE|ONIG_OPTION_EXTEND;
|
||||
long len;
|
||||
const char* ptr;
|
||||
const UChar* ptr;
|
||||
VALUE str = rb_str_buf_new2("(?");
|
||||
|
||||
rb_reg_check(re);
|
||||
|
||||
options = RREGEXP(re)->ptr->options;
|
||||
ptr = RREGEXP(re)->str;
|
||||
ptr = (UChar*)RREGEXP(re)->str;
|
||||
len = RREGEXP(re)->len;
|
||||
again:
|
||||
if (len >= 4 && ptr[0] == '(' && ptr[1] == '?') {
|
||||
|
@ -566,7 +567,7 @@ rb_reg_to_s(VALUE re)
|
|||
}
|
||||
if (err) {
|
||||
options = RREGEXP(re)->ptr->options;
|
||||
ptr = RREGEXP(re)->str;
|
||||
ptr = (UChar*)RREGEXP(re)->str;
|
||||
len = RREGEXP(re)->len;
|
||||
}
|
||||
}
|
||||
|
@ -583,7 +584,7 @@ rb_reg_to_s(VALUE re)
|
|||
}
|
||||
|
||||
rb_str_buf_cat2(str, ":");
|
||||
rb_reg_expr_str(str, ptr, len);
|
||||
rb_reg_expr_str(str, (char*)ptr, len);
|
||||
rb_str_buf_cat2(str, ")");
|
||||
|
||||
OBJ_INFECT(str, re);
|
||||
|
@ -1247,12 +1248,12 @@ match_captures(VALUE match)
|
|||
}
|
||||
|
||||
static int
|
||||
name_to_backref_number(struct re_registers *regs, VALUE regexp, char* name, char* name_end)
|
||||
name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name, const char* name_end)
|
||||
{
|
||||
int num;
|
||||
|
||||
num = onig_name_to_backref_number(RREGEXP(regexp)->ptr,
|
||||
(unsigned char* )name, (unsigned char* )name_end, regs);
|
||||
(const unsigned char* )name, (const unsigned char* )name_end, regs);
|
||||
if (num >= 1) {
|
||||
return num;
|
||||
}
|
||||
|
@ -1301,7 +1302,7 @@ match_aref(int argc, VALUE *argv, VALUE match)
|
|||
}
|
||||
}
|
||||
else {
|
||||
char *p;
|
||||
const char *p;
|
||||
int num;
|
||||
|
||||
switch (TYPE(idx)) {
|
||||
|
@ -1336,6 +1337,8 @@ match_entry(VALUE match, long n)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)
|
||||
rb_raise(rb_eSecurityError, "Insecure: can't modify regexp");
|
||||
* mtch.select([index]*) => array
|
||||
*
|
||||
* Uses each <i>index</i> to access the matching values, returning an array of
|
||||
|
@ -1437,6 +1440,11 @@ rb_reg_initialize(VALUE obj, const char *s, long len,
|
|||
{
|
||||
struct RRegexp *re = RREGEXP(obj);
|
||||
|
||||
if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)
|
||||
rb_raise(rb_eSecurityError, "Insecure: can't modify regexp");
|
||||
rb_check_frozen(obj);
|
||||
if (FL_TEST(obj, REG_LITERAL))
|
||||
rb_raise(rb_eSecurityError, "can't modify literal regexp");
|
||||
if (re->ptr) onig_free(re->ptr);
|
||||
if (re->str) free(re->str);
|
||||
re->ptr = 0;
|
||||
|
@ -1459,6 +1467,7 @@ rb_reg_initialize(VALUE obj, const char *s, long len,
|
|||
if (options & ARG_KCODE_MASK) {
|
||||
kcode_reset_option();
|
||||
}
|
||||
if (ce) FL_SET(obj, REG_LITERAL);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -1760,7 +1769,6 @@ rb_reg_initialize_m(int argc, VALUE *argv, VALUE self)
|
|||
long len;
|
||||
int flags = 0;
|
||||
|
||||
rb_check_frozen(self);
|
||||
if (argc == 0 || argc > 3) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
}
|
||||
|
|
|
@ -276,8 +276,8 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist)
|
|||
UChar bs[6];
|
||||
va_list args;
|
||||
|
||||
va_init_list(args, (char* )fmt);
|
||||
n = vsnprintf((char* )buf, bufsize, (char* )fmt, args);
|
||||
va_init_list(args, (const char* )fmt);
|
||||
n = vsnprintf((char* )buf, bufsize, (const char* )fmt, args);
|
||||
va_end(args);
|
||||
|
||||
need = (pat_end - pat) * 4 + 4;
|
||||
|
|
|
@ -4487,11 +4487,11 @@ parse_effect(Node** np, OnigToken* tok, int term, UChar** src, UChar* end,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static char* PopularQStr[] = {
|
||||
static const char* PopularQStr[] = {
|
||||
"?", "*", "+", "??", "*?", "+?"
|
||||
};
|
||||
|
||||
static char* ReduceQStr[] = {
|
||||
static const char* ReduceQStr[] = {
|
||||
"", "", "*", "*?", "??", "+ and ??", "+? and ?"
|
||||
};
|
||||
|
||||
|
|
5
ruby.1
5
ruby.1
|
@ -309,9 +309,10 @@ this switch, unless you are going to debug the Ruby interpreter.
|
|||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width "RUBYLIB_PREFIX" -compact
|
||||
.It Ev RUBYLIB
|
||||
A colon-separated list of directories that are appended to Ruby's
|
||||
A colon-separated list of directories that are added to Ruby's
|
||||
library load path
|
||||
.Pf ( Li "$:" ) .
|
||||
.Pf ( Li "$:" ) . Directories from this environment variable are searched
|
||||
before the standard load path is searched.
|
||||
.Pp
|
||||
e.g.:
|
||||
.Dl RUBYLIB="$HOME/lib/ruby:$HOME/lib/rubyext"
|
||||
|
|
4
ruby.c
4
ruby.c
|
@ -73,7 +73,7 @@ usage(const char *name)
|
|||
/* This message really ought to be max 23 lines.
|
||||
* Removed -h because the user already knows that option. Others? */
|
||||
|
||||
static char *usage_msg[] = {
|
||||
static const char *usage_msg[] = {
|
||||
"-0[octal] specify record separator (\\0, if no argument)",
|
||||
"-a autosplit mode with -n or -p (splits $_ into $F)",
|
||||
"-c check syntax only",
|
||||
|
@ -99,7 +99,7 @@ usage(const char *name)
|
|||
"--version print the version",
|
||||
NULL
|
||||
};
|
||||
char **p = usage_msg;
|
||||
const char **p = usage_msg;
|
||||
|
||||
printf("Usage: %s [switches] [--] [programfile] [arguments]\n", name);
|
||||
while (*p)
|
||||
|
|
3
ruby.h
3
ruby.h
|
@ -547,7 +547,7 @@ void rb_gc_register_address(VALUE*);
|
|||
void rb_gc_unregister_address(VALUE*);
|
||||
|
||||
ID rb_intern(const char*);
|
||||
char *rb_id2name(ID);
|
||||
const char *rb_id2name(ID);
|
||||
ID rb_to_id(VALUE);
|
||||
|
||||
char *rb_class2name(VALUE);
|
||||
|
@ -629,6 +629,7 @@ RUBY_EXTERN VALUE rb_mGC;
|
|||
RUBY_EXTERN VALUE rb_mMath;
|
||||
RUBY_EXTERN VALUE rb_mProcess;
|
||||
|
||||
RUBY_EXTERN VALUE rb_cBasicObject;
|
||||
RUBY_EXTERN VALUE rb_cObject;
|
||||
RUBY_EXTERN VALUE rb_cArray;
|
||||
RUBY_EXTERN VALUE rb_cValues;
|
||||
|
|
270
sample/test.rb
270
sample/test.rb
|
@ -54,13 +54,13 @@ a = [*[]]; test_ok(a == [])
|
|||
a = [*[1]]; test_ok(a == [1])
|
||||
a = [*[1,2]]; test_ok(a == [1,2])
|
||||
|
||||
a = *[]; test_ok(a == nil)
|
||||
a = *[1]; test_ok(a == 1)
|
||||
a = *[nil]; test_ok(a == nil)
|
||||
a = *[[]]; test_ok(a == [])
|
||||
a = *[]; test_ok(a == [])
|
||||
a = *[1]; test_ok(a == [1])
|
||||
a = *[nil]; test_ok(a == [nil])
|
||||
a = *[[]]; test_ok(a == [[]])
|
||||
a = *[1,2]; test_ok(a == [1,2])
|
||||
a = *[*[]]; test_ok(a == nil)
|
||||
a = *[*[1]]; test_ok(a == 1)
|
||||
a = *[*[]]; test_ok(a == [])
|
||||
a = *[*[1]]; test_ok(a == [1])
|
||||
a = *[*[1,2]]; test_ok(a == [1,2])
|
||||
|
||||
a, = nil; test_ok(a == nil)
|
||||
|
@ -87,14 +87,14 @@ a, = *[*[1,2]]; test_ok(a == 1)
|
|||
|
||||
*a = nil; test_ok(a == [nil])
|
||||
*a = 1; test_ok(a == [1])
|
||||
*a = []; test_ok(a == [[]])
|
||||
*a = [1]; test_ok(a == [[1]])
|
||||
*a = [nil]; test_ok(a == [[nil]])
|
||||
*a = [[]]; test_ok(a == [[[]]])
|
||||
*a = [1,2]; test_ok(a == [[1,2]])
|
||||
*a = [*[]]; test_ok(a == [[]])
|
||||
*a = [*[1]]; test_ok(a == [[1]])
|
||||
*a = [*[1,2]]; test_ok(a == [[1,2]])
|
||||
*a = []; test_ok(a == [])
|
||||
*a = [1]; test_ok(a == [1])
|
||||
*a = [nil]; test_ok(a == [nil])
|
||||
*a = [[]]; test_ok(a == [[]])
|
||||
*a = [1,2]; test_ok(a == [1,2])
|
||||
*a = [*[]]; test_ok(a == [])
|
||||
*a = [*[1]]; test_ok(a == [1])
|
||||
*a = [*[1,2]]; test_ok(a == [1,2])
|
||||
|
||||
*a = *[]; test_ok(a == [])
|
||||
*a = *[1]; test_ok(a == [1])
|
||||
|
@ -127,18 +127,13 @@ a,b,*c = *[*[1,2]]; test_ok([a,b,c] == [1,2,[]])
|
|||
|
||||
def f; yield nil; end; f {|a| test_ok(a == nil)}
|
||||
def f; yield 1; end; f {|a| test_ok(a == 1)}
|
||||
def f; yield []; end; f {|a| test_ok(a == [])}
|
||||
def f; yield [1]; end; f {|a| test_ok(a == [1])}
|
||||
def f; yield [nil]; end; f {|a| test_ok(a == [nil])}
|
||||
def f; yield [[]]; end; f {|a| test_ok(a == [[]])}
|
||||
def f; yield [*[]]; end; f {|a| test_ok(a == [])}
|
||||
def f; yield [*[1]]; end; f {|a| test_ok(a == [1])}
|
||||
def f; yield [*[1,2]]; end; f {|a| test_ok(a == [1,2])}
|
||||
|
||||
def f; yield *[]; end; f {|a| test_ok(a == nil)}
|
||||
def f; yield *[1]; end; f {|a| test_ok(a == 1)}
|
||||
def f; yield *[nil]; end; f {|a| test_ok(a == nil)}
|
||||
def f; yield *[[]]; end; f {|a| test_ok(a == [])}
|
||||
def f; yield *[*[]]; end; f {|a| test_ok(a == nil)}
|
||||
def f; yield *[*[1]]; end; f {|a| test_ok(a == 1)}
|
||||
def f; yield *[*[1,2]]; end; f {|a| test_ok(a == 1)}
|
||||
|
||||
def f; yield; end; f {|a,| test_ok(a == nil)}
|
||||
def f; yield nil; end; f {|a,| test_ok(a == nil)}
|
||||
|
@ -162,14 +157,14 @@ def f; yield *[*[1,2]]; end; f {|a,| test_ok(a == 1)}
|
|||
def f; yield; end; f {|*a| test_ok(a == [])}
|
||||
def f; yield nil; end; f {|*a| test_ok(a == [nil])}
|
||||
def f; yield 1; end; f {|*a| test_ok(a == [1])}
|
||||
def f; yield []; end; f {|*a| test_ok(a == [[]])}
|
||||
def f; yield [1]; end; f {|*a| test_ok(a == [[1]])}
|
||||
def f; yield [nil]; end; f {|*a| test_ok(a == [[nil]])}
|
||||
def f; yield [[]]; end; f {|*a| test_ok(a == [[[]]])}
|
||||
def f; yield [1,2]; end; f {|*a| test_ok(a == [[1,2]])}
|
||||
def f; yield [*[]]; end; f {|*a| test_ok(a == [[]])}
|
||||
def f; yield [*[1]]; end; f {|*a| test_ok(a == [[1]])}
|
||||
def f; yield [*[1,2]]; end; f {|*a| test_ok(a == [[1,2]])}
|
||||
def f; yield []; end; f {|*a| test_ok(a == [])}
|
||||
def f; yield [1]; end; f {|*a| test_ok(a == [1])}
|
||||
def f; yield [nil]; end; f {|*a| test_ok(a == [nil])}
|
||||
def f; yield [[]]; end; f {|*a| test_ok(a == [[]])}
|
||||
def f; yield [1,2]; end; f {|*a| test_ok(a == [1,2])}
|
||||
def f; yield [*[]]; end; f {|*a| test_ok(a == [])}
|
||||
def f; yield [*[1]]; end; f {|*a| test_ok(a == [1])}
|
||||
def f; yield [*[1,2]]; end; f {|*a| test_ok(a == [1,2])}
|
||||
|
||||
def f; yield *[]; end; f {|*a| test_ok(a == [])}
|
||||
def f; yield *[1]; end; f {|*a| test_ok(a == [1])}
|
||||
|
@ -209,39 +204,39 @@ def r; return [*[]]; end; a = r(); test_ok(a == [])
|
|||
def r; return [*[1]]; end; a = r(); test_ok(a == [1])
|
||||
def r; return [*[1,2]]; end; a = r(); test_ok(a == [1,2])
|
||||
|
||||
def r; return *[]; end; a = r(); test_ok(a == nil)
|
||||
def r; return *[1]; end; a = r(); test_ok(a == 1)
|
||||
def r; return *[nil]; end; a = r(); test_ok(a == nil)
|
||||
def r; return *[[]]; end; a = r(); test_ok(a == [])
|
||||
def r; return *[*[]]; end; a = r(); test_ok(a == nil)
|
||||
def r; return *[*[1]]; end; a = r(); test_ok(a == 1)
|
||||
def r; return *[]; end; a = r(); test_ok(a == [])
|
||||
def r; return *[1]; end; a = r(); test_ok(a == [1])
|
||||
def r; return *[nil]; end; a = r(); test_ok(a == [nil])
|
||||
def r; return *[[]]; end; a = r(); test_ok(a == [[]])
|
||||
def r; return *[*[]]; end; a = r(); test_ok(a == [])
|
||||
def r; return *[*[1]]; end; a = r(); test_ok(a == [1])
|
||||
def r; return *[*[1,2]]; end; a = r(); test_ok(a == [1,2])
|
||||
|
||||
def r; return *[[]]; end; a = *r(); test_ok(a == nil)
|
||||
def r; return *[[]]; end; a = *r(); test_ok(a == [[]])
|
||||
def r; return *[*[1,2]]; end; a = *r(); test_ok(a == [1,2])
|
||||
|
||||
def r; return; end; *a = r(); test_ok(a == [nil])
|
||||
def r; return nil; end; *a = r(); test_ok(a == [nil])
|
||||
def r; return 1; end; *a = r(); test_ok(a == [1])
|
||||
def r; return []; end; *a = r(); test_ok(a == [[]])
|
||||
def r; return [1]; end; *a = r(); test_ok(a == [[1]])
|
||||
def r; return [nil]; end; *a = r(); test_ok(a == [[nil]])
|
||||
def r; return [[]]; end; *a = r(); test_ok(a == [[[]]])
|
||||
def r; return [1,2]; end; *a = r(); test_ok(a == [[1,2]])
|
||||
def r; return [*[]]; end; *a = r(); test_ok(a == [[]])
|
||||
def r; return [*[1]]; end; *a = r(); test_ok(a == [[1]])
|
||||
def r; return [*[1,2]]; end; *a = r(); test_ok(a == [[1,2]])
|
||||
def r; return []; end; *a = r(); test_ok(a == [])
|
||||
def r; return [1]; end; *a = r(); test_ok(a == [1])
|
||||
def r; return [nil]; end; *a = r(); test_ok(a == [nil])
|
||||
def r; return [[]]; end; *a = r(); test_ok(a == [[]])
|
||||
def r; return [1,2]; end; *a = r(); test_ok(a == [1,2])
|
||||
def r; return [*[]]; end; *a = r(); test_ok(a == [])
|
||||
def r; return [*[1]]; end; *a = r(); test_ok(a == [1])
|
||||
def r; return [*[1,2]]; end; *a = r(); test_ok(a == [1,2])
|
||||
|
||||
def r; return *[]; end; *a = r(); test_ok(a == [nil])
|
||||
def r; return *[]; end; *a = r(); test_ok(a == [])
|
||||
def r; return *[1]; end; *a = r(); test_ok(a == [1])
|
||||
def r; return *[nil]; end; *a = r(); test_ok(a == [nil])
|
||||
def r; return *[[]]; end; *a = r(); test_ok(a == [[]])
|
||||
def r; return *[1,2]; end; *a = r(); test_ok(a == [[1,2]])
|
||||
def r; return *[*[]]; end; *a = r(); test_ok(a == [nil])
|
||||
def r; return *[1,2]; end; *a = r(); test_ok(a == [1,2])
|
||||
def r; return *[*[]]; end; *a = r(); test_ok(a == [])
|
||||
def r; return *[*[1]]; end; *a = r(); test_ok(a == [1])
|
||||
def r; return *[*[1,2]]; end; *a = r(); test_ok(a == [[1,2]])
|
||||
def r; return *[*[1,2]]; end; *a = r(); test_ok(a == [1,2])
|
||||
|
||||
def r; return *[[]]; end; *a = *r(); test_ok(a == [])
|
||||
def r; return *[[]]; end; *a = *r(); test_ok(a == [[]])
|
||||
def r; return *[1,2]; end; *a = *r(); test_ok(a == [1,2])
|
||||
def r; return *[*[1,2]]; end; *a = *r(); test_ok(a == [1,2])
|
||||
|
||||
|
@ -260,7 +255,7 @@ def r; return [*[1,2]]; end; a,b,*c = r(); test_ok([a,b,c] == [1,2,[]])
|
|||
def r; return *[]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
|
||||
def r; return *[1]; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]])
|
||||
def r; return *[nil]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
|
||||
def r; return *[[]]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
|
||||
def r; return *[[]]; end; a,b,*c = r(); test_ok([a,b,c] == [[],nil,[]])
|
||||
def r; return *[1,2]; end; a,b,*c = r(); test_ok([a,b,c] == [1,2,[]])
|
||||
def r; return *[*[]]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
|
||||
def r; return *[*[1]]; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]])
|
||||
|
@ -316,36 +311,36 @@ a = loop do break [*[]]; end; test_ok(a == [])
|
|||
a = loop do break [*[1]]; end; test_ok(a == [1])
|
||||
a = loop do break [*[1,2]]; end; test_ok(a == [1,2])
|
||||
|
||||
a = loop do break *[]; end; test_ok(a == nil)
|
||||
a = loop do break *[1]; end; test_ok(a == 1)
|
||||
a = loop do break *[nil]; end; test_ok(a == nil)
|
||||
a = loop do break *[[]]; end; test_ok(a == [])
|
||||
a = loop do break *[*[]]; end; test_ok(a == nil)
|
||||
a = loop do break *[*[1]]; end; test_ok(a == 1)
|
||||
a = loop do break *[]; end; test_ok(a == [])
|
||||
a = loop do break *[1]; end; test_ok(a == [1])
|
||||
a = loop do break *[nil]; end; test_ok(a == [nil])
|
||||
a = loop do break *[[]]; end; test_ok(a == [[]])
|
||||
a = loop do break *[*[]]; end; test_ok(a == [])
|
||||
a = loop do break *[*[1]]; end; test_ok(a == [1])
|
||||
a = loop do break *[*[1,2]]; end; test_ok(a == [1,2])
|
||||
|
||||
*a = loop do break; end; test_ok(a == [nil])
|
||||
*a = loop do break nil; end; test_ok(a == [nil])
|
||||
*a = loop do break 1; end; test_ok(a == [1])
|
||||
*a = loop do break []; end; test_ok(a == [[]])
|
||||
*a = loop do break [1]; end; test_ok(a == [[1]])
|
||||
*a = loop do break [nil]; end; test_ok(a == [[nil]])
|
||||
*a = loop do break [[]]; end; test_ok(a == [[[]]])
|
||||
*a = loop do break [1,2]; end; test_ok(a == [[1,2]])
|
||||
*a = loop do break [*[]]; end; test_ok(a == [[]])
|
||||
*a = loop do break [*[1]]; end; test_ok(a == [[1]])
|
||||
*a = loop do break [*[1,2]]; end; test_ok(a == [[1,2]])
|
||||
*a = loop do break []; end; test_ok(a == [])
|
||||
*a = loop do break [1]; end; test_ok(a == [1])
|
||||
*a = loop do break [nil]; end; test_ok(a == [nil])
|
||||
*a = loop do break [[]]; end; test_ok(a == [[]])
|
||||
*a = loop do break [1,2]; end; test_ok(a == [1,2])
|
||||
*a = loop do break [*[]]; end; test_ok(a == [])
|
||||
*a = loop do break [*[1]]; end; test_ok(a == [1])
|
||||
*a = loop do break [*[1,2]]; end; test_ok(a == [1,2])
|
||||
|
||||
*a = loop do break *[]; end; test_ok(a == [nil])
|
||||
*a = loop do break *[]; end; test_ok(a == [])
|
||||
*a = loop do break *[1]; end; test_ok(a == [1])
|
||||
*a = loop do break *[nil]; end; test_ok(a == [nil])
|
||||
*a = loop do break *[[]]; end; test_ok(a == [[]])
|
||||
*a = loop do break *[1,2]; end; test_ok(a == [[1,2]])
|
||||
*a = loop do break *[*[]]; end; test_ok(a == [nil])
|
||||
*a = loop do break *[1,2]; end; test_ok(a == [1,2])
|
||||
*a = loop do break *[*[]]; end; test_ok(a == [])
|
||||
*a = loop do break *[*[1]]; end; test_ok(a == [1])
|
||||
*a = loop do break *[*[1,2]]; end; test_ok(a == [[1,2]])
|
||||
*a = loop do break *[*[1,2]]; end; test_ok(a == [1,2])
|
||||
|
||||
*a = *loop do break *[[]]; end; test_ok(a == [])
|
||||
*a = *loop do break *[[]]; end; test_ok(a == [[]])
|
||||
*a = *loop do break *[1,2]; end; test_ok(a == [1,2])
|
||||
*a = *loop do break *[*[1,2]]; end; test_ok(a == [1,2])
|
||||
|
||||
|
@ -364,7 +359,7 @@ a,b,*c = loop do break [*[1,2]]; end; test_ok([a,b,c] == [1,2,[]])
|
|||
a,b,*c = loop do break *[]; end; test_ok([a,b,c] == [nil,nil,[]])
|
||||
a,b,*c = loop do break *[1]; end; test_ok([a,b,c] == [1,nil,[]])
|
||||
a,b,*c = loop do break *[nil]; end; test_ok([a,b,c] == [nil,nil,[]])
|
||||
a,b,*c = loop do break *[[]]; end; test_ok([a,b,c] == [nil,nil,[]])
|
||||
a,b,*c = loop do break *[[]]; end; test_ok([a,b,c] == [[],nil,[]])
|
||||
a,b,*c = loop do break *[1,2]; end; test_ok([a,b,c] == [1,2,[]])
|
||||
a,b,*c = loop do break *[*[]]; end; test_ok([a,b,c] == [nil,nil,[]])
|
||||
a,b,*c = loop do break *[*[1]]; end; test_ok([a,b,c] == [1,nil,[]])
|
||||
|
@ -382,29 +377,29 @@ r([]){next [*[]]}
|
|||
r([1]){next [*[1]]}
|
||||
r([1,2]){next [*[1,2]]}
|
||||
|
||||
r(nil){next *[]}
|
||||
r(1){next *[1]}
|
||||
r(nil){next *[nil]}
|
||||
r([]){next *[[]]}
|
||||
r(nil){next *[*[]]}
|
||||
r(1){next *[*[1]]}
|
||||
r([]){next *[]}
|
||||
r([1]){next *[1]}
|
||||
r([nil]){next *[nil]}
|
||||
r([[]]){next *[[]]}
|
||||
r([]){next *[*[]]}
|
||||
r([1]){next *[*[1]]}
|
||||
r([1,2]){next *[*[1,2]]}
|
||||
|
||||
def r(val); *a = yield(); test_ok(a == val, 2); end
|
||||
r([nil]){next}
|
||||
r([nil]){next nil}
|
||||
r([1]){next 1}
|
||||
r([[]]){next []}
|
||||
r([[1]]){next [1]}
|
||||
r([[nil]]){next [nil]}
|
||||
r([[[]]]){next [[]]}
|
||||
r([[1,2]]){next [1,2]}
|
||||
r([[]]){next [*[]]}
|
||||
r([[1]]){next [*[1]]}
|
||||
r([[1,2]]){next [*[1,2]]}
|
||||
r([]){next []}
|
||||
r([1]){next [1]}
|
||||
r([nil]){next [nil]}
|
||||
r([[]]){next [[]]}
|
||||
r([1,2]){next [1,2]}
|
||||
r([]){next [*[]]}
|
||||
r([1]){next [*[1]]}
|
||||
r([1,2]){next [*[1,2]]}
|
||||
|
||||
def r(val); *a = *yield(); test_ok(a == val, 2); end
|
||||
r([]){next *[[]]}
|
||||
r([[]]){next *[[]]}
|
||||
r([1,2]){next *[1,2]}
|
||||
r([1,2]){next *[*[1,2]]}
|
||||
|
||||
|
@ -422,7 +417,7 @@ r([1,nil,[]]){next [*[1]]}
|
|||
r([1,2,[]]){next [*[1,2]]}
|
||||
|
||||
def r(val); a,b,*c = *yield(); test_ok([a,b,c] == val, 2); end
|
||||
r([nil,nil,[]]){next *[[]]}
|
||||
r([[],nil,[]]){next *[[]]}
|
||||
r([1,2,[]]){next *[1,2]}
|
||||
r([1,2,[]]){next *[*[1,2]]}
|
||||
|
||||
|
@ -963,22 +958,22 @@ IterTest.new([2]).each2 {|x| test_ok(x == [2])}
|
|||
#IterTest.new([3]).each3 {|x| test_ok(x == 3)}
|
||||
IterTest.new([4]).each4 {|x| test_ok(x == 4)}
|
||||
IterTest.new([5]).each5 {|x| test_ok(x == 5)}
|
||||
IterTest.new([6]).each6 {|x| test_ok(x == [6])}
|
||||
IterTest.new([6]).each6 {|x| test_ok(x == 6)}
|
||||
#IterTest.new([7]).each7 {|x| test_ok(x == 7)}
|
||||
IterTest.new([8]).each8 {|x| test_ok(x == 8)}
|
||||
|
||||
IterTest.new([[0]]).each0 {|x| test_ok(x == [0])}
|
||||
IterTest.new([[1]]).each1 {|x| test_ok(x == [1])}
|
||||
IterTest.new([[2]]).each2 {|x| test_ok(x == [[2]])}
|
||||
IterTest.new([[0]]).each0 {|x| test_ok(x == 0)}
|
||||
IterTest.new([[1]]).each1 {|x| test_ok(x == 1)}
|
||||
IterTest.new([[2]]).each2 {|x| test_ok(x == [2])}
|
||||
IterTest.new([[3]]).each3 {|x| test_ok(x == 3)}
|
||||
IterTest.new([[4]]).each4 {|x| test_ok(x == [4])}
|
||||
IterTest.new([[5]]).each5 {|x| test_ok(x == [5])}
|
||||
IterTest.new([[6]]).each6 {|x| test_ok(x == [[6]])}
|
||||
IterTest.new([[4]]).each4 {|x| test_ok(x == 4)}
|
||||
IterTest.new([[5]]).each5 {|x| test_ok(x == 5)}
|
||||
IterTest.new([[6]]).each6 {|x| test_ok(x == 6)}
|
||||
IterTest.new([[7]]).each7 {|x| test_ok(x == 7)}
|
||||
IterTest.new([[8]]).each8 {|x| test_ok(x == [8])}
|
||||
IterTest.new([[8]]).each8 {|x| test_ok(x == 8)}
|
||||
|
||||
IterTest.new([[0,0]]).each0 {|x| test_ok(x == [0,0])}
|
||||
IterTest.new([[8,8]]).each8 {|x| test_ok(x == [8,8])}
|
||||
IterTest.new([[0,0]]).each0 {|*x| test_ok(x == [0,0])}
|
||||
IterTest.new([[8,8]]).each8 {|*x| test_ok(x == [8])}
|
||||
|
||||
def m0(v)
|
||||
v
|
||||
|
@ -1018,7 +1013,7 @@ end
|
|||
block_test(NilClass)
|
||||
block_test(Proc){}
|
||||
|
||||
def argument_test(state, proc, *args)
|
||||
def call_argument_test(state, proc, *args)
|
||||
x = state
|
||||
begin
|
||||
proc.call(*args)
|
||||
|
@ -1028,27 +1023,43 @@ def argument_test(state, proc, *args)
|
|||
test_ok(x,2)
|
||||
end
|
||||
|
||||
argument_test(true, lambda{||})
|
||||
argument_test(false, lambda{||}, 1)
|
||||
argument_test(true, lambda{|a,|}, 1)
|
||||
argument_test(false, lambda{|a,|})
|
||||
argument_test(false, lambda{|a,|}, 1,2)
|
||||
def yield_argument_test(state, proc, *args)
|
||||
x = state
|
||||
begin
|
||||
proc.yield(*args)
|
||||
rescue ArgumentError
|
||||
x = !x
|
||||
end
|
||||
test_ok(x,2)
|
||||
end
|
||||
|
||||
call_argument_test(true, lambda{||})
|
||||
call_argument_test(false, lambda{||}, 1)
|
||||
call_argument_test(true, lambda{|a,|}, 1)
|
||||
call_argument_test(false, lambda{|a,|})
|
||||
call_argument_test(false, lambda{|a,|}, 1,2)
|
||||
|
||||
yield_argument_test(true, lambda{||})
|
||||
yield_argument_test(true, lambda{||}, 1)
|
||||
yield_argument_test(true, lambda{|a,|}, 1)
|
||||
yield_argument_test(true, lambda{|a,|})
|
||||
yield_argument_test(true, lambda{|a,|}, 1,2)
|
||||
|
||||
def get_block(&block)
|
||||
block
|
||||
end
|
||||
|
||||
test_ok(Proc == get_block{}.class)
|
||||
argument_test(true, get_block{||})
|
||||
argument_test(true, get_block{||}, 1)
|
||||
argument_test(true, get_block{|a,|}, 1)
|
||||
argument_test(true, get_block{|a,|})
|
||||
argument_test(true, get_block{|a,|}, 1,2)
|
||||
yield_argument_test(true, get_block{||})
|
||||
yield_argument_test(true, get_block{||}, 1)
|
||||
yield_argument_test(true, get_block{|a,|}, 1)
|
||||
yield_argument_test(true, get_block{|a,|})
|
||||
yield_argument_test(true, get_block{|a,|}, 1,2)
|
||||
|
||||
argument_test(true, get_block(&lambda{||}))
|
||||
argument_test(false, get_block(&lambda{||}),1)
|
||||
argument_test(true, get_block(&lambda{|a,|}),1)
|
||||
argument_test(false, get_block(&lambda{|a,|}),1,2)
|
||||
call_argument_test(true, get_block(&lambda{||}))
|
||||
call_argument_test(false, get_block(&lambda{||}),1)
|
||||
call_argument_test(true, get_block(&lambda{|a,|}),1)
|
||||
call_argument_test(false, get_block(&lambda{|a,|}),1,2)
|
||||
|
||||
blk = get_block{11}
|
||||
test_ok(blk.class == Proc)
|
||||
|
@ -1062,8 +1073,8 @@ test_ok(lmd.to_proc.class == Proc)
|
|||
test_ok(lmd.clone.call == 44)
|
||||
test_ok(get_block(&lmd).class == Proc)
|
||||
|
||||
test_ok(Proc.new{|a,| a}.call(1,2,3) == 1)
|
||||
argument_test(true, Proc.new{|a,|}, 1,2)
|
||||
test_ok(Proc.new{|a,| a}.yield(1,2,3) == 1)
|
||||
yield_argument_test(true, Proc.new{|a,|}, 1,2)
|
||||
|
||||
test_ok(Proc.new{|&b| b.call(10)}.call {|x| x} == 10)
|
||||
test_ok(Proc.new{|a,&b| b.call(a)}.call(12) {|x| x} == 12)
|
||||
|
@ -1071,7 +1082,7 @@ test_ok(Proc.new{|a,&b| b.call(a)}.call(12) {|x| x} == 12)
|
|||
def test_return1
|
||||
Proc.new {
|
||||
return 55
|
||||
}.call + 5
|
||||
}.yield + 5
|
||||
end
|
||||
test_ok(test_return1() == 55)
|
||||
def test_return2
|
||||
|
@ -1090,7 +1101,7 @@ end
|
|||
def proc_return1
|
||||
proc_call{return 42}+1
|
||||
end
|
||||
test_ok(proc_return1() == 42)
|
||||
test_ok(proc_return1() == 43)
|
||||
def proc_return2
|
||||
proc_yield{return 42}+1
|
||||
end
|
||||
|
@ -1106,7 +1117,7 @@ def ljump_test(state, proc, *args)
|
|||
test_ok(x,2)
|
||||
end
|
||||
|
||||
ljump_test(false, get_block{break})
|
||||
ljump_test(true, get_block{break})
|
||||
ljump_test(true, lambda{break})
|
||||
|
||||
def exit_value_test(&block)
|
||||
|
@ -1149,11 +1160,11 @@ def test_b2
|
|||
block_get{break 21}.call
|
||||
end
|
||||
end
|
||||
test_ok(test_b2() == 22)
|
||||
test_ok(test_b2() == 21)
|
||||
|
||||
def test_b3
|
||||
ljump_rescue(33) do
|
||||
Proc.new{break 31}.call
|
||||
Proc.new{break 31}.yield
|
||||
end
|
||||
end
|
||||
test_ok(test_b3() == 33)
|
||||
|
@ -1169,7 +1180,7 @@ def test_b5
|
|||
block_call(&b)
|
||||
end
|
||||
end
|
||||
test_ok(test_b5() == 55)
|
||||
test_ok(test_b5() == 54)
|
||||
|
||||
def test_b6
|
||||
b = lambda{break 67}
|
||||
|
@ -1188,7 +1199,7 @@ def test_b7
|
|||
block_call(&b)
|
||||
end
|
||||
end
|
||||
test_ok(test_b7() == 77)
|
||||
test_ok(test_b7() == 78)
|
||||
|
||||
def util_b8(&block)
|
||||
block_call(&block)
|
||||
|
@ -1220,7 +1231,7 @@ test_ok(test_b10() == 100)
|
|||
def test_b11
|
||||
ljump_rescue(111) do
|
||||
loop do
|
||||
Proc.new{break 110}.call
|
||||
Proc.new{break 110}.yield
|
||||
break 112
|
||||
end
|
||||
end
|
||||
|
@ -1238,7 +1249,7 @@ test_ok(test_b12() == 122)
|
|||
def test_b13
|
||||
ljump_rescue(133) do
|
||||
while true
|
||||
Proc.new{break 130}.call
|
||||
Proc.new{break 130}.yield
|
||||
break 131
|
||||
end
|
||||
end
|
||||
|
@ -1260,7 +1271,7 @@ end
|
|||
test_ok(test_b15{|e| break 155 } == 155)
|
||||
|
||||
def marity_test(m)
|
||||
method = self.method(m)
|
||||
method = method(m)
|
||||
test_ok(method.arity == method.to_proc.arity, 2)
|
||||
end
|
||||
marity_test(:test_ok)
|
||||
|
@ -1421,7 +1432,6 @@ $good = true;
|
|||
for i in 4000..4096
|
||||
n1 = 1 << i;
|
||||
if (n1**2-1) / (n1+1) != (n1-1)
|
||||
p i
|
||||
$good = false
|
||||
end
|
||||
end
|
||||
|
@ -1525,9 +1535,9 @@ test_ok($x.sub(/.*\.([^\.]+)$/, '<\&>') == "<a.gif>")
|
|||
# character constants(assumes ASCII)
|
||||
test_ok("a"[0] == ?a)
|
||||
test_ok(?a == ?a)
|
||||
test_ok(?\C-a == 1)
|
||||
test_ok(?\M-a == 225)
|
||||
test_ok(?\M-\C-a == 129)
|
||||
test_ok(?\C-a == "\1")
|
||||
test_ok(?\M-a == "\341")
|
||||
test_ok(?\M-\C-a == "\201")
|
||||
test_ok("a".upcase![0] == ?A)
|
||||
test_ok("A".downcase![0] == ?a)
|
||||
test_ok("abc".tr!("a-z", "A-Z") == "ABC")
|
||||
|
@ -1539,7 +1549,7 @@ $x = "abcdef"
|
|||
$y = [ ?a, ?b, ?c, ?d, ?e, ?f ]
|
||||
$bad = false
|
||||
$x.each_byte {|i|
|
||||
if i != $y.shift
|
||||
if i.chr != $y.shift
|
||||
$bad = true
|
||||
break
|
||||
end
|
||||
|
@ -1927,7 +1937,7 @@ module M003; include M002; end
|
|||
module M002; include M001; end
|
||||
module M003; include M002; end
|
||||
|
||||
test_ok(M003.ancestors == [M003, M002, M001])
|
||||
test_ok(M003.ancestors == [M003, M002, M001, M002])
|
||||
|
||||
test_check "marshal"
|
||||
$x = [1,2,3,[4,5,"foo"],{1=>"bar"},2.5,fact(30)]
|
||||
|
|
6
signal.c
6
signal.c
|
@ -226,7 +226,7 @@ rb_f_kill(int argc, VALUE *argv)
|
|||
int negative = 0;
|
||||
int sig;
|
||||
int i;
|
||||
char *s;
|
||||
const char *s;
|
||||
|
||||
rb_secure(2);
|
||||
if (argc < 2)
|
||||
|
@ -564,7 +564,7 @@ trap(struct trap_arg *arg)
|
|||
sighandler_t func, oldfunc;
|
||||
VALUE command, oldcmd;
|
||||
int sig = -1;
|
||||
char *s;
|
||||
const char *s;
|
||||
|
||||
func = sighandler;
|
||||
if (NIL_P(arg->cmd)) {
|
||||
|
@ -630,7 +630,7 @@ trap(struct trap_arg *arg)
|
|||
rb_raise(rb_eArgError, "unsupported signal SIG%s", s);
|
||||
}
|
||||
|
||||
if (sig < 0 || sig > NSIG) {
|
||||
if (sig < 0 || sig >= NSIG) {
|
||||
rb_raise(rb_eArgError, "invalid signal number (%d)", sig);
|
||||
}
|
||||
#if defined(HAVE_SETITIMER)
|
||||
|
|
10
sprintf.c
10
sprintf.c
|
@ -394,7 +394,15 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
|
|||
VALUE val = GETARG();
|
||||
char c;
|
||||
|
||||
c = NUM2INT(val) & 0xff;
|
||||
if (rb_check_string_type(val)) {
|
||||
if (RSTRING(val)->len != 1) {
|
||||
rb_raise(rb_eArgError, "%%c requires a character");
|
||||
}
|
||||
c = RSTRING(val)->ptr[0];
|
||||
}
|
||||
else {
|
||||
c = NUM2INT(val) & 0xff;
|
||||
}
|
||||
if (!(flags & FWIDTH)) {
|
||||
PUSH(&c, 1);
|
||||
}
|
||||
|
|
115
st.c
115
st.c
|
@ -490,42 +490,97 @@ st_foreach(st_table *table, int (*func)(ANYARGS), st_data_t arg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* hash_32 - 32 bit Fowler/Noll/Vo FNV-1a hash code
|
||||
*
|
||||
* @(#) $Revision$
|
||||
* @(#) $Id$
|
||||
* @(#) $Source$
|
||||
*
|
||||
***
|
||||
*
|
||||
* Fowler/Noll/Vo hash
|
||||
*
|
||||
* The basis of this hash algorithm was taken from an idea sent
|
||||
* as reviewer comments to the IEEE POSIX P1003.2 committee by:
|
||||
*
|
||||
* Phong Vo (http://www.research.att.com/info/kpv/)
|
||||
* Glenn Fowler (http://www.research.att.com/~gsf/)
|
||||
*
|
||||
* In a subsequent ballot round:
|
||||
*
|
||||
* Landon Curt Noll (http://www.isthe.com/chongo/)
|
||||
*
|
||||
* improved on their algorithm. Some people tried this hash
|
||||
* and found that it worked rather well. In an EMail message
|
||||
* to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash.
|
||||
*
|
||||
* FNV hashes are designed to be fast while maintaining a low
|
||||
* collision rate. The FNV speed allows one to quickly hash lots
|
||||
* of data while maintaining a reasonable collision rate. See:
|
||||
*
|
||||
* http://www.isthe.com/chongo/tech/comp/fnv/index.html
|
||||
*
|
||||
* for more details as well as other forms of the FNV hash.
|
||||
***
|
||||
*
|
||||
* To use the recommended 32 bit FNV-1a hash, pass FNV1_32A_INIT as the
|
||||
* Fnv32_t hashval argument to fnv_32a_buf() or fnv_32a_str().
|
||||
*
|
||||
***
|
||||
*
|
||||
* Please do not copyright this code. This code is in the public domain.
|
||||
*
|
||||
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
||||
* EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
|
||||
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* By:
|
||||
* chongo <Landon Curt Noll> /\oo/\
|
||||
* http://www.isthe.com/chongo/
|
||||
*
|
||||
* Share and Enjoy! :-)
|
||||
*/
|
||||
|
||||
/*
|
||||
* 32 bit FNV-1 and FNV-1a non-zero initial basis
|
||||
*
|
||||
* The FNV-1 initial basis is the FNV-0 hash of the following 32 octets:
|
||||
*
|
||||
* chongo <Landon Curt Noll> /\../\
|
||||
*
|
||||
* NOTE: The \'s above are not back-slashing escape characters.
|
||||
* They are literal ASCII backslash 0x5c characters.
|
||||
*
|
||||
* NOTE: The FNV-1a initial basis is the same value as FNV-1 by definition.
|
||||
*/
|
||||
#define FNV1_32A_INIT 0x811c9dc5
|
||||
|
||||
/*
|
||||
* 32 bit magic FNV-1a prime
|
||||
*/
|
||||
#define FNV_32_PRIME 0x01000193
|
||||
|
||||
static int
|
||||
strhash(register const char *string)
|
||||
{
|
||||
register int c;
|
||||
register int hval = FNV1_32A_INIT;
|
||||
|
||||
#ifdef HASH_ELFHASH
|
||||
register unsigned int h = 0, g;
|
||||
/*
|
||||
* FNV-1a hash each octet in the buffer
|
||||
*/
|
||||
while (*string) {
|
||||
/* xor the bottom with the current octet */
|
||||
hval ^= (int)*string++;
|
||||
|
||||
while ((c = *string++) != '\0') {
|
||||
h = ( h << 4 ) + c;
|
||||
if ( g = h & 0xF0000000 )
|
||||
h ^= g >> 24;
|
||||
h &= ~g;
|
||||
/* multiply by the 32 bit FNV magic prime mod 2^32 */
|
||||
hval *= FNV_32_PRIME;
|
||||
}
|
||||
return h;
|
||||
#elif HASH_PERL
|
||||
register int val = 0;
|
||||
|
||||
while ((c = *string++) != '\0') {
|
||||
val += c;
|
||||
val += (val << 10);
|
||||
val ^= (val >> 6);
|
||||
}
|
||||
val += (val << 3);
|
||||
val ^= (val >> 11);
|
||||
|
||||
return val + (val << 15);
|
||||
#else
|
||||
register int val = 0;
|
||||
|
||||
while ((c = *string++) != '\0') {
|
||||
val = val*997 + c;
|
||||
}
|
||||
|
||||
return val + (val>>5);
|
||||
#endif
|
||||
return hval;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
164
string.c
164
string.c
|
@ -765,39 +765,103 @@ rb_str_concat(VALUE str1, VALUE str2)
|
|||
return str1;
|
||||
}
|
||||
|
||||
/*
|
||||
* hash_32 - 32 bit Fowler/Noll/Vo FNV-1a hash code
|
||||
*
|
||||
* @(#) $Revision$
|
||||
* @(#) $Id$
|
||||
* @(#) $Source$
|
||||
*
|
||||
***
|
||||
*
|
||||
* Fowler/Noll/Vo hash
|
||||
*
|
||||
* The basis of this hash algorithm was taken from an idea sent
|
||||
* as reviewer comments to the IEEE POSIX P1003.2 committee by:
|
||||
*
|
||||
* Phong Vo (http://www.research.att.com/info/kpv/)
|
||||
* Glenn Fowler (http://www.research.att.com/~gsf/)
|
||||
*
|
||||
* In a subsequent ballot round:
|
||||
*
|
||||
* Landon Curt Noll (http://www.isthe.com/chongo/)
|
||||
*
|
||||
* improved on their algorithm. Some people tried this hash
|
||||
* and found that it worked rather well. In an EMail message
|
||||
* to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash.
|
||||
*
|
||||
* FNV hashes are designed to be fast while maintaining a low
|
||||
* collision rate. The FNV speed allows one to quickly hash lots
|
||||
* of data while maintaining a reasonable collision rate. See:
|
||||
*
|
||||
* http://www.isthe.com/chongo/tech/comp/fnv/index.html
|
||||
*
|
||||
* for more details as well as other forms of the FNV hash.
|
||||
***
|
||||
*
|
||||
* To use the recommended 32 bit FNV-1a hash, pass FNV1_32A_INIT as the
|
||||
* Fnv32_t hashval argument to fnv_32a_buf() or fnv_32a_str().
|
||||
*
|
||||
***
|
||||
*
|
||||
* Please do not copyright this code. This code is in the public domain.
|
||||
*
|
||||
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
||||
* EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
|
||||
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* By:
|
||||
* chongo <Landon Curt Noll> /\oo/\
|
||||
* http://www.isthe.com/chongo/
|
||||
*
|
||||
* Share and Enjoy! :-)
|
||||
*/
|
||||
|
||||
/*
|
||||
* 32 bit FNV-1 and FNV-1a non-zero initial basis
|
||||
*
|
||||
* The FNV-1 initial basis is the FNV-0 hash of the following 32 octets:
|
||||
*
|
||||
* chongo <Landon Curt Noll> /\../\
|
||||
*
|
||||
* NOTE: The \'s above are not back-slashing escape characters.
|
||||
* They are literal ASCII backslash 0x5c characters.
|
||||
*
|
||||
* NOTE: The FNV-1a initial basis is the same value as FNV-1 by definition.
|
||||
*/
|
||||
#define FNV1_32A_INIT 0x811c9dc5
|
||||
|
||||
/*
|
||||
* 32 bit magic FNV-1a prime
|
||||
*/
|
||||
#define FNV_32_PRIME 0x01000193
|
||||
|
||||
int
|
||||
rb_str_hash(VALUE str)
|
||||
{
|
||||
register long len = RSTRING(str)->len;
|
||||
register char *p = RSTRING(str)->ptr;
|
||||
register int key = 0;
|
||||
register int hval = FNV1_32A_INIT;
|
||||
|
||||
#ifdef HASH_ELFHASH
|
||||
register unsigned int g;
|
||||
/*
|
||||
* FNV-1a hash each octet in the buffer
|
||||
*/
|
||||
while (len--) {
|
||||
/* xor the bottom with the current octet */
|
||||
hval ^= (int)*p++;
|
||||
|
||||
while (len--) {
|
||||
key = (key << 4) + *p++;
|
||||
if (g = key & 0xF0000000)
|
||||
key ^= g >> 24;
|
||||
key &= ~g;
|
||||
}
|
||||
#elif HASH_PERL
|
||||
while (len--) {
|
||||
key += *p++;
|
||||
key += (key << 10);
|
||||
key ^= (key >> 6);
|
||||
}
|
||||
key += (key << 3);
|
||||
key ^= (key >> 11);
|
||||
key += (key << 15);
|
||||
/* multiply by the 32 bit FNV magic prime mod 2^32 */
|
||||
#if defined(FNV_GCC_OPTIMIZATION)
|
||||
hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
|
||||
#else
|
||||
while (len--) {
|
||||
key = key*65599 + *p;
|
||||
p++;
|
||||
}
|
||||
key = key + (key>>5);
|
||||
hval *= FNV_32_PRIME;
|
||||
#endif
|
||||
return key;
|
||||
}
|
||||
return hval;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -810,8 +874,8 @@ rb_str_hash(VALUE str)
|
|||
static VALUE
|
||||
rb_str_hash_m(VALUE str)
|
||||
{
|
||||
int key = rb_str_hash(str);
|
||||
return INT2FIX(key);
|
||||
int hval = rb_str_hash(str);
|
||||
return INT2FIX(hval);
|
||||
}
|
||||
|
||||
#define lesser(a,b) (((a)>(b))?(b):(a))
|
||||
|
@ -1414,13 +1478,7 @@ rb_str_aref(VALUE str, VALUE indx)
|
|||
idx = FIX2LONG(indx);
|
||||
|
||||
num_index:
|
||||
if (idx < 0) {
|
||||
idx = RSTRING(str)->len + idx;
|
||||
}
|
||||
if (idx < 0 || RSTRING(str)->len <= idx) {
|
||||
return Qnil;
|
||||
}
|
||||
return INT2FIX(RSTRING(str)->ptr[idx] & 0xff);
|
||||
return rb_str_substr(str, idx, 1);
|
||||
|
||||
case T_REGEXP:
|
||||
return rb_str_subpat(str, indx, 0);
|
||||
|
@ -1456,21 +1514,21 @@ rb_str_aref(VALUE str, VALUE indx)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* str[fixnum] => fixnum or nil
|
||||
* str[fixnum] => new_str or nil
|
||||
* str[fixnum, fixnum] => new_str or nil
|
||||
* str[range] => new_str or nil
|
||||
* str[regexp] => new_str or nil
|
||||
* str[regexp, fixnum] => new_str or nil
|
||||
* str[other_str] => new_str or nil
|
||||
* str.slice(fixnum) => fixnum or nil
|
||||
* str.slice(fixnum) => new_str or nil
|
||||
* str.slice(fixnum, fixnum) => new_str or nil
|
||||
* str.slice(range) => new_str or nil
|
||||
* str.slice(regexp) => new_str or nil
|
||||
* str.slice(regexp, fixnum) => new_str or nil
|
||||
* str.slice(other_str) => new_str or nil
|
||||
*
|
||||
* Element Reference---If passed a single <code>Fixnum</code>, returns the code
|
||||
* of the character at that position. If passed two <code>Fixnum</code>
|
||||
* Element Reference---If passed a single <code>Fixnum</code>, returns a
|
||||
* substring of one character at that position. If passed two <code>Fixnum</code>
|
||||
* objects, returns a substring starting at the offset given by the first, and
|
||||
* a length given by the second. If given a range, a substring containing
|
||||
* characters at offsets given by the range is returned. In all three cases, if
|
||||
|
@ -1486,7 +1544,7 @@ rb_str_aref(VALUE str, VALUE indx)
|
|||
* match.
|
||||
*
|
||||
* a = "hello there"
|
||||
* a[1] #=> 101
|
||||
* a[1] #=> "e"
|
||||
* a[1,3] #=> "ell"
|
||||
* a[1..3] #=> "ell"
|
||||
* a[-3,2] #=> "er"
|
||||
|
@ -1615,17 +1673,7 @@ rb_str_aset(VALUE str, VALUE indx, VALUE val)
|
|||
goto out_of_range;
|
||||
idx += RSTRING(str)->len;
|
||||
}
|
||||
if (FIXNUM_P(val)) {
|
||||
rb_str_modify(str);
|
||||
if (RSTRING(str)->len == idx) {
|
||||
RSTRING(str)->len += 1;
|
||||
RESIZE_CAPA(str, RSTRING(str)->len);
|
||||
}
|
||||
RSTRING(str)->ptr[idx] = FIX2INT(val) & 0xff;
|
||||
}
|
||||
else {
|
||||
rb_str_splice(str, idx, 1, val);
|
||||
}
|
||||
rb_str_splice(str, idx, 1, val);
|
||||
return val;
|
||||
|
||||
case T_REGEXP:
|
||||
|
@ -1656,7 +1704,6 @@ rb_str_aset(VALUE str, VALUE indx, VALUE val)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* str[fixnum] = fixnum
|
||||
* str[fixnum] = new_str
|
||||
* str[fixnum, fixnum] = new_str
|
||||
* str[range] = aString
|
||||
|
@ -2158,6 +2205,22 @@ rb_str_clear(VALUE str)
|
|||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* string.chr -> string
|
||||
*
|
||||
* Returns a one-character string at the beginning of the string.
|
||||
*
|
||||
* a = "abcde"
|
||||
* a.chr #=> "a"
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
rb_str_chr(VALUE str)
|
||||
{
|
||||
return rb_str_substr(str, 0, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* str.reverse! => str
|
||||
|
@ -4217,6 +4280,7 @@ Init_String(void)
|
|||
rb_define_method(rb_cString, "rindex", rb_str_rindex_m, -1);
|
||||
rb_define_method(rb_cString, "replace", rb_str_replace, 1);
|
||||
rb_define_method(rb_cString, "clear", rb_str_clear, 0);
|
||||
rb_define_method(rb_cString, "chr", rb_str_chr, 0);
|
||||
|
||||
rb_define_method(rb_cString, "to_i", rb_str_to_i, -1);
|
||||
rb_define_method(rb_cString, "to_f", rb_str_to_f, 0);
|
||||
|
|
2
struct.c
2
struct.c
|
@ -451,7 +451,7 @@ inspect_struct(VALUE s, VALUE dummy, int recur)
|
|||
for (i=0; i<RSTRUCT_LEN(s); i++) {
|
||||
VALUE slot;
|
||||
ID id;
|
||||
char *p;
|
||||
const char *p;
|
||||
|
||||
if (i > 0) {
|
||||
rb_str_cat2(str, ", ");
|
||||
|
|
|
@ -29,25 +29,25 @@ class TestAssignment < Test::Unit::TestCase
|
|||
a = [*[1]]; assert_equal([1], a)
|
||||
a = [*[1,2]]; assert_equal([1,2], a)
|
||||
|
||||
a = *[]; assert_nil(a)
|
||||
a = *[1]; assert_equal(1, a)
|
||||
a = *[nil]; assert_nil(a)
|
||||
a = *[[]]; assert_equal([], a)
|
||||
a = *[]; assert_equal([], a)
|
||||
a = *[1]; assert_equal([1], a)
|
||||
a = *[nil]; assert_equal([nil], a)
|
||||
a = *[[]]; assert_equal([[]], a)
|
||||
a = *[1,2]; assert_equal([1,2], a)
|
||||
a = *[*[]]; assert_nil(a)
|
||||
a = *[*[1]]; assert_equal(1, a)
|
||||
a = *[*[]]; assert_equal([], a)
|
||||
a = *[*[1]]; assert_equal([1], a)
|
||||
a = *[*[1,2]]; assert_equal([1,2], a)
|
||||
|
||||
*a = nil; assert_equal([nil], a)
|
||||
*a = 1; assert_equal([1], a)
|
||||
*a = []; assert_equal([[]], a)
|
||||
*a = [1]; assert_equal([[1]], a)
|
||||
*a = [nil]; assert_equal([[nil]], a)
|
||||
*a = [[]]; assert_equal([[[]]], a)
|
||||
*a = [1,2]; assert_equal([[1,2]], a)
|
||||
*a = [*[]]; assert_equal([[]], a)
|
||||
*a = [*[1]]; assert_equal([[1]], a)
|
||||
*a = [*[1,2]]; assert_equal([[1,2]], a)
|
||||
*a = []; assert_equal([], a)
|
||||
*a = [1]; assert_equal([1], a)
|
||||
*a = [nil]; assert_equal([nil], a)
|
||||
*a = [[]]; assert_equal([[]], a)
|
||||
*a = [1,2]; assert_equal([1,2], a)
|
||||
*a = [*[]]; assert_equal([], a)
|
||||
*a = [*[1]]; assert_equal([1], a)
|
||||
*a = [*[1,2]]; assert_equal([1,2], a)
|
||||
|
||||
*a = *[]; assert_equal([], a)
|
||||
*a = *[1]; assert_equal([1], a)
|
||||
|
@ -82,13 +82,13 @@ class TestAssignment < Test::Unit::TestCase
|
|||
def test_yield
|
||||
def f; yield(nil); end; f {|a| assert_nil(a)}; undef f
|
||||
def f; yield(1); end; f {|a| assert_equal(1, a)}; undef f
|
||||
def f; yield([]); end; f {|a| assert_equal([], a)}; undef f
|
||||
def f; yield([1]); end; f {|a| assert_equal([1], a)}; undef f
|
||||
def f; yield([nil]); end; f {|a| assert_equal([nil], a)}; undef f
|
||||
def f; yield([[]]); end; f {|a| assert_equal([[]], a)}; undef f
|
||||
def f; yield([*[]]); end; f {|a| assert_equal([], a)}; undef f
|
||||
def f; yield([*[1]]); end; f {|a| assert_equal([1], a)}; undef f
|
||||
def f; yield([*[1,2]]); end; f {|a| assert_equal([1,2], a)}; undef f
|
||||
def f; yield([]); end; f {|a| assert_equal(nil, a)}; undef f
|
||||
def f; yield([1]); end; f {|a| assert_equal(1, a)}; undef f
|
||||
def f; yield([nil]); end; f {|a| assert_equal(nil, a)}; undef f
|
||||
def f; yield([[]]); end; f {|a| assert_equal([], a)}; undef f
|
||||
def f; yield([*[]]); end; f {|a| assert_equal(nil, a)}; undef f
|
||||
def f; yield([*[1]]); end; f {|a| assert_equal(1, a)}; undef f
|
||||
def f; yield([*[1,2]]); end; f {|a| assert_equal(1, a)}; undef f
|
||||
|
||||
def f; yield(*[1]); end; f {|a| assert_equal(1, a)}; undef f
|
||||
def f; yield(*[nil]); end; f {|a| assert_nil(a)}; undef f
|
||||
|
@ -98,14 +98,14 @@ class TestAssignment < Test::Unit::TestCase
|
|||
def f; yield; end; f {|*a| assert_equal([], a)}; undef f
|
||||
def f; yield(nil); end; f {|*a| assert_equal([nil], a)}; undef f
|
||||
def f; yield(1); end; f {|*a| assert_equal([1], a)}; undef f
|
||||
def f; yield([]); end; f {|*a| assert_equal([[]], a)}; undef f
|
||||
def f; yield([1]); end; f {|*a| assert_equal([[1]], a)}; undef f
|
||||
def f; yield([nil]); end; f {|*a| assert_equal([[nil]], a)}; undef f
|
||||
def f; yield([[]]); end; f {|*a| assert_equal([[[]]], a)}; undef f
|
||||
def f; yield([1,2]); end; f {|*a| assert_equal([[1,2]], a)}; undef f
|
||||
def f; yield([*[]]); end; f {|*a| assert_equal([[]], a)}; undef f
|
||||
def f; yield([*[1]]); end; f {|*a| assert_equal([[1]], a)}; undef f
|
||||
def f; yield([*[1,2]]); end; f {|*a| assert_equal([[1,2]], a)}; undef f
|
||||
def f; yield([]); end; f {|*a| assert_equal([], a)}; undef f
|
||||
def f; yield([1]); end; f {|*a| assert_equal([1], a)}; undef f
|
||||
def f; yield([nil]); end; f {|*a| assert_equal([nil], a)}; undef f
|
||||
def f; yield([[]]); end; f {|*a| assert_equal([[]], a)}; undef f
|
||||
def f; yield([1,2]); end; f {|*a| assert_equal([1,2], a)}; undef f
|
||||
def f; yield([*[]]); end; f {|*a| assert_equal([], a)}; undef f
|
||||
def f; yield([*[1]]); end; f {|*a| assert_equal([1], a)}; undef f
|
||||
def f; yield([*[1,2]]); end; f {|*a| assert_equal([1,2], a)}; undef f
|
||||
|
||||
def f; yield(*[]); end; f {|*a| assert_equal([], a)}; undef f
|
||||
def f; yield(*[1]); end; f {|*a| assert_equal([1], a)}; undef f
|
||||
|
@ -147,39 +147,39 @@ class TestAssignment < Test::Unit::TestCase
|
|||
def r; return [*[1]]; end; a = r(); assert_equal([1], a); undef r
|
||||
def r; return [*[1,2]]; end; a = r(); assert_equal([1,2], a); undef r
|
||||
|
||||
def r; return *[]; end; a = r(); assert_nil(a); undef r
|
||||
def r; return *[1]; end; a = r(); assert_equal(1, a); undef r
|
||||
def r; return *[nil]; end; a = r(); assert_nil(a); undef r
|
||||
def r; return *[[]]; end; a = r(); assert_equal([], a); undef r
|
||||
def r; return *[*[]]; end; a = r(); assert_nil(a); undef r
|
||||
def r; return *[*[1]]; end; a = r(); assert_equal(1, a); undef r
|
||||
def r; return *[]; end; a = r(); assert_equal([], a); undef r
|
||||
def r; return *[1]; end; a = r(); assert_equal([1], a); undef r
|
||||
def r; return *[nil]; end; a = r(); assert_equal([nil], a); undef r
|
||||
def r; return *[[]]; end; a = r(); assert_equal([[]], a); undef r
|
||||
def r; return *[*[]]; end; a = r(); assert_equal([], a); undef r
|
||||
def r; return *[*[1]]; end; a = r(); assert_equal([1], a); undef r
|
||||
def r; return *[*[1,2]]; end; a = r(); assert_equal([1,2], a); undef r
|
||||
|
||||
def r; return *[[]]; end; a = *r(); assert_nil(a); undef r
|
||||
def r; return *[[]]; end; a = *r(); assert_equal([[]], a); undef r
|
||||
def r; return *[*[1,2]]; end; a = *r(); assert_equal([1,2], a); undef r
|
||||
|
||||
def r; return; end; *a = r(); assert_equal([nil], a); undef r
|
||||
def r; return nil; end; *a = r(); assert_equal([nil], a); undef r
|
||||
def r; return 1; end; *a = r(); assert_equal([1], a); undef r
|
||||
def r; return []; end; *a = r(); assert_equal([[]], a); undef r
|
||||
def r; return [1]; end; *a = r(); assert_equal([[1]], a); undef r
|
||||
def r; return [nil]; end; *a = r(); assert_equal([[nil]], a); undef r
|
||||
def r; return [[]]; end; *a = r(); assert_equal([[[]]], a); undef r
|
||||
def r; return [1,2]; end; *a = r(); assert_equal([[1,2]], a); undef r
|
||||
def r; return [*[]]; end; *a = r(); assert_equal([[]], a); undef r
|
||||
def r; return [*[1]]; end; *a = r(); assert_equal([[1]], a); undef r
|
||||
def r; return [*[1,2]]; end; *a = r(); assert_equal([[1,2]], a); undef r
|
||||
def r; return []; end; *a = r(); assert_equal([], a); undef r
|
||||
def r; return [1]; end; *a = r(); assert_equal([1], a); undef r
|
||||
def r; return [nil]; end; *a = r(); assert_equal([nil], a); undef r
|
||||
def r; return [[]]; end; *a = r(); assert_equal([[]], a); undef r
|
||||
def r; return [1,2]; end; *a = r(); assert_equal([1,2], a); undef r
|
||||
def r; return [*[]]; end; *a = r(); assert_equal([], a); undef r
|
||||
def r; return [*[1]]; end; *a = r(); assert_equal([1], a); undef r
|
||||
def r; return [*[1,2]]; end; *a = r(); assert_equal([1,2], a); undef r
|
||||
|
||||
def r; return *[]; end; *a = r(); assert_equal([nil], a); undef r
|
||||
def r; return *[]; end; *a = r(); assert_equal([], a); undef r
|
||||
def r; return *[1]; end; *a = r(); assert_equal([1], a); undef r
|
||||
def r; return *[nil]; end; *a = r(); assert_equal([nil], a); undef r
|
||||
def r; return *[[]]; end; *a = r(); assert_equal([[]], a); undef r
|
||||
def r; return *[1,2]; end; *a = r(); assert_equal([[1,2]], a); undef r
|
||||
def r; return *[*[]]; end; *a = r(); assert_equal([nil], a); undef r
|
||||
def r; return *[1,2]; end; *a = r(); assert_equal([1,2], a); undef r
|
||||
def r; return *[*[]]; end; *a = r(); assert_equal([], a); undef r
|
||||
def r; return *[*[1]]; end; *a = r(); assert_equal([1], a); undef r
|
||||
def r; return *[*[1,2]]; end; *a = r(); assert_equal([[1,2]], a); undef r
|
||||
def r; return *[*[1,2]]; end; *a = r(); assert_equal([1,2], a); undef r
|
||||
|
||||
def r; return *[[]]; end; *a = *r(); assert_equal([], a); undef r
|
||||
def r; return *[[]]; end; *a = *r(); assert_equal([[]], a); undef r
|
||||
def r; return *[1,2]; end; *a = *r(); assert_equal([1,2], a); undef r
|
||||
def r; return *[*[1,2]]; end; *a = *r(); assert_equal([1,2], a); undef r
|
||||
|
||||
|
@ -198,7 +198,7 @@ class TestAssignment < Test::Unit::TestCase
|
|||
def r; return *[]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
|
||||
def r; return *[1]; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c]); undef r
|
||||
def r; return *[nil]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
|
||||
def r; return *[[]]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
|
||||
def r; return *[[]]; end; a,b,*c = r(); assert_equal([[],nil,[]], [a,b,c]); undef r
|
||||
def r; return *[1,2]; end; a,b,*c = r(); assert_equal([1,2,[]], [a,b,c]); undef r
|
||||
def r; return *[*[]]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
|
||||
def r; return *[*[1]]; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c]); undef r
|
||||
|
@ -260,36 +260,36 @@ class TestAssignment < Test::Unit::TestCase
|
|||
a = loop do break [*[1]]; end; assert_equal([1], a)
|
||||
a = loop do break [*[1,2]]; end; assert_equal([1,2], a)
|
||||
|
||||
a = loop do break *[]; end; assert_nil(a)
|
||||
a = loop do break *[1]; end; assert_equal(1, a)
|
||||
a = loop do break *[nil]; end; assert_nil(a)
|
||||
a = loop do break *[[]]; end; assert_equal([], a)
|
||||
a = loop do break *[*[]]; end; assert_nil(a)
|
||||
a = loop do break *[*[1]]; end; assert_equal(1, a)
|
||||
a = loop do break *[]; end; assert_equal([], a)
|
||||
a = loop do break *[1]; end; assert_equal([1], a)
|
||||
a = loop do break *[nil]; end; assert_equal([nil], a)
|
||||
a = loop do break *[[]]; end; assert_equal([[]], a)
|
||||
a = loop do break *[*[]]; end; assert_equal([], a)
|
||||
a = loop do break *[*[1]]; end; assert_equal([1], a)
|
||||
a = loop do break *[*[1,2]]; end; assert_equal([1,2], a)
|
||||
|
||||
*a = loop do break; end; assert_equal([nil], a)
|
||||
*a = loop do break nil; end; assert_equal([nil], a)
|
||||
*a = loop do break 1; end; assert_equal([1], a)
|
||||
*a = loop do break []; end; assert_equal([[]], a)
|
||||
*a = loop do break [1]; end; assert_equal([[1]], a)
|
||||
*a = loop do break [nil]; end; assert_equal([[nil]], a)
|
||||
*a = loop do break [[]]; end; assert_equal([[[]]], a)
|
||||
*a = loop do break [1,2]; end; assert_equal([[1,2]], a)
|
||||
*a = loop do break [*[]]; end; assert_equal([[]], a)
|
||||
*a = loop do break [*[1]]; end; assert_equal([[1]], a)
|
||||
*a = loop do break [*[1,2]]; end; assert_equal([[1,2]], a)
|
||||
*a = loop do break []; end; assert_equal([], a)
|
||||
*a = loop do break [1]; end; assert_equal([1], a)
|
||||
*a = loop do break [nil]; end; assert_equal([nil], a)
|
||||
*a = loop do break [[]]; end; assert_equal([[]], a)
|
||||
*a = loop do break [1,2]; end; assert_equal([1,2], a)
|
||||
*a = loop do break [*[]]; end; assert_equal([], a)
|
||||
*a = loop do break [*[1]]; end; assert_equal([1], a)
|
||||
*a = loop do break [*[1,2]]; end; assert_equal([1,2], a)
|
||||
|
||||
*a = loop do break *[]; end; assert_equal([nil], a)
|
||||
*a = loop do break *[]; end; assert_equal([], a)
|
||||
*a = loop do break *[1]; end; assert_equal([1], a)
|
||||
*a = loop do break *[nil]; end; assert_equal([nil], a)
|
||||
*a = loop do break *[[]]; end; assert_equal([[]], a)
|
||||
*a = loop do break *[1,2]; end; assert_equal([[1,2]], a)
|
||||
*a = loop do break *[*[]]; end; assert_equal([nil], a)
|
||||
*a = loop do break *[1,2]; end; assert_equal([1,2], a)
|
||||
*a = loop do break *[*[]]; end; assert_equal([], a)
|
||||
*a = loop do break *[*[1]]; end; assert_equal([1], a)
|
||||
*a = loop do break *[*[1,2]]; end; assert_equal([[1,2]], a)
|
||||
*a = loop do break *[*[1,2]]; end; assert_equal([1,2], a)
|
||||
|
||||
*a = *loop do break *[[]]; end; assert_equal([], a)
|
||||
*a = *loop do break *[[]]; end; assert_equal([[]], a)
|
||||
*a = *loop do break *[1,2]; end; assert_equal([1,2], a)
|
||||
*a = *loop do break *[*[1,2]]; end; assert_equal([1,2], a)
|
||||
|
||||
|
@ -308,7 +308,7 @@ class TestAssignment < Test::Unit::TestCase
|
|||
a,b,*c = loop do break *[]; end; assert_equal([nil,nil,[]], [a,b,c])
|
||||
a,b,*c = loop do break *[1]; end; assert_equal([1,nil,[]], [a,b,c])
|
||||
a,b,*c = loop do break *[nil]; end; assert_equal([nil,nil,[]], [a,b,c])
|
||||
a,b,*c = loop do break *[[]]; end; assert_equal([nil,nil,[]], [a,b,c])
|
||||
a,b,*c = loop do break *[[]]; end; assert_equal([[],nil,[]], [a,b,c])
|
||||
a,b,*c = loop do break *[1,2]; end; assert_equal([1,2,[]], [a,b,c])
|
||||
a,b,*c = loop do break *[*[]]; end; assert_equal([nil,nil,[]], [a,b,c])
|
||||
a,b,*c = loop do break *[*[1]]; end; assert_equal([1,nil,[]], [a,b,c])
|
||||
|
@ -328,12 +328,12 @@ class TestAssignment < Test::Unit::TestCase
|
|||
r([1]){next [*[1]]}
|
||||
r([1,2]){next [*[1,2]]}
|
||||
|
||||
r(nil){next *[]}
|
||||
r(1){next *[1]}
|
||||
r(nil){next *[nil]}
|
||||
r([]){next *[[]]}
|
||||
r(nil){next *[*[]]}
|
||||
r(1){next *[*[1]]}
|
||||
r([]){next *[]}
|
||||
r([1]){next *[1]}
|
||||
r([nil]){next *[nil]}
|
||||
r([[]]){next *[[]]}
|
||||
r([]){next *[*[]]}
|
||||
r([1]){next *[*[1]]}
|
||||
r([1,2]){next *[*[1,2]]}
|
||||
undef r
|
||||
|
||||
|
@ -341,18 +341,18 @@ class TestAssignment < Test::Unit::TestCase
|
|||
r([nil]){next}
|
||||
r([nil]){next nil}
|
||||
r([1]){next 1}
|
||||
r([[]]){next []}
|
||||
r([[1]]){next [1]}
|
||||
r([[nil]]){next [nil]}
|
||||
r([[[]]]){next [[]]}
|
||||
r([[1,2]]){next [1,2]}
|
||||
r([[]]){next [*[]]}
|
||||
r([[1]]){next [*[1]]}
|
||||
r([[1,2]]){next [*[1,2]]}
|
||||
r([]){next []}
|
||||
r([1]){next [1]}
|
||||
r([nil]){next [nil]}
|
||||
r([[]]){next [[]]}
|
||||
r([1,2]){next [1,2]}
|
||||
r([]){next [*[]]}
|
||||
r([1]){next [*[1]]}
|
||||
r([1,2]){next [*[1,2]]}
|
||||
undef r
|
||||
|
||||
def r(val); *a = *yield(); assert_equal(val, a); end
|
||||
r([]){next *[[]]}
|
||||
r([[]]){next *[[]]}
|
||||
r([1,2]){next *[1,2]}
|
||||
r([1,2]){next *[*[1,2]]}
|
||||
undef r
|
||||
|
@ -372,7 +372,7 @@ class TestAssignment < Test::Unit::TestCase
|
|||
undef r
|
||||
|
||||
def r(val); a,b,*c = *yield(); assert_equal(val, [a,b,c]); end
|
||||
r([nil,nil,[]]){next *[[]]}
|
||||
r([[],nil,[]]){next *[[]]}
|
||||
r([1,2,[]]){next *[1,2]}
|
||||
r([1,2,[]]){next *[*[1,2]]}
|
||||
undef r
|
||||
|
|
|
@ -23,6 +23,6 @@ class TestClone < Test::Unit::TestCase
|
|||
|
||||
assert_raises(NoMethodError) {foo.test2}
|
||||
|
||||
assert_equal([M003, M002, M001], M003.ancestors)
|
||||
assert_equal([M003, M002, M001, M002], M003.ancestors)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,9 +31,9 @@ class TestDir < Test::Unit::TestCase
|
|||
break unless name = dir.read
|
||||
cache << [pos, name]
|
||||
end
|
||||
for x in cache.sort_by {|x| x[0] % 3 } # shuffle
|
||||
dir.seek(x[0])
|
||||
assert_equal(x[1], dir.read)
|
||||
for x,y in cache.sort_by {|x| x[0] % 3 } # shuffle
|
||||
dir.seek(x)
|
||||
assert_equal(y, dir.read)
|
||||
end
|
||||
ensure
|
||||
dir.close
|
||||
|
|
|
@ -88,7 +88,7 @@ class TestFile < Test::Unit::TestCase
|
|||
assert_nil(f.getc)
|
||||
open(f.path, "w") {|g| g.print "a" }
|
||||
result = []
|
||||
f.each_byte {|b| result << b }
|
||||
f.each_byte {|b| result << b.chr }
|
||||
assert_equal([?a], result)
|
||||
end
|
||||
|
||||
|
|
|
@ -87,4 +87,32 @@ class TestFloat < Test::Unit::TestCase
|
|||
assert_raise(ArgumentError){Float("1e")}
|
||||
# add expected behaviour here.
|
||||
end
|
||||
|
||||
def test_divmod
|
||||
assert_equal([2, 3.5], 11.5.divmod(4))
|
||||
assert_equal([-3, -0.5], 11.5.divmod(-4))
|
||||
assert_equal([-3, 0.5], (-11.5).divmod(4))
|
||||
assert_equal([2, -3.5], (-11.5).divmod(-4))
|
||||
end
|
||||
|
||||
def test_div
|
||||
assert_equal(2, 11.5.div(4))
|
||||
assert_equal(-3, 11.5.div(-4))
|
||||
assert_equal(-3, (-11.5).div(4))
|
||||
assert_equal(2, (-11.5).div(-4))
|
||||
end
|
||||
|
||||
def test_modulo
|
||||
assert_equal(3.5, 11.5.modulo(4))
|
||||
assert_equal(-0.5, 11.5.modulo(-4))
|
||||
assert_equal(0.5, (-11.5).modulo(4))
|
||||
assert_equal(-3.5, (-11.5).modulo(-4))
|
||||
end
|
||||
|
||||
def test_remainder
|
||||
assert_equal(3.5, 11.5.remainder(4))
|
||||
assert_equal(3.5, 11.5.remainder(-4))
|
||||
assert_equal(-3.5, (-11.5).remainder(4))
|
||||
assert_equal(-3.5, (-11.5).remainder(-4))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -151,21 +151,21 @@ class TestIterator < Test::Unit::TestCase
|
|||
IterTest.new([2]).each2 {|x| assert_equal([2], x)}
|
||||
IterTest.new([4]).each4 {|x| assert_equal(4, x)}
|
||||
IterTest.new([5]).each5 {|x| assert_equal(5, x)}
|
||||
IterTest.new([6]).each6 {|x| assert_equal([6], x)}
|
||||
IterTest.new([6]).each6 {|x| assert_equal(6, x)}
|
||||
IterTest.new([8]).each8 {|x| assert_equal(8, x)}
|
||||
|
||||
IterTest.new([[0]]).each0 {|x| assert_equal([0], x)}
|
||||
IterTest.new([[1]]).each1 {|x| assert_equal([1], x)}
|
||||
IterTest.new([[2]]).each2 {|x| assert_equal([[2]], x)}
|
||||
IterTest.new([[0]]).each0 {|x| assert_equal(0, x)}
|
||||
IterTest.new([[1]]).each1 {|x| assert_equal(1, x)}
|
||||
IterTest.new([[2]]).each2 {|x| assert_equal([2], x)}
|
||||
IterTest.new([[3]]).each3 {|x| assert_equal(3, x)}
|
||||
IterTest.new([[4]]).each4 {|x| assert_equal([4], x)}
|
||||
IterTest.new([[5]]).each5 {|x| assert_equal([5], x)}
|
||||
IterTest.new([[6]]).each6 {|x| assert_equal([[6]], x)}
|
||||
IterTest.new([[4]]).each4 {|x| assert_equal(4, x)}
|
||||
IterTest.new([[5]]).each5 {|x| assert_equal(5, x)}
|
||||
IterTest.new([[6]]).each6 {|x| assert_equal(6, x)}
|
||||
IterTest.new([[7]]).each7 {|x| assert_equal(7, x)}
|
||||
IterTest.new([[8]]).each8 {|x| assert_equal([8], x)}
|
||||
IterTest.new([[8]]).each8 {|x| assert_equal(8, x)}
|
||||
|
||||
IterTest.new([[0,0]]).each0 {|x| assert_equal([0,0], x)}
|
||||
IterTest.new([[8,8]]).each8 {|x| assert_equal([8,8], x)}
|
||||
IterTest.new([[0,0]]).each0 {|*x| assert_equal([0,0], x)}
|
||||
IterTest.new([[8,8]]).each8 {|*x| assert_equal([8], x)}
|
||||
end
|
||||
|
||||
def m(var)
|
||||
|
@ -346,10 +346,10 @@ class TestIterator < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def foo
|
||||
yield([:key, :value])
|
||||
yield(:key, :value)
|
||||
end
|
||||
def bar(&blk)
|
||||
blk.call([:key, :value])
|
||||
blk.call(:key, :value)
|
||||
end
|
||||
|
||||
def test_yield_vs_call
|
||||
|
@ -359,14 +359,14 @@ class TestIterator < Test::Unit::TestCase
|
|||
|
||||
class H
|
||||
def each
|
||||
yield [:key, :value]
|
||||
yield :key, :value
|
||||
end
|
||||
end
|
||||
|
||||
def test_assoc_yield
|
||||
[{:key=>:value}, H.new].each {|h|
|
||||
h.each{|a| assert_equal([:key, :value], a)}
|
||||
h.each{|*a| assert_equal([[:key, :value]], a)}
|
||||
h.each{|a| assert_equal(:key, a)}
|
||||
h.each{|*a| assert_equal([:key, :value], a)}
|
||||
h.each{|k,v| assert_equal([:key, :value], [k,v])}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -68,9 +68,9 @@ END
|
|||
# character constants(assumes ASCII)
|
||||
assert_equal(?a, "a"[0])
|
||||
assert_equal(?a, ?a)
|
||||
assert_equal(1, ?\C-a)
|
||||
assert_equal(225, ?\M-a)
|
||||
assert_equal(129, ?\M-\C-a)
|
||||
assert_equal("\1", ?\C-a)
|
||||
assert_equal("\341", ?\M-a)
|
||||
assert_equal("\201", ?\M-\C-a)
|
||||
assert_equal(?A, "a".upcase![0])
|
||||
assert_equal(?a, "A".downcase![0])
|
||||
assert_equal("ABC", "abc".tr!("a-z", "A-Z"))
|
||||
|
@ -82,7 +82,7 @@ END
|
|||
$y = [ ?a, ?b, ?c, ?d, ?e, ?f ]
|
||||
$bad = false
|
||||
$x.each_byte {|i|
|
||||
if i != $y.shift
|
||||
if i.chr != $y.shift
|
||||
$bad = true
|
||||
break
|
||||
end
|
||||
|
|
6
time.c
6
time.c
|
@ -157,7 +157,7 @@ static struct timeval
|
|||
time_timeval(VALUE time, int interval)
|
||||
{
|
||||
struct timeval t;
|
||||
char *tstr = interval ? "time interval" : "time";
|
||||
const char *tstr = interval ? "time interval" : "time";
|
||||
|
||||
#ifndef NEGATIVE_TIME_T
|
||||
interval = 1;
|
||||
|
@ -182,7 +182,7 @@ time_timeval(VALUE time, int interval)
|
|||
if (f != t.tv_sec) {
|
||||
rb_raise(rb_eRangeError, "%f out of Time range", RFLOAT(time)->value);
|
||||
}
|
||||
t.tv_usec = (time_t)(d*1e6);
|
||||
t.tv_usec = (time_t)(d*1e6+0.5);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1229,7 +1229,7 @@ time_add(struct time_object *tobj, VALUE offset, int sign)
|
|||
if (f != (double)sec_off)
|
||||
rb_raise(rb_eRangeError, "time %s %f out of Time range",
|
||||
sign < 0 ? "-" : "+", v);
|
||||
usec_off = (time_t)(d*1e6);
|
||||
usec_off = (time_t)(d*1e6+0.5);
|
||||
|
||||
if (sign < 0) {
|
||||
sec = tobj->tv.tv_sec - sec_off;
|
||||
|
|
90
util.c
90
util.c
|
@ -15,6 +15,8 @@
|
|||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "missing/file.h"
|
||||
|
@ -664,11 +666,9 @@ ruby_getcwd(void)
|
|||
*
|
||||
*/
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define MDMINEXPT DBL_MIN_EXP
|
||||
#define MDMAXEXPT DBL_MAX_EXP
|
||||
|
||||
static int MDMINEXPT = -323;
|
||||
static int MDMAXEXPT = 309;
|
||||
static double powersOf10[] = { /* Table giving binary powers of 10. Entry */
|
||||
10.0, /* is 10^2^i. Used to convert decimal */
|
||||
100.0, /* exponents into floating-point numbers. */
|
||||
|
@ -720,8 +720,8 @@ ruby_strtod(
|
|||
char **endPtr) /* If non-NULL, store terminating character's
|
||||
* address here. */
|
||||
{
|
||||
int sign, expSign = FALSE;
|
||||
double fraction, dblExp, *d;
|
||||
int sign, expSign = Qfalse;
|
||||
double fraction = 0.0, dblExp, *d;
|
||||
register const char *p;
|
||||
register int c;
|
||||
int exp = 0; /* Exponent read from "EX" field. */
|
||||
|
@ -735,8 +735,8 @@ ruby_strtod(
|
|||
* case, fracExp is incremented one for each
|
||||
* dropped digit. */
|
||||
int mantSize = 0; /* Number of digits in mantissa. */
|
||||
int hasPoint = FALSE; /* Decimal point exists. */
|
||||
int hasDigit = FALSE; /* I or F exists. */
|
||||
int hasPoint = Qfalse; /* Decimal point exists. */
|
||||
int hasDigit = Qfalse; /* I or F exists. */
|
||||
const char *pMant; /* Temporarily holds location of mantissa
|
||||
* in string. */
|
||||
const char *pExp; /* Temporarily holds location of exponent
|
||||
|
@ -748,44 +748,43 @@ ruby_strtod(
|
|||
|
||||
errno = 0;
|
||||
p = string;
|
||||
while (ISSPACE(*p)) {
|
||||
p += 1;
|
||||
}
|
||||
while (ISSPACE(*p)) p++;
|
||||
if (*p == '-') {
|
||||
sign = TRUE;
|
||||
p += 1;
|
||||
sign = Qtrue;
|
||||
p++;
|
||||
}
|
||||
else {
|
||||
if (*p == '+') {
|
||||
p += 1;
|
||||
}
|
||||
sign = FALSE;
|
||||
if (*p == '+') p++;
|
||||
sign = Qfalse;
|
||||
}
|
||||
|
||||
fraction = 0.;
|
||||
exp = 0;
|
||||
|
||||
/*
|
||||
* Count the number of digits in the mantissa
|
||||
* and also locate the decimal point.
|
||||
*/
|
||||
|
||||
for ( ; c = *p; p += 1) {
|
||||
for ( ; c = *p; p++) {
|
||||
if (!ISDIGIT(c)) {
|
||||
if (c != '.' || hasPoint) {
|
||||
break;
|
||||
}
|
||||
hasPoint = TRUE;
|
||||
hasPoint = Qtrue;
|
||||
}
|
||||
else {
|
||||
if (hasPoint) { /* already in fractional part */
|
||||
fracExp -= 1;
|
||||
fracExp--;
|
||||
}
|
||||
if (mantSize) { /* already in mantissa */
|
||||
mantSize += 1;
|
||||
mantSize++;
|
||||
}
|
||||
else if (c != '0') { /* have entered mantissa */
|
||||
mantSize += 1;
|
||||
mantSize++;
|
||||
pMant = p;
|
||||
}
|
||||
hasDigit = TRUE;
|
||||
hasDigit = Qtrue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -796,7 +795,7 @@ ruby_strtod(
|
|||
* they can't affect the value anyway.
|
||||
*/
|
||||
|
||||
pExp = p;
|
||||
pExp = p;
|
||||
if (mantSize) {
|
||||
p = pMant;
|
||||
}
|
||||
|
@ -809,7 +808,7 @@ ruby_strtod(
|
|||
p = string;
|
||||
}
|
||||
else {
|
||||
int frac1, frac2;
|
||||
double frac1, frac2;
|
||||
frac1 = 0;
|
||||
for ( ; mantSize > 9; mantSize -= 1) {
|
||||
c = *p;
|
||||
|
@ -837,21 +836,20 @@ ruby_strtod(
|
|||
|
||||
p = pExp;
|
||||
if ((*p == 'E') || (*p == 'e')) {
|
||||
p += 1;
|
||||
p++;
|
||||
if (*p == '-') {
|
||||
expSign = TRUE;
|
||||
p += 1;
|
||||
expSign = Qtrue;
|
||||
p++;
|
||||
}
|
||||
else {
|
||||
if (*p == '+') {
|
||||
p += 1;
|
||||
p++;
|
||||
}
|
||||
expSign = FALSE;
|
||||
expSign = Qfalse;
|
||||
}
|
||||
if (ISDIGIT(*p)) {
|
||||
do {
|
||||
exp = exp * 10 + (*p - '0');
|
||||
p += 1;
|
||||
exp = exp * 10 + (*p++ - '0');
|
||||
}
|
||||
while (ISDIGIT(*p));
|
||||
}
|
||||
|
@ -873,22 +871,22 @@ ruby_strtod(
|
|||
* fraction.
|
||||
*/
|
||||
|
||||
if (exp >= MDMAXEXPT - 18) {
|
||||
exp = MDMAXEXPT;
|
||||
if (exp >= MDMAXEXPT) {
|
||||
errno = ERANGE;
|
||||
return HUGE_VAL * (sign ? -1.0 : 1.0);
|
||||
}
|
||||
else if (exp < MDMINEXPT + 18) {
|
||||
exp = MDMINEXPT;
|
||||
else if (exp < MDMINEXPT) {
|
||||
errno = ERANGE;
|
||||
return 0.0 * (sign ? -1.0 : 1.0);
|
||||
}
|
||||
fracExp = exp;
|
||||
exp += 9;
|
||||
if (exp < 0) {
|
||||
expSign = TRUE;
|
||||
expSign = Qtrue;
|
||||
exp = -exp;
|
||||
}
|
||||
else {
|
||||
expSign = FALSE;
|
||||
expSign = Qfalse;
|
||||
}
|
||||
dblExp = 1.0;
|
||||
for (d = powersOf10; exp != 0; exp >>= 1, d += 1) {
|
||||
|
@ -897,18 +895,18 @@ ruby_strtod(
|
|||
}
|
||||
}
|
||||
if (expSign) {
|
||||
fraction = frac1 / dblExp;
|
||||
frac1 /= dblExp;
|
||||
}
|
||||
else {
|
||||
fraction = frac1 * dblExp;
|
||||
frac1 *= dblExp;
|
||||
}
|
||||
exp = fracExp;
|
||||
if (exp < 0) {
|
||||
expSign = TRUE;
|
||||
expSign = Qtrue;
|
||||
exp = -exp;
|
||||
}
|
||||
else {
|
||||
expSign = FALSE;
|
||||
expSign = Qfalse;
|
||||
}
|
||||
dblExp = 1.0;
|
||||
for (d = powersOf10; exp != 0; exp >>= 1, d += 1) {
|
||||
|
@ -917,17 +915,17 @@ ruby_strtod(
|
|||
}
|
||||
}
|
||||
if (expSign) {
|
||||
fraction += frac2 / dblExp;
|
||||
frac2 /= dblExp;
|
||||
}
|
||||
else {
|
||||
fraction += frac2 * dblExp;
|
||||
frac2 *= dblExp;
|
||||
}
|
||||
fraction = frac1 + frac2;
|
||||
}
|
||||
|
||||
if (endPtr != NULL) {
|
||||
*endPtr = (char *) p;
|
||||
*endPtr = (char *)p;
|
||||
}
|
||||
|
||||
if (sign) {
|
||||
return -fraction;
|
||||
}
|
||||
|
|
12
variable.c
12
variable.c
|
@ -186,7 +186,7 @@ rb_class_path(VALUE klass)
|
|||
return path;
|
||||
}
|
||||
else {
|
||||
char *s = "Class";
|
||||
const char *s = "Class";
|
||||
|
||||
if (TYPE(klass) == T_MODULE) {
|
||||
if (rb_obj_class(klass) == rb_cModule) {
|
||||
|
@ -711,7 +711,7 @@ rb_f_global_variables(void)
|
|||
{
|
||||
VALUE ary = rb_ary_new();
|
||||
char buf[4];
|
||||
char *s = "&`'+123456789";
|
||||
const char *s = "&`'+123456789";
|
||||
|
||||
st_foreach_safe(rb_global_tbl, gvar_i, ary);
|
||||
if (!NIL_P(rb_backref_get())) {
|
||||
|
@ -1282,7 +1282,7 @@ rb_const_get_0(VALUE klass, ID id, int exclude, int recurse, NODE *fallback)
|
|||
|
||||
tmp = klass;
|
||||
retry:
|
||||
while (tmp) {
|
||||
while (tmp && !NIL_P(tmp)) {
|
||||
while (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) {
|
||||
if (value == Qundef) {
|
||||
if (!RTEST(rb_autoload_load(tmp, id))) break;
|
||||
|
@ -1510,7 +1510,7 @@ rb_const_defined_fallback(VALUE klass, ID id, NODE *fallback)
|
|||
static void
|
||||
mod_av_set(VALUE klass, ID id, VALUE val, int isconst)
|
||||
{
|
||||
char *dest = isconst ? "constant" : "class variable";
|
||||
const char *dest = isconst ? "constant" : "class variable";
|
||||
|
||||
if (!OBJ_TAINTED(klass) && rb_safe_level() >= 4)
|
||||
rb_raise(rb_eSecurityError, "Insecure: can't set %s", dest);
|
||||
|
@ -1542,6 +1542,10 @@ mod_av_set(VALUE klass, ID id, VALUE val, int isconst)
|
|||
void
|
||||
rb_const_set(VALUE klass, ID id, VALUE val)
|
||||
{
|
||||
if (NIL_P(klass)) {
|
||||
rb_raise(rb_eTypeError, "no class/module to define constant %s",
|
||||
rb_id2name(id));
|
||||
}
|
||||
mod_av_set(klass, id, val, Qtrue);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче