Ruby  1.9.3p551(2014-11-13revision48407)
Data Structures | Macros | Typedefs | Functions | Variables
hash.c File Reference
#include "ruby/ruby.h"
#include "ruby/st.h"
#include "ruby/util.h"
#include "ruby/encoding.h"
#include <errno.h>

Go to the source code of this file.

Data Structures

struct  foreach_safe_arg
 
struct  hash_foreach_arg
 
struct  rehash_arg
 
struct  shift_var
 
struct  equal_data
 
struct  update_arg
 

Macros

#define HASH_DELETED   FL_USER1
 
#define HASH_PROC_DEFAULT   FL_USER2
 
#define GET_ENVIRON(e)   (e)
 
#define FREE_ENVIRON(e)
 
#define ENVMATCH(n1, n2)   (strcmp((n1), (n2)) == 0)
 
#define ENVNMATCH(s1, s2, n)   (memcmp((s1), (s2), (n)) == 0)
 
#define rb_intern(str)   rb_intern_const(str)
 

Typedefs

typedef int st_foreach_func(st_data_t, st_data_t, st_data_t)
 
typedef int rb_foreach_func(VALUE, VALUE, VALUE)
 

Functions

static VALUE rb_hash_s_try_convert (VALUE, VALUE)
 
VALUE rb_hash_freeze (VALUE hash)
 
static int rb_any_cmp (VALUE a, VALUE b)
 
VALUE rb_hash (VALUE obj)
 
static st_index_t rb_any_hash (VALUE a)
 
static int foreach_safe_i (st_data_t key, st_data_t value, struct foreach_safe_arg *arg)
 
void st_foreach_safe (st_table *table, int(*func)(ANYARGS), st_data_t a)
 
static int hash_foreach_iter (st_data_t key, st_data_t value, struct hash_foreach_arg *arg)
 
static VALUE hash_foreach_ensure (VALUE hash)
 
static VALUE hash_foreach_call (struct hash_foreach_arg *arg)
 
void rb_hash_foreach (VALUE hash, int(*func)(ANYARGS), VALUE farg)
 
static VALUE hash_alloc (VALUE klass)
 
VALUE rb_hash_new (void)
 
VALUE rb_hash_dup (VALUE hash)
 
static void rb_hash_modify_check (VALUE hash)
 
struct st_tablerb_hash_tbl (VALUE hash)
 
static void rb_hash_modify (VALUE hash)
 
static void hash_update (VALUE hash, VALUE key)
 
static void default_proc_arity_check (VALUE proc)
 
static VALUE rb_hash_initialize (int argc, VALUE *argv, VALUE hash)
 
static VALUE rb_hash_s_create (int argc, VALUE *argv, VALUE klass)
 
static VALUE to_hash (VALUE hash)
 
VALUE rb_check_hash_type (VALUE hash)
 
static int rb_hash_rehash_i (VALUE key, VALUE value, VALUE arg)
 
static VALUE rb_hash_rehash (VALUE hash)
 
VALUE rb_hash_aref (VALUE hash, VALUE key)
 
VALUE rb_hash_lookup2 (VALUE hash, VALUE key, VALUE def)
 
VALUE rb_hash_lookup (VALUE hash, VALUE key)
 
static VALUE rb_hash_fetch_m (int argc, VALUE *argv, VALUE hash)
 
VALUE rb_hash_fetch (VALUE hash, VALUE key)
 
static VALUE rb_hash_default (int argc, VALUE *argv, VALUE hash)
 
static VALUE rb_hash_set_default (VALUE hash, VALUE ifnone)
 
static VALUE rb_hash_default_proc (VALUE hash)
 
static VALUE rb_hash_set_default_proc (VALUE hash, VALUE proc)
 
static int key_i (VALUE key, VALUE value, VALUE arg)
 
static VALUE rb_hash_key (VALUE hash, VALUE value)
 
static VALUE rb_hash_index (VALUE hash, VALUE value)
 
static VALUE rb_hash_delete_key (VALUE hash, VALUE key)
 
VALUE rb_hash_delete (VALUE hash, VALUE key)
 
static int shift_i_safe (VALUE key, VALUE value, VALUE arg)
 
static VALUE rb_hash_shift (VALUE hash)
 
static int delete_if_i (VALUE key, VALUE value, VALUE hash)
 
VALUE rb_hash_delete_if (VALUE hash)
 
VALUE rb_hash_reject_bang (VALUE hash)
 
static VALUE rb_hash_reject (VALUE hash)
 
VALUE rb_hash_values_at (int argc, VALUE *argv, VALUE hash)
 
static int select_i (VALUE key, VALUE value, VALUE result)
 
VALUE rb_hash_select (VALUE hash)
 
static int keep_if_i (VALUE key, VALUE value, VALUE hash)
 
VALUE rb_hash_select_bang (VALUE hash)
 
VALUE rb_hash_keep_if (VALUE hash)
 
static int clear_i (VALUE key, VALUE value, VALUE dummy)
 
static VALUE rb_hash_clear (VALUE hash)
 
static st_data_t copy_str_key (st_data_t str)
 
VALUE rb_hash_aset (VALUE hash, VALUE key, VALUE val)
 
static int replace_i (VALUE key, VALUE val, VALUE hash)
 
static VALUE rb_hash_replace (VALUE hash, VALUE hash2)
 
static VALUE rb_hash_size (VALUE hash)
 
static VALUE rb_hash_empty_p (VALUE hash)
 
static int each_value_i (VALUE key, VALUE value)
 
static VALUE rb_hash_each_value (VALUE hash)
 
static int each_key_i (VALUE key, VALUE value)
 
static VALUE rb_hash_each_key (VALUE hash)
 
static int each_pair_i (VALUE key, VALUE value)
 
static VALUE rb_hash_each_pair (VALUE hash)
 
static int to_a_i (VALUE key, VALUE value, VALUE ary)
 
static VALUE rb_hash_to_a (VALUE hash)
 
static int inspect_i (VALUE key, VALUE value, VALUE str)
 
static VALUE inspect_hash (VALUE hash, VALUE dummy, int recur)
 
static VALUE rb_hash_inspect (VALUE hash)
 
static VALUE rb_hash_to_hash (VALUE hash)
 
static int keys_i (VALUE key, VALUE value, VALUE ary)
 
static VALUE rb_hash_keys (VALUE hash)
 
static int values_i (VALUE key, VALUE value, VALUE ary)
 
static VALUE rb_hash_values (VALUE hash)
 
static VALUE rb_hash_has_key (VALUE hash, VALUE key)
 
static int rb_hash_search_value (VALUE key, VALUE value, VALUE arg)
 
static VALUE rb_hash_has_value (VALUE hash, VALUE val)
 
static int eql_i (VALUE key, VALUE val1, VALUE arg)
 
static VALUE recursive_eql (VALUE hash, VALUE dt, int recur)
 
static VALUE hash_equal (VALUE hash1, VALUE hash2, int eql)
 
static VALUE rb_hash_equal (VALUE hash1, VALUE hash2)
 
static VALUE rb_hash_eql (VALUE hash1, VALUE hash2)
 
static int hash_i (VALUE key, VALUE val, VALUE arg)
 
static VALUE recursive_hash (VALUE hash, VALUE dummy, int recur)
 
static VALUE rb_hash_hash (VALUE hash)
 
static int rb_hash_invert_i (VALUE key, VALUE value, VALUE hash)
 
static VALUE rb_hash_invert (VALUE hash)
 
static int rb_hash_update_i (VALUE key, VALUE value, VALUE hash)
 
static int rb_hash_update_block_i (VALUE key, VALUE value, VALUE hash)
 
static VALUE rb_hash_update (VALUE hash1, VALUE hash2)
 
static int rb_hash_update_func_i (VALUE key, VALUE value, VALUE arg0)
 
VALUE rb_hash_update_by (VALUE hash1, VALUE hash2, rb_hash_update_func *func)
 
static VALUE rb_hash_merge (VALUE hash1, VALUE hash2)
 
static int assoc_i (VALUE key, VALUE val, VALUE arg)
 
VALUE rb_hash_assoc (VALUE hash, VALUE obj)
 
static int rassoc_i (VALUE key, VALUE val, VALUE arg)
 
VALUE rb_hash_rassoc (VALUE hash, VALUE obj)
 
static VALUE rb_hash_flatten (int argc, VALUE *argv, VALUE hash)
 
static VALUE rb_hash_compare_by_id (VALUE hash)
 
static VALUE rb_hash_compare_by_id_p (VALUE hash)
 
static VALUE env_str_new (const char *ptr, long len)
 
static VALUE env_str_new2 (const char *ptr)
 
static VALUE env_delete (VALUE obj, VALUE name)
 
static VALUE env_delete_m (VALUE obj, VALUE name)
 
static int env_path_tainted (const char *)
 
static VALUE rb_f_getenv (VALUE obj, VALUE name)
 
static VALUE env_fetch (int argc, VALUE *argv)
 
static void path_tainted_p (const char *path)
 
int rb_env_path_tainted (void)
 
static int envix (const char *nam)
 
void ruby_setenv (const char *name, const char *value)
 
void ruby_unsetenv (const char *name)
 
static VALUE env_aset (VALUE obj, VALUE nm, VALUE val)
 
static VALUE env_keys (void)
 
static VALUE env_each_key (VALUE ehash)
 
static VALUE env_values (void)
 
static VALUE env_each_value (VALUE ehash)
 
static VALUE env_each_pair (VALUE ehash)
 
static VALUE env_reject_bang (VALUE ehash)
 
static VALUE env_delete_if (VALUE ehash)
 
static VALUE env_values_at (int argc, VALUE *argv)
 
static VALUE env_select (VALUE ehash)
 
static VALUE env_select_bang (VALUE ehash)
 
static VALUE env_keep_if (VALUE ehash)
 
VALUE rb_env_clear (void)
 
static VALUE env_to_s (void)
 
static VALUE env_inspect (void)
 
static VALUE env_to_a (void)
 
static VALUE env_none (void)
 
static VALUE env_size (void)
 
static VALUE env_empty_p (void)
 
static VALUE env_has_key (VALUE env, VALUE key)
 
static VALUE env_assoc (VALUE env, VALUE key)
 
static VALUE env_has_value (VALUE dmy, VALUE obj)
 
static VALUE env_rassoc (VALUE dmy, VALUE obj)
 
static VALUE env_key (VALUE dmy, VALUE value)
 
static VALUE env_index (VALUE dmy, VALUE value)
 
static VALUE env_to_hash (void)
 
static VALUE env_reject (void)
 
static VALUE env_shift (void)
 
static VALUE env_invert (void)
 
static int env_replace_i (VALUE key, VALUE val, VALUE keys)
 
static VALUE env_replace (VALUE env, VALUE hash)
 
static int env_update_i (VALUE key, VALUE val)
 
static VALUE env_update (VALUE env, VALUE hash)
 
void Init_Hash (void)
 

Variables

VALUE rb_cHash
 
static VALUE envtbl
 
static ID id_hash
 
static ID id_yield
 
static ID id_default
 
static const struct st_hash_type objhash
 
static const struct st_hash_type identhash
 
static int path_tainted = -1
 
static char ** origenviron
 
char ** environ
 

Macro Definition Documentation

◆ ENVMATCH

#define ENVMATCH (   n1,
  n2 
)    (strcmp((n1), (n2)) == 0)

Definition at line 2037 of file hash.c.

Referenced by env_aset(), env_delete(), env_fetch(), and rb_f_getenv().

◆ ENVNMATCH

#define ENVNMATCH (   s1,
  s2,
 
)    (memcmp((s1), (s2), (n)) == 0)

Definition at line 2038 of file hash.c.

Referenced by envix().

◆ FREE_ENVIRON

#define FREE_ENVIRON (   e)

◆ GET_ENVIRON

#define GET_ENVIRON (   e)    (e)

◆ HASH_DELETED

#define HASH_DELETED   FL_USER1

Definition at line 26 of file hash.c.

Referenced by hash_foreach_ensure(), hash_foreach_iter(), and rb_hash_delete_key().

◆ HASH_PROC_DEFAULT

#define HASH_PROC_DEFAULT   FL_USER2

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

Typedef Documentation

◆ rb_foreach_func

typedef int rb_foreach_func(VALUE, VALUE, VALUE)

Definition at line 148 of file hash.c.

◆ st_foreach_func

typedef int st_foreach_func(st_data_t, st_data_t, st_data_t)

Definition at line 114 of file hash.c.

Function Documentation

◆ assoc_i()

static int assoc_i ( VALUE  key,
VALUE  val,
VALUE  arg 
)
static

Definition at line 1864 of file hash.c.

References args, key, Qundef, rb_assoc_new(), rb_equal(), RTEST, ST_CONTINUE, and ST_STOP.

Referenced by rb_hash_assoc().

◆ clear_i()

static int clear_i ( VALUE  key,
VALUE  value,
VALUE  dummy 
)
static

Definition at line 1076 of file hash.c.

References ST_DELETE.

Referenced by rb_hash_clear().

◆ copy_str_key()

static st_data_t copy_str_key ( st_data_t  str)
static

Definition at line 1109 of file hash.c.

References rb_str_new4().

Referenced by rb_hash_aset().

◆ default_proc_arity_check()

static void default_proc_arity_check ( VALUE  proc)
static

Definition at line 282 of file hash.c.

References rb_eTypeError, rb_proc_arity(), rb_proc_lambda_p(), and rb_raise().

Referenced by rb_hash_initialize(), and rb_hash_set_default_proc().

◆ delete_if_i()

static int delete_if_i ( VALUE  key,
VALUE  value,
VALUE  hash 
)
static

Definition at line 889 of file hash.c.

References hash(), key, Qundef, rb_hash_delete_key(), rb_yield_values(), RTEST, and ST_CONTINUE.

Referenced by rb_hash_delete_if(), and rb_hash_reject_bang().

◆ each_key_i()

static int each_key_i ( VALUE  key,
VALUE  value 
)
static

Definition at line 1265 of file hash.c.

References key, Qundef, rb_yield(), and ST_CONTINUE.

Referenced by rb_hash_each_key().

◆ each_pair_i()

static int each_pair_i ( VALUE  key,
VALUE  value 
)
static

Definition at line 1299 of file hash.c.

References key, Qundef, rb_assoc_new(), rb_yield(), and ST_CONTINUE.

Referenced by rb_hash_each_pair().

◆ each_value_i()

static int each_value_i ( VALUE  key,
VALUE  value 
)
static

Definition at line 1230 of file hash.c.

References key, Qundef, rb_yield(), and ST_CONTINUE.

Referenced by rb_hash_each_value().

◆ env_aset()

static VALUE env_aset ( VALUE  obj,
VALUE  nm,
VALUE  val 
)
static

◆ env_assoc()

static VALUE env_assoc ( VALUE  env,
VALUE  key 
)
static

◆ env_delete()

static VALUE env_delete ( VALUE  obj,
VALUE  name 
)
static

◆ env_delete_if()

static VALUE env_delete_if ( VALUE  ehash)
static

Definition at line 2587 of file hash.c.

References env_reject_bang(), envtbl, and RETURN_ENUMERATOR.

Referenced by Init_Hash().

◆ env_delete_m()

static VALUE env_delete_m ( VALUE  obj,
VALUE  name 
)
static

Definition at line 2091 of file hash.c.

References env_delete(), name, NIL_P, rb_block_given_p(), and rb_yield().

Referenced by Init_Hash().

◆ env_each_key()

static VALUE env_each_key ( VALUE  ehash)
static

Definition at line 2444 of file hash.c.

References env_keys(), i, RARRAY_LEN, RARRAY_PTR, rb_yield(), and RETURN_ENUMERATOR.

Referenced by Init_Hash().

◆ env_each_pair()

static VALUE env_each_pair ( VALUE  ehash)
static

◆ env_each_value()

static VALUE env_each_value ( VALUE  ehash)
static

Definition at line 2493 of file hash.c.

References env_values(), i, RARRAY_LEN, RARRAY_PTR, rb_yield(), and RETURN_ENUMERATOR.

Referenced by Init_Hash().

◆ env_empty_p()

static VALUE env_empty_p ( void  )
static

Definition at line 2839 of file hash.c.

References env, environ, FREE_ENVIRON, GET_ENVIRON, Qfalse, Qtrue, and rb_secure().

Referenced by Init_Hash().

◆ env_fetch()

static VALUE env_fetch ( int  argc,
VALUE argv 
)
static

◆ env_has_key()

static VALUE env_has_key ( VALUE  env,
VALUE  key 
)
static

Definition at line 2863 of file hash.c.

References getenv(), key, Qfalse, Qtrue, rb_eArgError, rb_raise(), rb_secure(), RSTRING_LEN, and StringValuePtr.

Referenced by Init_Hash().

◆ env_has_value()

static VALUE env_has_value ( VALUE  dmy,
VALUE  obj 
)
static

◆ env_index()

static VALUE env_index ( VALUE  dmy,
VALUE  value 
)
static

Definition at line 2998 of file hash.c.

References env_key(), and rb_warn().

Referenced by Init_Hash().

◆ env_inspect()

static VALUE env_inspect ( void  )
static

◆ env_invert()

static VALUE env_invert ( void  )
static

Definition at line 3081 of file hash.c.

References env_to_hash(), and rb_hash_invert().

Referenced by Init_Hash().

◆ env_keep_if()

static VALUE env_keep_if ( VALUE  ehash)
static

Definition at line 2690 of file hash.c.

References env_select_bang(), envtbl, and RETURN_ENUMERATOR.

Referenced by Init_Hash().

◆ env_key()

static VALUE env_key ( VALUE  dmy,
VALUE  value 
)
static

◆ env_keys()

static VALUE env_keys ( void  )
static

◆ env_none()

static VALUE env_none ( void  )
static

Definition at line 2806 of file hash.c.

References Qnil.

Referenced by Init_Hash().

◆ env_path_tainted()

static int env_path_tainted ( const char *  path)
static

Definition at line 2185 of file hash.c.

References path_tainted, and path_tainted_p().

Referenced by env_fetch(), and rb_f_getenv().

◆ env_rassoc()

static VALUE env_rassoc ( VALUE  dmy,
VALUE  obj 
)
static

◆ env_reject()

static VALUE env_reject ( void  )
static

Definition at line 3041 of file hash.c.

References env_to_hash(), and rb_hash_delete_if().

Referenced by Init_Hash().

◆ env_reject_bang()

static VALUE env_reject_bang ( VALUE  ehash)
static

◆ env_replace()

static VALUE env_replace ( VALUE  env,
VALUE  hash 
)
static

Definition at line 3106 of file hash.c.

References env, env_delete(), env_keys(), env_replace_i(), hash(), i, RARRAY_LEN, RARRAY_PTR, rb_hash_foreach(), and to_hash().

Referenced by Init_Hash().

◆ env_replace_i()

static int env_replace_i ( VALUE  key,
VALUE  val,
VALUE  keys 
)
static

Definition at line 3087 of file hash.c.

References env_aset(), key, Qnil, Qundef, rb_ary_delete(), rb_ary_includes(), and ST_CONTINUE.

Referenced by env_replace().

◆ env_select()

static VALUE env_select ( VALUE  ehash)
static

◆ env_select_bang()

static VALUE env_select_bang ( VALUE  ehash)
static

◆ env_shift()

static VALUE env_shift ( void  )
static

◆ env_size()

static VALUE env_size ( void  )
static

Definition at line 2819 of file hash.c.

References env, environ, FREE_ENVIRON, GET_ENVIRON, i, INT2FIX, and rb_secure().

Referenced by Init_Hash().

◆ env_str_new()

static VALUE env_str_new ( const char *  ptr,
long  len 
)
static

◆ env_str_new2()

static VALUE env_str_new2 ( const char *  ptr)
static

◆ env_to_a()

static VALUE env_to_a ( void  )
static

◆ env_to_hash()

static VALUE env_to_hash ( void  )
static

◆ env_to_s()

static VALUE env_to_s ( void  )
static

Definition at line 2726 of file hash.c.

References rb_usascii_str_new2().

Referenced by Init_Hash().

◆ env_update()

static VALUE env_update ( VALUE  env,
VALUE  hash 
)
static

Definition at line 3145 of file hash.c.

References env, env_update_i(), hash(), rb_hash_foreach(), rb_secure(), and to_hash().

Referenced by Init_Hash().

◆ env_update_i()

static int env_update_i ( VALUE  key,
VALUE  val 
)
static

Definition at line 3123 of file hash.c.

References env_aset(), key, Qnil, Qundef, rb_block_given_p(), rb_f_getenv(), rb_yield_values(), and ST_CONTINUE.

Referenced by env_update().

◆ env_values()

static VALUE env_values ( void  )
static

Definition at line 2464 of file hash.c.

References env, env_str_new2(), environ, FREE_ENVIRON, GET_ENVIRON, rb_ary_new(), rb_ary_push(), rb_secure(), and strchr().

Referenced by env_each_value(), and Init_Hash().

◆ env_values_at()

static VALUE env_values_at ( int  argc,
VALUE argv 
)
static

Definition at line 2602 of file hash.c.

References argc, argv, i, Qnil, rb_ary_new(), rb_ary_push(), rb_f_getenv(), rb_secure(), and result.

Referenced by Init_Hash().

◆ envix()

static int envix ( const char *  nam)
static

Definition at line 2215 of file hash.c.

References env, environ, ENVNMATCH, FREE_ENVIRON, GET_ENVIRON, i, len, and strlen().

Referenced by ruby_setenv().

◆ eql_i()

static int eql_i ( VALUE  key,
VALUE  val1,
VALUE  arg 
)
static

◆ foreach_safe_i()

static int foreach_safe_i ( st_data_t  key,
st_data_t  value,
struct foreach_safe_arg arg 
)
static

Definition at line 123 of file hash.c.

References foreach_safe_arg::arg, foreach_safe_arg::func, key, Qundef, ST_CHECK, and ST_CONTINUE.

Referenced by st_foreach_safe().

◆ hash_alloc()

static VALUE hash_alloc ( VALUE  klass)
static

Definition at line 218 of file hash.c.

References hash(), NEWOBJ, OBJSETUP, Qnil, RHASH_IFNONE, and T_HASH.

Referenced by Init_Hash(), rb_hash_new(), rb_hash_rehash(), and rb_hash_s_create().

◆ hash_equal()

static VALUE hash_equal ( VALUE  hash1,
VALUE  hash2,
int  eql 
)
static

◆ hash_foreach_call()

static VALUE hash_foreach_call ( struct hash_foreach_arg arg)
static

Definition at line 195 of file hash.c.

References hash_foreach_arg::hash, hash_foreach_iter(), Qnil, rb_eRuntimeError, rb_raise(), RHASH, and st_foreach.

Referenced by rb_hash_foreach().

◆ hash_foreach_ensure()

static VALUE hash_foreach_ensure ( VALUE  hash)
static

Definition at line 181 of file hash.c.

References FL_TEST, FL_UNSET, hash(), HASH_DELETED, Qundef, RHASH, and st_cleanup_safe.

Referenced by rb_hash_foreach().

◆ hash_foreach_iter()

static int hash_foreach_iter ( st_data_t  key,
st_data_t  value,
struct hash_foreach_arg arg 
)
static

◆ hash_i()

static int hash_i ( VALUE  key,
VALUE  val,
VALUE  arg 
)
static

Definition at line 1670 of file hash.c.

References key, Qundef, rb_hash(), ST_CONTINUE, and st_hash().

Referenced by recursive_hash().

◆ hash_update()

static void hash_update ( VALUE  hash,
VALUE  key 
)
static

◆ Init_Hash()

void Init_Hash ( void  )

Definition at line 3167 of file hash.c.

References env_aset(), env_assoc(), env_delete_if(), env_delete_m(), env_each_key(), env_each_pair(), env_each_value(), env_empty_p(), env_fetch(), env_has_key(), env_has_value(), env_index(), env_inspect(), env_invert(), env_keep_if(), env_key(), env_keys(), env_none(), env_rassoc(), env_reject(), env_reject_bang(), env_replace(), env_select(), env_select_bang(), env_shift(), env_size(), env_to_a(), env_to_hash(), env_to_s(), env_update(), env_values(), env_values_at(), environ, envtbl, hash_alloc(), id_default, id_hash, id_yield, origenviron, rb_cHash, rb_cObject, rb_define_alias(), rb_define_alloc_func(), rb_define_class(), rb_define_global_const(), rb_define_method(), rb_define_singleton_method(), rb_env_clear(), rb_extend_object(), rb_f_getenv(), rb_hash_aref(), rb_hash_aset(), rb_hash_assoc(), rb_hash_clear(), rb_hash_compare_by_id(), rb_hash_compare_by_id_p(), rb_hash_default(), rb_hash_default_proc(), rb_hash_delete(), rb_hash_delete_if(), rb_hash_each_key(), rb_hash_each_pair(), rb_hash_each_value(), rb_hash_empty_p(), rb_hash_eql(), rb_hash_equal(), rb_hash_fetch_m(), rb_hash_flatten(), rb_hash_has_key(), rb_hash_has_value(), rb_hash_hash(), rb_hash_index(), rb_hash_initialize(), rb_hash_inspect(), rb_hash_invert(), rb_hash_keep_if(), rb_hash_key(), rb_hash_keys(), rb_hash_merge(), rb_hash_rassoc(), rb_hash_rehash(), rb_hash_reject(), rb_hash_reject_bang(), rb_hash_replace(), rb_hash_s_create(), rb_hash_s_try_convert(), rb_hash_select(), rb_hash_select_bang(), rb_hash_set_default(), rb_hash_set_default_proc(), rb_hash_shift(), rb_hash_size(), rb_hash_to_a(), rb_hash_to_hash(), rb_hash_update(), rb_hash_values(), rb_hash_values_at(), rb_include_module(), rb_intern, rb_mEnumerable, and rb_obj_alloc().

◆ inspect_hash()

static VALUE inspect_hash ( VALUE  hash,
VALUE  dummy,
int  recur 
)
static

◆ inspect_i()

static int inspect_i ( VALUE  key,
VALUE  value,
VALUE  str 
)
static

◆ keep_if_i()

static int keep_if_i ( VALUE  key,
VALUE  value,
VALUE  hash 
)
static

Definition at line 1021 of file hash.c.

References key, Qundef, rb_yield_values(), RTEST, ST_CONTINUE, and ST_DELETE.

Referenced by rb_hash_keep_if(), and rb_hash_select_bang().

◆ key_i()

static int key_i ( VALUE  key,
VALUE  value,
VALUE  arg 
)
static

Definition at line 735 of file hash.c.

References args, key, rb_equal(), ST_CONTINUE, and ST_STOP.

Referenced by rb_hash_key().

◆ keys_i()

static int keys_i ( VALUE  key,
VALUE  value,
VALUE  ary 
)
static

Definition at line 1437 of file hash.c.

References key, Qundef, rb_ary_push(), and ST_CONTINUE.

Referenced by rb_hash_keys().

◆ path_tainted_p()

static void path_tainted_p ( const char *  path)
static

Definition at line 2179 of file hash.c.

References path_tainted, and rb_path_check().

Referenced by env_aset(), env_path_tainted(), and rb_env_path_tainted().

◆ rassoc_i()

static int rassoc_i ( VALUE  key,
VALUE  val,
VALUE  arg 
)
static

Definition at line 1902 of file hash.c.

References args, key, Qundef, rb_assoc_new(), rb_equal(), RTEST, ST_CONTINUE, and ST_STOP.

Referenced by rb_hash_rassoc().

◆ rb_any_cmp()

static int rb_any_cmp ( VALUE  a,
VALUE  b 
)
static

Definition at line 41 of file hash.c.

References FIXNUM_P, Qundef, rb_cString, rb_eql(), rb_str_hash_cmp(), RBASIC, SYMBOL_P, T_STRING, and TYPE.

◆ rb_any_hash()

static st_index_t rb_any_hash ( VALUE  a)
static

◆ rb_check_hash_type()

VALUE rb_check_hash_type ( VALUE  hash)

Definition at line 423 of file hash.c.

References hash(), rb_check_convert_type(), and T_HASH.

Referenced by rb_econv_prepare_options(), and rb_hash_s_try_convert().

◆ rb_env_clear()

VALUE rb_env_clear ( void  )

Definition at line 2704 of file hash.c.

References env_delete(), env_keys(), envtbl, i, NIL_P, Qnil, RARRAY_LEN, RARRAY_PTR, and rb_f_getenv().

Referenced by Init_Hash(), and rb_run_exec_options_err().

◆ rb_env_path_tainted()

int rb_env_path_tainted ( void  )

Definition at line 2194 of file hash.c.

References getenv(), PATH_ENV, path_tainted, and path_tainted_p().

Referenced by security().

◆ rb_f_getenv()

static VALUE rb_f_getenv ( VALUE  obj,
VALUE  name 
)
static

◆ rb_hash()

VALUE rb_hash ( VALUE  obj)

◆ rb_hash_aref()

VALUE rb_hash_aref ( VALUE  hash,
VALUE  key 
)

◆ rb_hash_aset()

VALUE rb_hash_aset ( VALUE  hash,
VALUE  key,
VALUE  val 
)

◆ rb_hash_assoc()

VALUE rb_hash_assoc ( VALUE  hash,
VALUE  obj 
)

Definition at line 1891 of file hash.c.

References args, assoc_i(), hash(), Qnil, and rb_hash_foreach().

Referenced by Init_Hash().

◆ rb_hash_clear()

static VALUE rb_hash_clear ( VALUE  hash)
static

Definition at line 1093 of file hash.c.

References clear_i(), hash(), rb_hash_foreach(), rb_hash_modify_check(), RHASH, and st_clear().

Referenced by Init_Hash(), and rb_hash_replace().

◆ rb_hash_compare_by_id()

static VALUE rb_hash_compare_by_id ( VALUE  hash)
static

Definition at line 1986 of file hash.c.

References hash(), identhash, rb_hash_modify(), rb_hash_rehash(), and RHASH.

Referenced by Init_Hash().

◆ rb_hash_compare_by_id_p()

static VALUE rb_hash_compare_by_id_p ( VALUE  hash)
static

Definition at line 2004 of file hash.c.

References hash(), identhash, Qfalse, Qtrue, and RHASH.

Referenced by Init_Hash().

◆ rb_hash_default()

static VALUE rb_hash_default ( int  argc,
VALUE argv,
VALUE  hash 
)
static

Definition at line 636 of file hash.c.

References argc, argv, FL_TEST, hash(), HASH_PROC_DEFAULT, id_yield, key, Qnil, rb_funcall(), rb_scan_args(), and RHASH_IFNONE.

Referenced by Init_Hash().

◆ rb_hash_default_proc()

static VALUE rb_hash_default_proc ( VALUE  hash)
static

Definition at line 694 of file hash.c.

References FL_TEST, hash(), HASH_PROC_DEFAULT, Qnil, and RHASH_IFNONE.

Referenced by Init_Hash().

◆ rb_hash_delete()

VALUE rb_hash_delete ( VALUE  hash,
VALUE  key 
)

◆ rb_hash_delete_if()

VALUE rb_hash_delete_if ( VALUE  hash)

◆ rb_hash_delete_key()

static VALUE rb_hash_delete_key ( VALUE  hash,
VALUE  key 
)
static

Definition at line 782 of file hash.c.

References FL_SET, hash(), HASH_DELETED, key, Qundef, RHASH, st_delete, and st_delete_safe.

Referenced by delete_if_i(), rb_hash_delete(), and rb_hash_shift().

◆ rb_hash_dup()

VALUE rb_hash_dup ( VALUE  hash)

Definition at line 235 of file hash.c.

References DUPSETUP, FL_SET, FL_TEST, hash(), HASH_PROC_DEFAULT, NEWOBJ, RHASH, RHASH_EMPTY_P, RHASH_IFNONE, and st_copy.

Referenced by io_s_write().

◆ rb_hash_each_key()

static VALUE rb_hash_each_key ( VALUE  hash)
static

Definition at line 1291 of file hash.c.

References each_key_i(), hash(), rb_hash_foreach(), and RETURN_ENUMERATOR.

Referenced by Init_Hash().

◆ rb_hash_each_pair()

static VALUE rb_hash_each_pair ( VALUE  hash)
static

Definition at line 1329 of file hash.c.

References each_pair_i(), hash(), rb_hash_foreach(), and RETURN_ENUMERATOR.

Referenced by Init_Hash().

◆ rb_hash_each_value()

static VALUE rb_hash_each_value ( VALUE  hash)
static

Definition at line 1257 of file hash.c.

References each_value_i(), hash(), rb_hash_foreach(), and RETURN_ENUMERATOR.

Referenced by Init_Hash().

◆ rb_hash_empty_p()

static VALUE rb_hash_empty_p ( VALUE  hash)
static

Definition at line 1224 of file hash.c.

References hash(), Qfalse, Qtrue, and RHASH_EMPTY_P.

Referenced by Init_Hash().

◆ rb_hash_eql()

static VALUE rb_hash_eql ( VALUE  hash1,
VALUE  hash2 
)
static

Definition at line 1664 of file hash.c.

References hash_equal(), and TRUE.

Referenced by Init_Hash().

◆ rb_hash_equal()

static VALUE rb_hash_equal ( VALUE  hash1,
VALUE  hash2 
)
static

Definition at line 1650 of file hash.c.

References FALSE, and hash_equal().

Referenced by Init_Hash().

◆ rb_hash_fetch()

VALUE rb_hash_fetch ( VALUE  hash,
VALUE  key 
)

Definition at line 609 of file hash.c.

References hash(), key, and rb_hash_fetch_m().

◆ rb_hash_fetch_m()

static VALUE rb_hash_fetch_m ( int  argc,
VALUE argv,
VALUE  hash 
)
static

◆ rb_hash_flatten()

static VALUE rb_hash_flatten ( int  argc,
VALUE argv,
VALUE  hash 
)
static

Definition at line 1955 of file hash.c.

References argc, argv, hash(), INT2FIX, rb_funcall2(), rb_hash_to_a(), and rb_intern.

Referenced by Init_Hash().

◆ rb_hash_foreach()

void rb_hash_foreach ( VALUE  hash,
int(*)(ANYARGS func,
VALUE  farg 
)

◆ rb_hash_freeze()

VALUE rb_hash_freeze ( VALUE  hash)

Definition at line 30 of file hash.c.

References hash(), and rb_obj_freeze().

Referenced by rb_coverage_result(), and rb_econv_prepare_options().

◆ rb_hash_has_key()

static VALUE rb_hash_has_key ( VALUE  hash,
VALUE  key 
)
static

Definition at line 1514 of file hash.c.

References hash(), key, Qfalse, Qtrue, RHASH, and st_lookup.

Referenced by Init_Hash(), rb_hash_update_block_i(), and rb_hash_update_func_i().

◆ rb_hash_has_value()

static VALUE rb_hash_has_value ( VALUE  hash,
VALUE  val 
)
static

Definition at line 1551 of file hash.c.

References hash(), Qfalse, rb_hash_foreach(), rb_hash_search_value(), and shift_var::val.

Referenced by Init_Hash().

◆ rb_hash_hash()

static VALUE rb_hash_hash ( VALUE  hash)
static

Definition at line 1708 of file hash.c.

References hash(), rb_exec_recursive_outer(), and recursive_hash().

Referenced by Init_Hash().

◆ rb_hash_index()

static VALUE rb_hash_index ( VALUE  hash,
VALUE  value 
)
static

Definition at line 775 of file hash.c.

References hash(), rb_hash_key(), and rb_warn().

Referenced by Init_Hash().

◆ rb_hash_initialize()

static VALUE rb_hash_initialize ( int  argc,
VALUE argv,
VALUE  hash 
)
static

◆ rb_hash_inspect()

static VALUE rb_hash_inspect ( VALUE  hash)
static

Definition at line 1416 of file hash.c.

References hash(), inspect_hash(), rb_exec_recursive(), rb_usascii_str_new2(), and RHASH_EMPTY_P.

Referenced by Init_Hash().

◆ rb_hash_invert()

static VALUE rb_hash_invert ( VALUE  hash)
static

Definition at line 1734 of file hash.c.

References hash(), rb_hash_foreach(), rb_hash_invert_i(), and rb_hash_new().

Referenced by env_invert(), and Init_Hash().

◆ rb_hash_invert_i()

static int rb_hash_invert_i ( VALUE  key,
VALUE  value,
VALUE  hash 
)
static

Definition at line 1714 of file hash.c.

References hash(), key, Qundef, rb_hash_aset(), and ST_CONTINUE.

Referenced by rb_hash_invert().

◆ rb_hash_keep_if()

VALUE rb_hash_keep_if ( VALUE  hash)

Definition at line 1067 of file hash.c.

References hash(), keep_if_i(), rb_hash_foreach(), rb_hash_modify(), and RETURN_ENUMERATOR.

Referenced by Init_Hash().

◆ rb_hash_key()

static VALUE rb_hash_key ( VALUE  hash,
VALUE  value 
)
static

Definition at line 761 of file hash.c.

References args, hash(), key_i(), Qnil, and rb_hash_foreach().

Referenced by Init_Hash(), and rb_hash_index().

◆ rb_hash_keys()

static VALUE rb_hash_keys ( VALUE  hash)
static

Definition at line 1457 of file hash.c.

References hash(), keys_i(), rb_ary_new(), and rb_hash_foreach().

Referenced by Init_Hash().

◆ rb_hash_lookup()

VALUE rb_hash_lookup ( VALUE  hash,
VALUE  key 
)

Definition at line 546 of file hash.c.

References hash(), key, Qnil, and rb_hash_lookup2().

◆ rb_hash_lookup2()

VALUE rb_hash_lookup2 ( VALUE  hash,
VALUE  key,
VALUE  def 
)

◆ rb_hash_merge()

static VALUE rb_hash_merge ( VALUE  hash1,
VALUE  hash2 
)
static

Definition at line 1858 of file hash.c.

References rb_hash_update(), and rb_obj_dup().

Referenced by Init_Hash().

◆ rb_hash_modify()

static void rb_hash_modify ( VALUE  hash)
static

◆ rb_hash_modify_check()

static void rb_hash_modify_check ( VALUE  hash)
static

◆ rb_hash_new()

VALUE rb_hash_new ( void  )

◆ rb_hash_rassoc()

VALUE rb_hash_rassoc ( VALUE  hash,
VALUE  obj 
)

Definition at line 1928 of file hash.c.

References args, hash(), Qnil, rassoc_i(), and rb_hash_foreach().

Referenced by Init_Hash().

◆ rb_hash_rehash()

static VALUE rb_hash_rehash ( VALUE  hash)
static

◆ rb_hash_rehash_i()

static int rb_hash_rehash_i ( VALUE  key,
VALUE  value,
VALUE  arg 
)
static

Definition at line 451 of file hash.c.

References key, Qundef, ST_CONTINUE, and st_insert.

Referenced by rb_hash_rehash().

◆ rb_hash_reject()

static VALUE rb_hash_reject ( VALUE  hash)
static

Definition at line 958 of file hash.c.

References hash(), rb_hash_delete_if(), and rb_obj_dup().

Referenced by Init_Hash().

◆ rb_hash_reject_bang()

VALUE rb_hash_reject_bang ( VALUE  hash)

Definition at line 932 of file hash.c.

References delete_if_i(), hash(), Qnil, rb_hash_foreach(), rb_hash_modify(), RETURN_ENUMERATOR, and RHASH.

Referenced by Init_Hash().

◆ rb_hash_replace()

static VALUE rb_hash_replace ( VALUE  hash,
VALUE  hash2 
)
static

◆ rb_hash_s_create()

static VALUE rb_hash_s_create ( int  argc,
VALUE argv,
VALUE  klass 
)
static

◆ rb_hash_s_try_convert()

static VALUE rb_hash_s_try_convert ( VALUE  dummy,
VALUE  hash 
)
static

Definition at line 440 of file hash.c.

References hash(), and rb_check_hash_type().

Referenced by Init_Hash(), and rb_hash_s_create().

◆ rb_hash_search_value()

static int rb_hash_search_value ( VALUE  key,
VALUE  value,
VALUE  arg 
)
static

Definition at line 1525 of file hash.c.

References key, Qtrue, Qundef, rb_equal(), ST_CONTINUE, and ST_STOP.

Referenced by rb_hash_has_value().

◆ rb_hash_select()

VALUE rb_hash_select ( VALUE  hash)

Definition at line 1010 of file hash.c.

References hash(), rb_hash_foreach(), rb_hash_new(), result, RETURN_ENUMERATOR, and select_i().

Referenced by Init_Hash().

◆ rb_hash_select_bang()

VALUE rb_hash_select_bang ( VALUE  hash)

Definition at line 1040 of file hash.c.

References hash(), keep_if_i(), Qnil, rb_hash_foreach(), rb_hash_modify(), RETURN_ENUMERATOR, and RHASH.

Referenced by Init_Hash().

◆ rb_hash_set_default()

static VALUE rb_hash_set_default ( VALUE  hash,
VALUE  ifnone 
)
static

Definition at line 670 of file hash.c.

References FL_UNSET, hash(), HASH_PROC_DEFAULT, rb_hash_modify(), and RHASH_IFNONE.

Referenced by Init_Hash().

◆ rb_hash_set_default_proc()

static VALUE rb_hash_set_default_proc ( VALUE  hash,
VALUE  proc 
)
static

◆ rb_hash_shift()

static VALUE rb_hash_shift ( VALUE  hash)
static

◆ rb_hash_size()

static VALUE rb_hash_size ( VALUE  hash)
static

Definition at line 1205 of file hash.c.

References hash(), INT2FIX, and RHASH.

Referenced by Init_Hash().

◆ rb_hash_tbl()

struct st_table* rb_hash_tbl ( VALUE  hash)

Definition at line 258 of file hash.c.

References hash(), objhash, RHASH, and st_init_table.

Referenced by iseq_set_sequence(), rb_hash_modify(), and rb_hash_replace().

◆ rb_hash_to_a()

static VALUE rb_hash_to_a ( VALUE  hash)
static

Definition at line 1356 of file hash.c.

References hash(), OBJ_INFECT, rb_ary_new(), rb_hash_foreach(), and to_a_i().

Referenced by Init_Hash(), and rb_hash_flatten().

◆ rb_hash_to_hash()

static VALUE rb_hash_to_hash ( VALUE  hash)
static

Definition at line 1431 of file hash.c.

References hash().

Referenced by Init_Hash().

◆ rb_hash_update()

static VALUE rb_hash_update ( VALUE  hash1,
VALUE  hash2 
)
static

◆ rb_hash_update_block_i()

static int rb_hash_update_block_i ( VALUE  key,
VALUE  value,
VALUE  hash 
)
static

◆ rb_hash_update_by()

VALUE rb_hash_update_by ( VALUE  hash1,
VALUE  hash2,
rb_hash_update_func func 
)

◆ rb_hash_update_func_i()

static int rb_hash_update_func_i ( VALUE  key,
VALUE  value,
VALUE  arg0 
)
static

◆ rb_hash_update_i()

static int rb_hash_update_i ( VALUE  key,
VALUE  value,
VALUE  hash 
)
static

Definition at line 1743 of file hash.c.

References hash(), hash_update(), key, Qundef, RHASH, ST_CONTINUE, and st_insert.

Referenced by rb_hash_update(), and rb_hash_update_by().

◆ rb_hash_values()

static VALUE rb_hash_values ( VALUE  hash)
static

Definition at line 1488 of file hash.c.

References hash(), rb_ary_new(), rb_hash_foreach(), and values_i().

Referenced by Init_Hash().

◆ rb_hash_values_at()

VALUE rb_hash_values_at ( int  argc,
VALUE argv,
VALUE  hash 
)

Definition at line 975 of file hash.c.

References argc, argv, hash(), i, rb_ary_new2(), rb_ary_push(), rb_hash_aref(), and result.

Referenced by Init_Hash().

◆ recursive_eql()

static VALUE recursive_eql ( VALUE  hash,
VALUE  dt,
int  recur 
)
static

Definition at line 1586 of file hash.c.

References eql_i(), hash(), Qtrue, rb_hash_foreach(), recur, and equal_data::result.

Referenced by hash_equal().

◆ recursive_hash()

static VALUE recursive_hash ( VALUE  hash,
VALUE  dummy,
int  recur 
)
static

◆ replace_i()

static int replace_i ( VALUE  key,
VALUE  val,
VALUE  hash 
)
static

Definition at line 1147 of file hash.c.

References hash(), key, Qundef, rb_hash_aset(), ST_CONTINUE, and shift_var::val.

Referenced by rb_hash_replace().

◆ ruby_setenv()

void ruby_setenv ( const char *  name,
const char *  value 
)

◆ ruby_unsetenv()

void ruby_unsetenv ( const char *  name)

Definition at line 2358 of file hash.c.

References name, and ruby_setenv().

◆ select_i()

static int select_i ( VALUE  key,
VALUE  value,
VALUE  result 
)
static

Definition at line 987 of file hash.c.

References key, Qundef, rb_hash_aset(), rb_yield_values(), result, RTEST, and ST_CONTINUE.

Referenced by rb_hash_select().

◆ shift_i_safe()

static int shift_i_safe ( VALUE  key,
VALUE  value,
VALUE  arg 
)
static

Definition at line 837 of file hash.c.

References shift_var::key, key, Qundef, ST_CONTINUE, ST_STOP, and shift_var::val.

Referenced by rb_hash_shift().

◆ st_foreach_safe()

void st_foreach_safe ( st_table table,
int(*)(ANYARGS func,
st_data_t  a 
)

◆ to_a_i()

static int to_a_i ( VALUE  key,
VALUE  value,
VALUE  ary 
)
static

Definition at line 1337 of file hash.c.

References key, Qundef, rb_ary_push(), rb_assoc_new(), and ST_CONTINUE.

Referenced by rb_hash_to_a().

◆ to_hash()

static VALUE to_hash ( VALUE  hash)
static

Definition at line 417 of file hash.c.

References hash(), rb_convert_type(), and T_HASH.

Referenced by env_replace(), env_update(), rb_hash_replace(), rb_hash_update(), and rb_hash_update_by().

◆ values_i()

static int values_i ( VALUE  key,
VALUE  value,
VALUE  ary 
)
static

Definition at line 1468 of file hash.c.

References key, Qundef, rb_ary_push(), and ST_CONTINUE.

Referenced by rb_hash_values().

Variable Documentation

◆ environ

char** environ

◆ envtbl

VALUE envtbl
static

◆ id_default

ID id_default
static

Definition at line 38 of file hash.c.

Referenced by Init_Hash(), and rb_hash_aref().

◆ id_hash

ID id_hash
static

Definition at line 38 of file hash.c.

Referenced by Init_Hash(), and rb_hash().

◆ id_yield

ID id_yield
static

Definition at line 38 of file hash.c.

Referenced by Init_Hash(), rb_hash_default(), and rb_hash_shift().

◆ identhash

const struct st_hash_type identhash
static
Initial value:
= {
}
int st_numcmp(st_data_t, st_data_t)
Definition: st.c:1369
st_index_t st_numhash(st_data_t)
Definition: st.c:1375

Definition at line 109 of file hash.c.

Referenced by rb_hash_aset(), rb_hash_compare_by_id(), and rb_hash_compare_by_id_p().

◆ objhash

const struct st_hash_type objhash
static
Initial value:
= {
}
static int rb_any_cmp(VALUE a, VALUE b)
Definition: hash.c:41
static st_index_t rb_any_hash(VALUE a)
Definition: hash.c:78

Definition at line 104 of file hash.c.

Referenced by rb_hash_tbl().

◆ origenviron

char** origenviron
static

Definition at line 2016 of file hash.c.

Referenced by Init_Hash(), and ruby_setenv().

◆ path_tainted

int path_tainted = -1
static

Definition at line 2014 of file hash.c.

Referenced by env_aset(), env_delete(), env_path_tainted(), path_tainted_p(), and rb_env_path_tainted().

◆ rb_cHash

VALUE rb_cHash