Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

hash.c File Reference

#include "ruby.h"
#include "st.h"
#include "util.h"
#include "rubysig.h"

Go to the source code of this file.

Data Structures

struct  equal_data
struct  foreach_safe_arg
struct  hash_foreach_arg
struct  shift_var

Defines

#define HASH_DELETED   FL_USER1
#define HASH_PROC_DEFAULT   FL_USER2
#define GET_ENVIRON(e)   (e)
#define FREE_ENVIRON(e)

Functions

void rb_hash_modify (VALUE hash)
VALUE rb_hash_freeze (VALUE hash)
VALUE eql (VALUE *args)
int rb_any_cmp (VALUE a, VALUE b)
VALUE rb_hash (VALUE obj)
int rb_any_hash (VALUE a)
int foreach_safe_i (st_data_t key, st_data_t value, struct foreach_safe_arg *arg)
void st_foreach_safe (st_table *table, func, st_data_t a)
int hash_foreach_iter (VALUE key, VALUE value, struct hash_foreach_arg *arg)
VALUE hash_foreach_ensure (VALUE hash)
VALUE hash_foreach_call (struct hash_foreach_arg *arg)
void rb_hash_foreach (VALUE hash, func, VALUE farg)
VALUE hash_alloc (VALUE)
VALUE rb_hash_new ()
VALUE rb_hash_initialize (int argc, VALUE *argv, VALUE hash)
VALUE rb_hash_s_create (int argc, VALUE *argv, VALUE klass)
VALUE to_hash (VALUE hash)
int rb_hash_rehash_i (VALUE key, VALUE value, st_table *tbl)
VALUE rb_hash_rehash (VALUE hash)
VALUE rb_hash_aref (VALUE hash, VALUE key)
VALUE rb_hash_fetch (int argc, VALUE *argv, VALUE hash)
VALUE rb_hash_default (int argc, VALUE *argv, VALUE hash)
VALUE rb_hash_set_default (VALUE hash, VALUE ifnone)
VALUE rb_hash_default_proc (VALUE hash)
int index_i (VALUE key, VALUE value, VALUE *args)
VALUE rb_hash_index (VALUE hash, VALUE value)
VALUE rb_hash_indexes (int argc, VALUE *argv, VALUE hash)
VALUE rb_hash_delete (VALUE hash, VALUE key)
int shift_i (VALUE key, VALUE value, struct shift_var *var)
VALUE rb_hash_shift (VALUE hash)
int delete_if_i (VALUE key, VALUE value, VALUE hash)
VALUE rb_hash_delete_if (VALUE hash)
VALUE rb_hash_reject_bang (VALUE hash)
VALUE rb_hash_reject (VALUE hash)
int select_i (VALUE key, VALUE value, VALUE result)
VALUE rb_hash_values_at (int argc, VALUE *argv, VALUE hash)
VALUE rb_hash_select (int argc, VALUE *argv, VALUE hash)
int clear_i (VALUE key, VALUE value, VALUE dummy)
VALUE rb_hash_clear (VALUE hash)
VALUE rb_hash_aset (VALUE hash, VALUE key, VALUE val)
int replace_i (VALUE key, VALUE val, VALUE hash)
VALUE rb_hash_replace (VALUE hash, VALUE hash2)
VALUE rb_hash_size (VALUE hash)
VALUE rb_hash_empty_p (VALUE hash)
int each_value_i (VALUE key, VALUE value)
VALUE rb_hash_each_value (VALUE hash)
int each_key_i (VALUE key, VALUE value)
VALUE rb_hash_each_key (VALUE hash)
int each_pair_i (VALUE key, VALUE value)
VALUE rb_hash_each_pair (VALUE hash)
int each_i (VALUE key, VALUE value)
VALUE rb_hash_each (VALUE hash)
int to_a_i (VALUE key, VALUE value, VALUE ary)
VALUE rb_hash_to_a (VALUE hash)
VALUE rb_hash_sort (VALUE hash)
int inspect_i (VALUE key, VALUE value, VALUE str)
VALUE inspect_hash (VALUE hash)
VALUE rb_hash_inspect (VALUE hash)
VALUE to_s_hash (VALUE hash)
VALUE rb_hash_to_s (VALUE hash)
VALUE rb_hash_to_hash (VALUE hash)
int keys_i (VALUE key, VALUE value, VALUE ary)
VALUE rb_hash_keys (VALUE hash)
int values_i (VALUE key, VALUE value, VALUE ary)
VALUE rb_hash_values (VALUE hash)
VALUE rb_hash_has_key (VALUE hash, VALUE key)
int rb_hash_search_value (VALUE key, VALUE value, VALUE *data)
VALUE rb_hash_has_value (VALUE hash, VALUE val)
int equal_i (VALUE key, VALUE val1, struct equal_data *data)
VALUE hash_equal (VALUE hash1, VALUE hash2, int eql)
VALUE rb_hash_equal (VALUE hash1, VALUE hash2)
int rb_hash_invert_i (VALUE key, VALUE value, VALUE hash)
VALUE rb_hash_invert (VALUE hash)
int rb_hash_update_i (VALUE key, VALUE value, VALUE hash)
int rb_hash_update_block_i (VALUE key, VALUE value, VALUE hash)
VALUE rb_hash_update (VALUE hash1, VALUE hash2)
VALUE rb_hash_merge (VALUE hash1, VALUE hash2)
VALUE env_str_new (char *ptr, long len) const
VALUE env_str_new2 (char *ptr) const
VALUE env_delete (VALUE obj, VALUE name)
VALUE env_delete_m (VALUE obj, VALUE name)
VALUE rb_f_getenv (VALUE obj, VALUE name)
VALUE env_fetch (int argc, VALUE *argv)
void path_tainted_p (char *path)
int rb_env_path_tainted ()
int envix (char *nam) const
void ruby_setenv (char *name, const char *value) const
void ruby_unsetenv (char *name) const
VALUE env_aset (VALUE obj, VALUE nm, VALUE val)
VALUE env_keys ()
VALUE env_each_key (VALUE ehash)
VALUE env_values ()
VALUE env_each_value (VALUE ehash)
VALUE env_each_i (VALUE ehash, int values)
VALUE env_each (VALUE ehash)
VALUE env_each_pair (VALUE ehash)
VALUE env_reject_bang ()
VALUE env_delete_if ()
VALUE env_values_at (int argc, VALUE *argv)
VALUE env_select (int argc, VALUE *argv)
VALUE env_clear ()
VALUE env_to_s ()
VALUE env_inspect ()
VALUE env_to_a ()
VALUE env_none ()
VALUE env_size ()
VALUE env_empty_p ()
VALUE env_has_key (VALUE env, VALUE key)
VALUE env_has_value (VALUE dmy, VALUE value)
VALUE env_index (VALUE dmy, VALUE value)
VALUE env_indexes (int argc, VALUE *argv)
VALUE env_to_hash ()
VALUE env_reject ()
VALUE env_shift ()
VALUE env_invert ()
int env_replace_i (VALUE key, VALUE val, VALUE keys)
VALUE env_replace (VALUE env, VALUE hash)
int env_update_i (VALUE key, VALUE val)
VALUE env_update (VALUE env, VALUE hash)
void Init_Hash ()

Variables

VALUE rb_cHash
VALUE envtbl
ID id_hash
ID id_call
ID id_default
st_hash_type objhash
int path_tainted = -1
char ** origenviron
char ** environ


Define Documentation

#define FREE_ENVIRON  ) 
 

Definition at line 1625 of file hash.c.

Referenced by env_each_i(), env_empty_p(), env_has_value(), env_index(), env_inspect(), env_keys(), env_select(), env_shift(), env_size(), env_to_a(), env_to_hash(), env_values(), and envix().

#define GET_ENVIRON  )     (e)
 

Definition at line 1624 of file hash.c.

Referenced by env_each_i(), env_empty_p(), env_has_value(), env_index(), env_inspect(), env_keys(), env_select(), env_shift(), env_size(), env_to_a(), env_to_hash(), env_values(), and envix().

#define HASH_DELETED   FL_USER1
 

Definition at line 24 of file hash.c.

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

#define HASH_PROC_DEFAULT   FL_USER2
 

Definition at line 25 of file hash.c.

Referenced by hash_equal(), rb_hash_default(), rb_hash_default_proc(), rb_hash_initialize(), rb_hash_replace(), rb_hash_set_default(), and rb_hash_shift().


Function Documentation

int clear_i VALUE  key,
VALUE  value,
VALUE  dummy
[static]
 

Definition at line 862 of file hash.c.

References ST_DELETE, and VALUE.

Referenced by rb_hash_clear().

int delete_if_i VALUE  key,
VALUE  value,
VALUE  hash
[static]
 

Definition at line 730 of file hash.c.

References Qundef, rb_hash_delete(), rb_yield_values(), RTEST, ST_CONTINUE, and VALUE.

Referenced by rb_hash_delete_if().

int each_i VALUE  key,
VALUE  value
[static]
 

Definition at line 1105 of file hash.c.

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

Referenced by rb_hash_each().

int each_key_i VALUE  key,
VALUE  value
[static]
 

Definition at line 1039 of file hash.c.

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

Referenced by rb_hash_each_key().

int each_pair_i VALUE  key,
VALUE  value
[static]
 

Definition at line 1071 of file hash.c.

References Qundef, rb_yield_values(), ST_CONTINUE, and VALUE.

Referenced by rb_hash_each_pair().

int each_value_i VALUE  key,
VALUE  value
[static]
 

Definition at line 1006 of file hash.c.

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

Referenced by rb_hash_each_value().

VALUE env_aset VALUE  obj,
VALUE  nm,
VALUE  val
[static]
 

Definition at line 1881 of file hash.c.

References env_delete(), name, NIL_P, OBJ_TAINTED, PATH_ENV, path_tainted, path_tainted_p(), Qnil, rb_eArgError, rb_eSecurityError, rb_raise(), rb_safe_level, RSTRING, ruby_setenv(), strcasecmp(), StringValue, and VALUE.

Referenced by env_replace_i(), env_update_i(), and Init_Hash().

VALUE env_clear  )  [static]
 

Definition at line 2104 of file hash.c.

References env_delete(), env_keys(), envtbl, NIL_P, Qnil, RARRAY, rb_f_getenv(), rb_secure(), and VALUE.

Referenced by Init_Hash().

VALUE env_delete VALUE  obj,
VALUE  name
[static]
 

Definition at line 1648 of file hash.c.

References env_str_new2(), getenv(), name, PATH_ENV, path_tainted, Qnil, rb_eArgError, rb_raise(), rb_secure(), RSTRING, ruby_setenv(), SafeStringValue, strcasecmp(), and VALUE.

Referenced by env_aset(), env_clear(), env_delete_m(), env_reject_bang(), env_replace(), and env_shift().

VALUE env_delete_if  )  [static]
 

Definition at line 2054 of file hash.c.

References env_reject_bang(), and envtbl.

Referenced by Init_Hash().

VALUE env_delete_m VALUE  obj,
VALUE  name
[static]
 

Definition at line 1678 of file hash.c.

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

Referenced by Init_Hash().

VALUE env_each VALUE  ehash  )  [static]
 

Definition at line 2016 of file hash.c.

References env_each_i(), Qfalse, and VALUE.

Referenced by Init_Hash().

VALUE env_each_i VALUE  ehash,
int  values
[static]
 

Definition at line 1985 of file hash.c.

References env_str_new(), env_str_new2(), environ, FREE_ENVIRON, GET_ENVIRON, RARRAY, rb_ary_new(), rb_ary_push(), rb_assoc_new(), rb_yield(), rb_yield_values(), strchr(), and VALUE.

Referenced by env_each(), and env_each_pair().

VALUE env_each_key VALUE  ehash  )  [static]
 

Definition at line 1941 of file hash.c.

References env_keys(), RARRAY, rb_yield(), and VALUE.

Referenced by Init_Hash().

VALUE env_each_pair VALUE  ehash  )  [static]
 

Definition at line 2023 of file hash.c.

References env_each_i(), Qtrue, and VALUE.

Referenced by Init_Hash().

VALUE env_each_value VALUE  ehash  )  [static]
 

Definition at line 1972 of file hash.c.

References env_values(), RARRAY, rb_yield(), and VALUE.

Referenced by Init_Hash().

VALUE env_empty_p  )  [static]
 

Definition at line 2196 of file hash.c.

References environ, FREE_ENVIRON, GET_ENVIRON, Qfalse, and Qtrue.

Referenced by Init_Hash().

VALUE env_fetch int  argc,
VALUE argv
[static]
 

Definition at line 1718 of file hash.c.

References env_str_new2(), getenv(), PATH_ENV, rb_block_given_p(), rb_eArgError, rb_eIndexError, rb_env_path_tainted(), rb_raise(), rb_scan_args(), rb_str_new2(), rb_warn(), rb_yield(), RSTRING, strcasecmp(), StringValue, and VALUE.

Referenced by Init_Hash().

VALUE env_has_key VALUE  env,
VALUE  key
[static]
 

Definition at line 2210 of file hash.c.

References getenv(), Qfalse, Qtrue, rb_eArgError, rb_raise(), RSTRING, StringValuePtr, and VALUE.

Referenced by Init_Hash().

VALUE env_has_value VALUE  dmy,
VALUE  value
[static]
 

Definition at line 2223 of file hash.c.

References environ, FREE_ENVIRON, GET_ENVIRON, Qfalse, Qtrue, RSTRING, strchr(), T_STRING, TYPE, and VALUE.

Referenced by Init_Hash().

VALUE env_index VALUE  dmy,
VALUE  value
[static]
 

Definition at line 2246 of file hash.c.

References env_str_new(), environ, FREE_ENVIRON, GET_ENVIRON, Qnil, RSTRING, strchr(), StringValue, and VALUE.

Referenced by Init_Hash().

VALUE env_indexes int  argc,
VALUE argv
[static]
 

Definition at line 2271 of file hash.c.

References env_str_new2(), getenv(), NIL_P, Qnil, RARRAY, rb_ary_new2(), rb_check_string_type(), rb_frame_last_func(), rb_id2name(), rb_warn(), RSTRING, and VALUE.

Referenced by Init_Hash().

VALUE env_inspect  )  [static]
 

Definition at line 2128 of file hash.c.

References environ, FREE_ENVIRON, GET_ENVIRON, OBJ_TAINT, rb_inspect(), rb_str_buf_append(), rb_str_buf_cat(), rb_str_buf_cat2(), rb_str_buf_new2(), rb_str_new2(), strchr(), and VALUE.

Referenced by Init_Hash().

VALUE env_invert  )  [static]
 

Definition at line 2339 of file hash.c.

References env_to_hash(), and rb_hash_invert().

Referenced by Init_Hash().

VALUE env_keys  )  [static]
 

Definition at line 1923 of file hash.c.

References env_str_new(), environ, FREE_ENVIRON, GET_ENVIRON, rb_ary_new(), rb_ary_push(), strchr(), and VALUE.

Referenced by env_clear(), env_each_key(), env_reject_bang(), env_replace(), and Init_Hash().

VALUE env_none  )  [static]
 

Definition at line 2177 of file hash.c.

References Qnil.

Referenced by Init_Hash().

VALUE env_reject  )  [static]
 

Definition at line 2314 of file hash.c.

References env_to_hash(), and rb_hash_delete_if().

Referenced by Init_Hash().

VALUE env_reject_bang  )  [static]
 

Definition at line 2030 of file hash.c.

References env_delete(), env_keys(), envtbl, FL_TAINT, FL_UNSET, NIL_P, Qnil, RARRAY, rb_f_getenv(), rb_secure(), rb_yield_values(), RTEST, and VALUE.

Referenced by env_delete_if(), and Init_Hash().

VALUE env_replace VALUE  env,
VALUE  hash
[static]
 

Definition at line 2358 of file hash.c.

References env_delete(), env_keys(), env_replace_i(), RARRAY, rb_hash_foreach(), to_hash(), and VALUE.

Referenced by Init_Hash().

int env_replace_i VALUE  key,
VALUE  val,
VALUE  keys
[static]
 

Definition at line 2345 of file hash.c.

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

Referenced by env_replace().

VALUE env_select int  argc,
VALUE argv
[static]
 

Definition at line 2075 of file hash.c.

References env_str_new(), env_str_new2(), environ, FREE_ENVIRON, GET_ENVIRON, rb_ary_new(), rb_ary_push(), rb_assoc_new(), rb_eArgError, rb_raise(), rb_yield_values(), RTEST, strchr(), and VALUE.

Referenced by Init_Hash().

VALUE env_shift  )  [static]
 

Definition at line 2320 of file hash.c.

References env_delete(), env_str_new(), env_str_new2(), environ, FREE_ENVIRON, GET_ENVIRON, getenv(), Qnil, rb_assoc_new(), RSTRING, strchr(), and VALUE.

Referenced by Init_Hash().

VALUE env_size  )  [static]
 

Definition at line 2183 of file hash.c.

References environ, FREE_ENVIRON, GET_ENVIRON, and INT2FIX.

Referenced by Init_Hash().

VALUE env_str_new char *  ptr,
long  len
const [static]
 

Definition at line 1629 of file hash.c.

References rb_obj_freeze(), rb_tainted_str_new(), and VALUE.

Referenced by env_each_i(), env_index(), env_keys(), env_select(), env_shift(), env_str_new2(), env_to_a(), and env_to_hash().

VALUE env_str_new2 char *  ptr  )  const [static]
 

Definition at line 1640 of file hash.c.

References env_str_new(), and Qnil.

Referenced by env_delete(), env_each_i(), env_fetch(), env_indexes(), env_select(), env_shift(), env_to_a(), env_to_hash(), env_values(), and rb_f_getenv().

VALUE env_to_a  )  [static]
 

Definition at line 2158 of file hash.c.

References env_str_new(), env_str_new2(), environ, FREE_ENVIRON, GET_ENVIRON, rb_ary_new(), rb_ary_push(), rb_assoc_new(), strchr(), and VALUE.

Referenced by Init_Hash().

VALUE env_to_hash  )  [static]
 

Definition at line 2295 of file hash.c.

References env_str_new(), env_str_new2(), environ, FREE_ENVIRON, GET_ENVIRON, rb_hash_aset(), rb_hash_new(), strchr(), and VALUE.

Referenced by env_invert(), env_reject(), and Init_Hash().

VALUE env_to_s  )  [static]
 

Definition at line 2122 of file hash.c.

References rb_str_new2().

Referenced by Init_Hash().

VALUE env_update VALUE  env,
VALUE  hash
[static]
 

Definition at line 2388 of file hash.c.

References env_update_i(), rb_hash_foreach(), to_hash(), and VALUE.

Referenced by Init_Hash().

int env_update_i VALUE  key,
VALUE  val
[static]
 

Definition at line 2375 of file hash.c.

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

Referenced by env_update().

VALUE env_values  )  [static]
 

Definition at line 1954 of file hash.c.

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

Referenced by env_each_value(), and Init_Hash().

VALUE env_values_at int  argc,
VALUE argv
[static]
 

Definition at line 2061 of file hash.c.

References Qnil, rb_ary_new(), rb_ary_push(), rb_f_getenv(), and VALUE.

Referenced by Init_Hash().

int envix char *  nam  )  const [static]
 

Definition at line 1770 of file hash.c.

References environ, FREE_ENVIRON, GET_ENVIRON, and strncasecmp().

Referenced by ruby_setenv().

VALUE eql VALUE args  )  [static]
 

Definition at line 50 of file hash.c.

References args, rb_eql(), and VALUE.

Referenced by hash_equal(), and rb_any_cmp().

int equal_i VALUE  key,
VALUE  val1,
struct equal_data data
[static]
 

Definition at line 1428 of file hash.c.

References Qfalse, Qundef, rb_equal(), ST_CONTINUE, st_lookup(), ST_STOP, and VALUE.

Referenced by hash_equal().

int foreach_safe_i st_data_t  key,
st_data_t  value,
struct foreach_safe_arg arg
[static]
 

Definition at line 124 of file hash.c.

References Qundef, ST_CHECK, ST_CONTINUE, and st_data_t.

Referenced by st_foreach_safe().

VALUE hash_alloc VALUE   )  [static]
 

Definition at line 228 of file hash.c.

References NEWOBJ, objhash, OBJSETUP, Qnil, st_init_table(), T_HASH, and VALUE.

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

VALUE hash_equal VALUE  hash1,
VALUE  hash2,
int  eql
[static]
 

Definition at line 1447 of file hash.c.

References eql(), equal_i(), FL_TEST, HASH_PROC_DEFAULT, Qfalse, Qtrue, rb_equal(), rb_hash_foreach(), rb_intern(), rb_respond_to(), equal_data::result, RHASH, st_data_t, T_HASH, equal_data::tbl, TYPE, and VALUE.

Referenced by rb_hash_equal().

VALUE hash_foreach_call struct hash_foreach_arg arg  )  [static]
 

Definition at line 202 of file hash.c.

References hash_foreach_iter(), Qnil, rb_eRuntimeError, rb_raise(), RHASH, st_data_t, and st_foreach().

Referenced by rb_hash_foreach().