Граф коммитов

238 Коммитов

Автор SHA1 Сообщение Дата
mame a48f90b05b * hash.c (rb_hash): always return a fixnum value because a return
value of rb_hash may be used as a hash value itself and bignums have
  no unique VALUE.

* test/ruby/test_hash.rb: add a test for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-14 18:53:40 +00:00
matz ad049bc5df * hash.c (rb_any_hash): fixed performance issues with nil, true,
false as hash keys.  a patch from Matthias Waechter.  
  [ruby-core:21568]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-26 18:48:47 +00:00
nobu 5a38751d02 * hash.c (rb_hash_s_create): set nil as the value if assoc length
is not enough.  [ruby-core:21249]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-11 00:47:32 +00:00
matz 63219d8a24 * io.c (rb_io_extract_encoding_option): "internal_encoding: nil"
to specify no-transcoding.  and other corner case fixed.
  [ruby-dev:37496]

* hash.c (rb_hash_lookup2): new function to look-up hash with
  default value.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-19 08:22:45 +00:00
matz 88cab63a07 * hash.c (rb_hash_aset): string key copying only happen if key is
an exact instance of String, not a subclass. based on a patch
  from Mike Gold <mike.gold.4433 at gmail.com> in [ruby-talk:322667].
  [incompatible] [ruby-talk:322417]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-18 08:05:17 +00:00
matz 16549e33da * ext/stringio/stringio.c (strio_write): should convert writing
string to the encoding of the buffer.

* hash.c (rb_any_hash): typo fixed.

* ext/zlib/zlib.c (rb_gzwriter_write): oops, IO string conversion
  need to be done by to_s.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-21 14:14:13 +00:00
matz c5377c2bcc * io.c (open_key_args): should adjust argc, argv in struct
foreach_arg.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-21 13:57:16 +00:00
yugui 642e081879 * dln.c: Ruby no longer supports MacOS 9 or before.
* eval.c: ditto.

* eval_intern.h: ditto.

* ext/extmk.rb: ditto.

* ext/tk/sample/tkextlib/treectrl/demo.rb: ditto.

* ext/tk/stubs.c: ditto.

* file.c: ditto.

* hash.c: ditto.

* include/ruby/defines.h: ditto.

* ruby.c: ditto.

* signal.c: ditto.

* vm_core.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-04 13:42:00 +00:00
yugui ae7ea3332b * dln.c: Ruby no longer supports MS-DOS.
* ext/sdbm/_sdbm.c: ditto.

* ext/sdbm/sdbm.h: ditto.

* gc.c: ditto.

* hash.c: ditto.

* include/ruby/defines.h: ditto.

* include/ruby/util.h: ditto.

* io.c: ditto.

* process.c: ditto.

* ruby.c: ditto.

* strftime.c: ditto.

* util.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-04 13:33:22 +00:00
matz 8bfa0ac869 * sprintf.c (rb_str_format): add %<name>s style named argument
support.  a patch from Yusuke Endoh <mame at tsg.ne.jp>
  in [ruby-dev:35851].

* sprintf.c (rb_str_format): add gettext style named format
  (%{name}) support.  inspired by [ruby-dev:35852].

* sprintf.c (GETNAMEARG): should raise KeyError exception when no
  named argument found.

* hash.c (rb_hash_fetch): export fetch function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-30 08:01:11 +00:00
akr 455fbd2373 * hash.c (rb_obj_is_proc): declaration moved for rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 09:25:27 +00:00
nobu ab279b4085 * hash.c (ENVMATCH, ENVNMATCH): reduced same code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 07:59:48 +00:00
ko1 23c291da09 * common.mk, hash.c: remove unused inclusion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 06:34:33 +00:00
matz 3256a4dc21 * hash.c (env_aset): allow nil value to remove an entry.
[ruby-dev:36465]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-22 23:27:33 +00:00
tadf 05ac51d225 * complex.c (nucomp_eql_p): new.
* complex.c (nucomp_hash): should use hash values of the elements.

	* rational.c (nurat_hash): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-15 04:20:46 +00:00
ko1 204929af9d * include/ruby/signal.h: removed.
* common.mk, class.c, eval.c, eval_intern.h, file.c, gc.c, hash.c,
  io.c, process.c, signal.c: vm_core.h: ditto.
  Some unused external global variables are also removed.
  (rb_prohibit_interrupt, rb_trap_immediate, rb_trap_pending,
  rb_thread_critical)
* ext/openssl/ossl_ssl.c, ext/openssl/ossl_x509store.c,
  ext/readline/readline.c, ext/socket/depend,
  ext/socket/socket.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 08:00:05 +00:00
nobu 5f9c188d97 * include/ruby/ruby.h (rb_intern_const): tiny optimization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-16 00:20:31 +00:00
matz 0cafe9e4cd * hash.c (set_default): fix rdoc. #441
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 08:19:56 +00:00
matz 8d4086d773 * hash.c (rb_hash_set_default_proc): add new method. a patch from
Giuseppe Bilotta.  #419

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 08:44:17 +00:00
shugo f433d710d0 * object.c (rb_obj_untrusted): new method Object#untrusted?.
(rb_obj_untrust): new method Object#untrust.
  (rb_obj_trust): new method Object#trust.
* array.c, debug.c, time.c, include/ruby/ruby.h, re.c, variable.c,
  string.c, io.c, dir.c, vm_method.c, struct.c, class.c, hash.c,
  ruby.c, marshal.c: fixes for Object#untrusted?.
* test/ruby/test_module.rb, test/ruby/test_array.rb,
  test/ruby/test_object.rb, test/ruby/test_string.rb,
  test/ruby/test_marshal.rb, test/ruby/test_hash.rb: added tests for
  Object#untrusted?.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 07:25:05 +00:00
nobu 5a647a3f5f * include/ruby/ruby.h (CONST_ID): constant ID cache for non-gcc.
* *.c: no cache in init functions.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-09 09:25:32 +00:00
ko1 72ba13aa8e * array.c, bignum.c, cont.c, dir.c, dln.c, encoding.c, enumerator.c,
enumerator.c (enumerator_allocate), eval_jump.c, file.c, hash.c,
  io.c, load.c, pack.c, proc.c, random.c, re.c, ruby.c, st.c,
  string.c, thread.c, thread_pthread.c, time.c, util.c, variable.c,
  vm.c, gc.c:
  allocated memory objects by xmalloc (ruby_xmalloc) should be
  freed by xfree (ruby_xfree).
* ext/curses/curses.c, ext/dbm/dbm.c, ext/digest/digest.c,
  ext/gdbm/gdbm.c, ext/json/ext/parser/parser.c,
  ext/json/ext/parser/unicode.c, ext/openssl/ossl_cipher.c,
  ext/openssl/ossl_hmac.c, ext/openssl/ossl_pkey_ec.c,
  ext/sdbm/init.c, ext/strscan/strscan.c, ext/zlib/zlib.c:
  ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-08 10:01:40 +00:00
akr cd6414267f * hash.c (hash_i): make Hash#hash order insensitive.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-07 16:19:47 +00:00
knu 80b0ef5706 * hash.c (env_each_key, env_each_value, env_reject_bang)
(rb_env_clear, env_replace): Omit duplicated secure level check.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-25 16:06:00 +00:00
knu 49cd417578 * hash.c (env_each_value): Do not call env_values() twice.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-25 15:42:14 +00:00
matz 69c213fbc7 * hash.c (rb_hash_s_create): should access converted hash value.
[ruby-dev:34555]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-01 14:04:38 +00:00
nobu 30aa6b99ca * hash.c (env_delete_if): return enumerator if no block given.
[ruby-dev:34554]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-01 07:10:23 +00:00
akr 514715250a * include/ruby/intern.h (rb_hash_dup): declared.
* hash.c (rb_hash_dup): new function.

* process.c (rb_spawn_internal): don't modify option hash.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-26 12:52:25 +00:00
akr 278b63a3e4 * include/ruby/intern.h (rb_env_clear): declared.
(rb_io_mode_modenum): declared.
  (rb_close_before_exec): declared.
  (struct rb_exec_arg): add options and redirect_fds field.
  (rb_check_argv): removed.
  (rb_exec_initarg): declared.
  (rb_exec_getargs): declared.
  (rb_exec_initarg2): declared.
  (rb_fork): add third argument: fds.

* io.c (max_file_descriptor): new static variable to record maximum
  file descriptor ruby used.
  (UPDATE_MAXFD): new macro.
  (UPDATE_MAXFD_PIPE): new macro.
  (rb_io_mode_modenum): externed.
  (rb_sysopen): update max_file_descriptor.
  (rb_close_before_exec): new function.
  (popen_exec): redirection removed because it is done by extended
  spawn mechanism.
  (pipe_open): generate a hash for spawn options to specify
  redirections.
  (pipe_open_v): use rb_exec_getargs.
  (pipe_open_s): use rb_exec_getargs.
  (rb_io_initialize): update max_file_descriptor..

* process.c (hide_obj): new function.
  (check_exec_redirect_fd): new function.
  (check_exec_redirect): new function.
  (check_exec_options_i): new function.
  (check_exec_fds): new function.
  (rb_check_exec_options): new function.
  (check_exec_env_i): new function.
  (rb_check_exec_env): new function.
  (rb_exec_getargs): new function.
  (rb_exec_initarg2): new function.
  (rb_exec_initarg): new function.
  (rb_f_exec): use rb_exec_initarg.
  (intcmp): new function.
  (run_exec_dup2): new function.
  (run_exec_close): new function.
  (run_exec_open): new function.
  (run_exec_pgroup): new function.
  (run_exec_rlimit): new function.
  (run_exec_options): new function.
  (rb_exec): call run_exec_options.
  (move_fds_to_avoid_crash): new function.
  (pipe_nocrash): new function.
  (rb_fork): use pipe_nocrash to avoid file descriptor conflicts.
  (rb_spawn): use rb_exec_initarg.
  (rlimit_resource_name2int): extracted from rlimit_resource_type.
  (rlimit_type_by_hname): new function.
  (rlimit_type_by_lname): new function.
  (rlimit_resource_type): use rlimit_type_by_hname.
  (proc_daemon): add fds argument for rb_fork.

* hash.c (rb_env_clear): renamed from env_clear and externed.

[ruby-dev:34086]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-24 14:46:39 +00:00
knu ac5b69acb8 * hash.c (rb_hash_delete_if, rb_hash_reject_bang, env_delete_if,
env_reject_bang): Return an enumerator if no block is given.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 08:31:38 +00:00
akr 861219ce4a fix doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-09 01:04:46 +00:00
matz a110ef359a * hash.c (hash_equal): two hash tables are different when internal
comparison table differ.  [ruby-dev:33989]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-04 10:19:55 +00:00
matz f8c5b8ec90 * hash.c (rb_hash_aset): should not copy key string when
compare_by_identity is set.  [ruby-dev:33604]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-04 10:14:40 +00:00
nobu 9b2dd1e20d * hash.c (rb_any_hash): shrinks all results in Fixnum range.
[ruby-core:15713]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-03 07:14:27 +00:00
naruse 50a860d006 * string.c (str_new): remove encoding assumption of empty string.
* hash.c ( rb_f_getenv, env_fetch, env_inspect): result of ENV should
  be always ASCII-8BIT.

* object.c (nil_to_s): nil.to_s should be US-ASCII.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-28 18:13:45 +00:00
matz 38694016bc * string.c (rb_str_hash_cmp): lighter version of rb_str_cmp() for
hash comparison function.

* hash.c (rb_any_cmp): use rb_str_hash_cmp().

* string.c (rb_str_casecmp): should return nil for incompatible
  comparison.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-12 03:17:43 +00:00
matz 8c1887e3a4 typo fixed
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-05 16:53:23 +00:00
matz acc1a53744 * hash.c (rb_hash_flatten): do not flatten recursively by default.
[ruby-dev:33603]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-05 16:51:30 +00:00
mame a73ec67e8d * hash.c (env_rassoc): remove access to free'd environment on mswin32.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-05 15:25:35 +00:00
naruse 42dcda08ae * string.c (rb_str_usascii_new{,2}: defined.
(rb_str_new): set US-ASCII and ENC_CODERANGE_7BIT when empty
  string.

* encoding.c (rb_usascii_encoding, rb_usascii_encindex): defined.
  (rb_enc_inspect, enc_name, rb_locale_charmap, rb_enc_name_list_i):
  use rb_str_ascii_new.

* array.c (recursive_join, inspect_ary): ditto.

* object.c (nil_to_s, nil_inspect, true_to_s, false_to_s,
  rb_mod_to_s): ditto.

* hash.c (inspect_hash, rb_hash_inspect, rb_f_getenv, env_fetch,
  env_clear, env_to_s, env_inspect): ditto.

* numeric.c (flo_to_s, int_chr, rb_fix2str): ditto.

* bignum.c (rb_big2str): ditto.

* file.c (rb_file_ftype, rb_file_s_dirname, rb_file_s_extname,
  file_inspect_join, Init_file): ditto.

* test/ruby/test_ruby_m17n.rb: add checks for encoding of string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-25 16:40:02 +00:00
akr 6cdef2dc7e * $Date$ keyword removed to avoid inclusion of locale dependent
string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-06 15:49:38 +00:00
akr 041e829127 * include/ruby/encoding.h (rb_isascii): defined.
(rb_isalnum): ditto.
  (rb_isalpha): ditto.
  (rb_isblank): ditto.
  (rb_iscntrl): ditto.
  (rb_isdigit): ditto.
  (rb_isgraph): ditto.
  (rb_islower): ditto.
  (rb_isprint): ditto.
  (rb_ispunct): ditto.
  (rb_isspace): ditto.
  (rb_isupper): ditto.
  (rb_isxdigit): ditto.
  (rb_tolower): ditto.
  (rb_toupper): ditto.

* include/ruby/st.h (st_strcasecmp): declared.
  (st_strncasecmp): ditto.

* st.c (type_strcasehash): use st_strcasecmp instead of strcasecmp.
  (st_strcasecmp): defined.
  (st_strncasecmp): ditto.

* include/ruby/ruby.h: include include/ruby/encoding.h.
  (ISASCII): use rb_isascii.
  (ISPRINT): use rb_isprint.
  (ISSPACE): use rb_isspace.
  (ISUPPER): use rb_isupper.
  (ISLOWER): use rb_islower.
  (ISALNUM): use rb_isalnum.
  (ISALPHA): use rb_isalpha.
  (ISDIGIT): use rb_isdigit.
  (ISXDIGIT): use rb_isxdigit.
  (TOUPPER): defined.
  (TOLOWER): ditto.
  (STRCASECMP): ditto.
  (STRNCASECMP): ditto.

* dir.c, encoding.c, file.c, hash.c, process.c, ruby.c, time.c,
  transcode.c, ext/readline/readline.c: use locale insensitive
  functions.  [ruby-core:14662]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-01 12:24:04 +00:00
akr 5088b14db7 fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-31 06:43:32 +00:00
matz efedaa432b * hash.c (rb_hash_eql): recursive comparison should be based on
eql?  [ruby-core:13803]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-30 05:26:59 +00:00
matz 6e8eea7abe * hash.c (rb_hash_each_pair): make Hash#each to be alias to
Hash#each_pair for compatibility and clarity.

* hash.c (env_each_pair): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-03 14:07:48 +00:00
matz 012b58b121 * hash.c (rb_hash_s_create): check and convert argument hash
using #to_hash.

* hash.c (rb_hash_s_create): Hash#[] now takes assocs as source of
  hash conversion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-25 17:05:09 +00:00
matz c1a432a7d9 * array.c (rb_ary_equal): should handle recursive array.
* hash.c (hash_equal): should handle recursive hash.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-24 13:43:58 +00:00
matz 5f93fa308b * hash.c (hash_i): avoid too frequent hash conflict where key and
value are same.  a patch from Yusuke ENDOH <mame AT tsg.ne.jp>.
  [ruby-dev:31802]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-24 13:18:02 +00:00
matz f4d9d3d39b * hash.c (hash_equal): should call rb_eql when argument eql is set.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-20 17:03:41 +00:00
akr 2b18d1ee8e * hash.c (hash_alloc0, hash_alloc): unified because hash_alloc doesn't
allocate st_table now.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-30 00:41:24 +00:00