23 # ifdef HAVE_CRT_EXTERNS_H 32 #define HASH_DELETED FL_USER1 33 #define HASH_PROC_DEFAULT FL_USER2 110 #define identhash st_hashtype_num 162 if (
RHASH(
arg->hash)->ntbl != tbl) {
288 #define NOINSERT_UPDATE_CALLBACK(func) \ 290 func##_noinsert(st_data_t *key, st_data_t *val, st_data_t arg, int existing) \ 292 if (!existing) no_new_key(); \ 293 return func(key, val, arg, existing); \ 296 #define UPDATE_CALLBACK(iter_lev, func) ((iter_lev) > 0 ? func##_noinsert : func) 298 #define RHASH_UPDATE_ITER(hash, iter_lev, key, func, arg) \ 299 st_update(RHASH(hash)->ntbl, (st_data_t)(key), \ 300 UPDATE_CALLBACK((iter_lev), func), \ 302 #define RHASH_UPDATE(hash, key, func, arg) \ 303 RHASH_UPDATE_ITER(hash, RHASH_ITER_LEV(hash), key, func, arg) 399 if (
RHASH(tmp)->ntbl) {
421 rb_warn(
"wrong element type %s at %ld (expected array)",
423 rb_warn(
"ignoring wrong elements is deprecated, remove them explicitly");
424 rb_warn(
"this causes ArgumentError in the next release");
531 RHASH(tmp)->ntbl = tbl;
536 RHASH(tmp)->ntbl = 0;
636 if (block_given &&
argc == 2) {
637 rb_warn(
"block supersedes default value argument");
775 "wrong default_proc type %s (expected Proc)",
828 rb_warn(
"Hash#index is deprecated; use Hash#key");
1153 if (
RHASH(
hash)->ntbl->num_entries > 0) {
1246 if (
RHASH(hash2)->ntbl) {
1286 if (
RHASH(hash2)->ntbl) {
1729 if (hash1 == hash2)
return Qtrue;
1735 return rb_eql(hash2, hash1);
1741 if (!
RHASH(hash1)->ntbl || !
RHASH(hash2)->ntbl)
1743 if (
RHASH(hash1)->ntbl->type !=
RHASH(hash2)->ntbl->type)
1803 *hval ^=
st_hash(hdata,
sizeof(hdata), 0);
2166 #define GET_ENVIRON(e) ((e) = rb_w32_get_environ()) 2167 #define FREE_ENVIRON(e) rb_w32_free_environ(e) 2168 static char **my_environ;
2170 #define environ my_environ 2172 #define getenv(n) rb_w32_ugetenv(n) 2173 #elif defined(__APPLE__) 2175 #define environ (*_NSGetEnviron()) 2176 #define GET_ENVIRON(e) (e) 2177 #define FREE_ENVIRON(e) 2180 #define GET_ENVIRON(e) (e) 2181 #define FREE_ENVIRON(e) 2183 #ifdef ENV_IGNORECASE 2184 #define ENVMATCH(s1, s2) (STRCASECMP((s1), (s2)) == 0) 2185 #define ENVNMATCH(s1, s2, n) (STRNCASECMP((s1), (s2), (n)) == 0) 2187 #define ENVMATCH(n1, n2) (strcmp((n1), (n2)) == 0) 2188 #define ENVNMATCH(s1, s2, n) (memcmp((s1), (s2), (n)) == 0) 2207 if (!ptr)
return Qnil;
2315 if (block_given &&
argc == 2) {
2316 rb_warn(
"block supersedes default value argument");
2364 #if defined(_WIN32) || (defined(HAVE_SETENV) && defined(HAVE_UNSETENV)) 2367 in_origenv(
const char *str)
2371 if (*
env == str)
return 1;
2379 register int i, len =
strlen(nam);
2383 for (
i = 0;
env[
i];
i++) {
2394 getenvsize(
const char*
p)
2396 const char* porg =
p;
2398 return p - porg + 1;
2419 char*
p = GetEnvironmentStringsA();
2423 FreeEnvironmentStringsA(
p);
2424 if (n >= getenvblocksize()) {
2438 if (!SetEnvironmentVariable(
name,
value) &&
2439 GetLastError() != ERROR_ENVVAR_NOT_FOUND)
goto fail;
2441 if (failed)
goto fail;
2442 #elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV) 2449 #ifdef VOID_UNSETENV 2458 char **env_ptr, *str;
2465 if (!strncmp(str,
name, len) && str[len] ==
'=') {
2466 if (!in_origenv(str))
free(str);
2467 while ((env_ptr[0] = env_ptr[1]) != 0) env_ptr++;
2493 for (j=0; j<
max; j++)
2500 while (*envp && *envp !=
environ[
i]) envp++;
2740 volatile VALUE keys;
2757 if (del == 0)
return Qnil;
2842 volatile VALUE keys;
2859 if (del == 0)
return Qnil;
2889 volatile VALUE keys;
3187 rb_warn(
"ENV.index is deprecated; use ENV.key");
3295 volatile VALUE keys;
3456 #define rb_intern(str) rb_intern_const(str) RUBY_EXTERN VALUE rb_cString
void rb_define_global_const(const char *, VALUE)
#define RHASH_UPDATE(hash, key, func, arg)
static VALUE empty_hash_alloc(VALUE klass)
const char * rb_builtin_class_name(VALUE x)
static VALUE hash_foreach_call(VALUE arg)
static int rb_hash_invert_i(VALUE key, VALUE value, VALUE hash)
static int each_pair_i(VALUE key, VALUE value)
static int rb_hash_update_callback(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
static VALUE env_each_value(VALUE ehash)
void rb_enc_copy(VALUE obj1, VALUE obj2)
static VALUE rb_hash_each_value(VALUE hash)
static VALUE env_delete_m(VALUE obj, VALUE name)
size_t strlen(const char *)
rb_hash_update_func * func
static VALUE rb_hash_has_value(VALUE hash, VALUE val)
static int hash_aset_str(st_data_t *key, st_data_t *val, st_data_t arg, int existing)
static void path_tainted_p(const char *path)
static int replace_i(VALUE key, VALUE val, VALUE hash)
VALUE rb_hash_dup(VALUE hash)
static VALUE rb_hash_s_try_convert(VALUE, VALUE)
static int envix(const char *nam)
VALUE rb_yield_values(int n,...)
static int max(int a, int b)
static int keep_if_i(VALUE key, VALUE value, VALUE hash)
static void no_new_key(void)
static int rb_hash_update_block_callback(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
VALUE rb_exec_recursive_outer(VALUE(*)(VALUE, VALUE, int), VALUE, VALUE)
static int env_update_i(VALUE key, VALUE val)
static VALUE rb_hash_size(VALUE hash)
static VALUE rb_hash_empty_p(VALUE hash)
#define RHASH_ITER_LEV(h)
static VALUE env_invert(void)
static VALUE rb_hash_default(int argc, VALUE *argv, VALUE hash)
int st_insert(st_table *, st_data_t, st_data_t)
static void rb_hash_modify(VALUE hash)
static VALUE env_str_new2(const char *ptr)
st_index_t rb_hash_end(st_index_t)
VALUE rb_hash_select_bang(VALUE hash)
static int keys_i(VALUE key, VALUE value, VALUE ary)
static VALUE env_to_s(void)
int rb_env_path_tainted(void)
static VALUE env_keys(void)
static VALUE env_delete_if(VALUE ehash)
#define HASH_PROC_DEFAULT
static VALUE env_shift(void)
VALUE rb_ary_push(VALUE ary, VALUE item)
static int eql_i(VALUE key, VALUE val1, VALUE arg)
VALUE rb_str_buf_new2(const char *)
SSL_METHOD *(* func)(void)
void st_free_table(st_table *)
static VALUE env_each_pair(VALUE ehash)
VALUE rb_hash_update_by(VALUE hash1, VALUE hash2, rb_hash_update_func *func)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
struct st_table * rb_hash_tbl(VALUE hash)
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *state)
static int assoc_i(VALUE key, VALUE val, VALUE arg)
void rb_raise(VALUE exc, const char *fmt,...)
static VALUE rb_hash_shift(VALUE hash)
static VALUE inspect_hash(VALUE hash, VALUE dummy, int recur)
VALUE rb_convert_type(VALUE, int, const char *, const char *)
VALUE rb_exec_recursive(VALUE(*)(VALUE, VALUE, int), VALUE, VALUE)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
static VALUE rb_hash_equal(VALUE hash1, VALUE hash2)
VALUE rb_tainted_str_new2(const char *)
st_index_t rb_str_hash(VALUE)
#define ENVNMATCH(s1, s2, n)
static int hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp)
void rb_include_module(VALUE klass, VALUE module)
static int env_path_tainted(const char *)
VALUE rb_hash_lookup(VALUE hash, VALUE key)
static int values_i(VALUE key, VALUE value, VALUE ary)
#define RHASH_UPDATE_ITER(hash, iter_lev, key, func, arg)
static VALUE env_keep_if(VALUE ehash)
VALUE rb_hash_fetch(VALUE hash, VALUE key)
static VALUE rb_hash_each_key(VALUE hash)
rb_encoding * rb_utf8_encoding(void)
static int rb_hash_search_value(VALUE key, VALUE value, VALUE arg)
VALUE rb_str_buf_append(VALUE, VALUE)
static VALUE rb_hash_replace(VALUE hash, VALUE hash2)
static int shift_i(VALUE key, VALUE value, VALUE arg)
#define NOINSERT_UPDATE_CALLBACK(func)
const char * rb_obj_classname(VALUE)
static VALUE rb_hash_fetch_m(int argc, VALUE *argv, VALUE hash)
static VALUE env_rassoc(VALUE dmy, VALUE obj)
static VALUE env_each_key(VALUE ehash)
VALUE rb_str_buf_cat(VALUE, const char *, long)
#define NEWOBJ_OF(obj, type, klass, flags)
void rb_hash_foreach(VALUE hash, int(*func)(ANYARGS), VALUE farg)
#define RB_TYPE_P(obj, type)
const struct st_hash_type st_hashtype_num
int st_lookup(st_table *, st_data_t, st_data_t *)
static int rb_hash_rehash_i(VALUE key, VALUE value, VALUE arg)
static VALUE env_key(VALUE dmy, VALUE value)
int rb_block_given_p(void)
static VALUE rb_hash_reject(VALUE hash)
static VALUE env_assoc(VALUE env, VALUE key)
static VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc)
VALUE rb_hash_reject_bang(VALUE hash)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_exec_recursive_paired(VALUE(*)(VALUE, VALUE, int), VALUE, VALUE, VALUE)
static VALUE env_select_bang(VALUE ehash)
static VALUE rb_hash_initialize_copy(VALUE hash, VALUE hash2)
char * ruby_strdup(const char *)
static int hash_i(VALUE key, VALUE val, VALUE arg)
static VALUE rb_env_size(VALUE ehash)
VALUE rb_str_buf_cat2(VALUE, const char *)
static int each_value_i(VALUE key, VALUE value)
VALUE rb_locale_str_new(const char *, long)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
static VALUE rb_hash_eql(VALUE hash1, VALUE hash2)
static VALUE env_delete(VALUE obj, VALUE name)
int st_delete(st_table *, st_data_t *, st_data_t *)
rb_atomic_t cnt[RUBY_NSIG]
VALUE rb_hash_update_func(VALUE newkey, VALUE oldkey, VALUE value)
int rb_foreach_func(VALUE, VALUE, VALUE)
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
static VALUE rb_hash_to_h(VALUE hash)
static VALUE env_reject(void)
static VALUE rb_hash_each_pair(VALUE hash)
static VALUE rb_hash_values(VALUE hash)
static const struct st_hash_type objhash
static int rb_any_cmp(VALUE a, VALUE b)
VALUE rb_obj_alloc(VALUE)
#define RBIGNUM_DIGITS(b)
static VALUE rb_hash_to_hash(VALUE hash)
static VALUE env_replace(VALUE env, VALUE hash)
VALUE rb_str_resize(VALUE, long)
static VALUE rb_hash_set_default(VALUE hash, VALUE ifnone)
int rb_str_hash_cmp(VALUE, VALUE)
void st_foreach_safe(st_table *table, int(*func)(ANYARGS), st_data_t a)
static void rb_hash_modify_check(VALUE hash)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
static VALUE rb_hash_s_create(int argc, VALUE *argv, VALUE klass)
static char ** origenviron
static int select_i(VALUE key, VALUE value, VALUE result)
static VALUE rb_hash_index(VALUE hash, VALUE value)
static VALUE env_index(VALUE dmy, VALUE value)
static VALUE rb_f_getenv(VALUE obj, VALUE name)
#define REALLOC_N(var, type, n)
static VALUE hash_foreach_ensure(VALUE hash)
VALUE rb_obj_is_proc(VALUE)
static VALUE env_inspect(void)
VALUE rb_funcall2(VALUE, ID, int, const VALUE *)
Calls a method.
VALUE rb_sprintf(const char *format,...)
static VALUE rb_hash_update(VALUE hash1, VALUE hash2)
VALUE rb_hash_delete(VALUE hash, VALUE key)
static VALUE rb_hash_key(VALUE hash, VALUE value)
VALUE rb_ary_delete(VALUE ary, VALUE item)
VALUE rb_hash_assoc(VALUE hash, VALUE obj)
static VALUE env_has_key(VALUE env, VALUE key)
#define unsetenv(name, val)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
VALUE rb_check_hash_type(VALUE hash)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_assoc_new(VALUE car, VALUE cdr)
static VALUE rb_hash_compare_by_id_p(VALUE hash)
rb_encoding * rb_locale_encoding(void)
VALUE rb_hash_clear(VALUE hash)
static VALUE env_values(void)
#define RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn)
static int clear_i(VALUE key, VALUE value, VALUE dummy)
VALUE rb_hash_keep_if(VALUE hash)
static VALUE hash_alloc(VALUE klass)
char * strchr(char *, char)
void rb_extend_object(VALUE obj, VALUE module)
#define setenv(name, val)
static VALUE env_aset(VALUE obj, VALUE nm, VALUE val)
static VALUE env_to_a(void)
static VALUE hash_equal(VALUE hash1, VALUE hash2, int eql)
static VALUE rb_hash_flatten(int argc, VALUE *argv, VALUE hash)
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
VALUE rb_str_ellipsize(VALUE, long)
Shortens str and adds three dots, an ellipsis, if it is longer than len characters.
VALUE rb_proc_lambda_p(VALUE)
static int each_key_i(VALUE key, VALUE value)
void ruby_unsetenv(const char *name)
void rb_sys_fail(const char *mesg)
static VALUE env_select(VALUE ehash)
VALUE rb_hash_freeze(VALUE hash)
#define RUBY_DTRACE_HASH_CREATE_ENABLED()
NORETURN(static void no_new_key(void))
int rb_respond_to(VALUE, ID)
st_index_t st_hash(const void *ptr, size_t len, st_index_t h)
static VALUE env_none(void)
static VALUE env_size(void)
static int delete_if_i(VALUE key, VALUE value, VALUE hash)
static VALUE rb_hash_keys(VALUE hash)
VALUE rb_usascii_str_new2(const char *)
st_table * st_init_table_with_size(const struct st_hash_type *, st_index_t)
VALUE rb_equal(VALUE, VALUE)
static int inspect_i(VALUE key, VALUE value, VALUE str)
static VALUE rb_hash_compare_by_id(VALUE hash)
VALUE rb_hash_lookup2(VALUE hash, VALUE key, VALUE def)
static VALUE to_hash(VALUE hash)
#define rb_check_arity(argc, min, max)
static int hash_aset(st_data_t *key, st_data_t *val, st_data_t arg, int existing)
int rb_path_check(const char *path)
VALUE rb_check_convert_type(VALUE, int, const char *, const char *)
VALUE rb_block_proc(void)
VALUE rb_str_buf_cat_ascii(VALUE, const char *)
static VALUE env_to_hash(void)
static VALUE rb_hash_has_key(VALUE hash, VALUE key)
VALUE rb_check_array_type(VALUE ary)
VALUE rb_hash_aref(VALUE hash, VALUE key)
static VALUE hash_default_value(VALUE hash, VALUE key)
static VALUE env_values_at(int argc, VALUE *argv)
VALUE rb_check_string_type(VALUE)
VALUE rb_ary_includes(VALUE ary, VALUE item)
static int shift_i_safe(VALUE key, VALUE value, VALUE arg)
static st_index_t rb_any_hash(VALUE a)
void rb_check_safe_obj(VALUE)
int st_foreach_check(st_table *, int(*)(ANYARGS), st_data_t, st_data_t)
st_index_t rb_hash_uint(st_index_t, st_index_t)
static VALUE rb_hash_invert(VALUE hash)
rb_encoding * rb_filesystem_encoding(void)
int rb_method_basic_definition_p(VALUE, ID)
static int foreach_safe_i(st_data_t key, st_data_t value, struct foreach_safe_arg *arg)
static VALUE rb_hash_hash(VALUE hash)
static VALUE recursive_eql(VALUE hash, VALUE dt, int recur)
const struct st_hash_type * type
static unsigned int hash(const char *str, unsigned int len)
static int rassoc_i(VALUE key, VALUE val, VALUE arg)
#define SafeStringValue(v)
VALUE rb_ary_new2(long capa)
VALUE rb_filesystem_str_new_cstr(const char *)
static VALUE rb_hash_merge(VALUE hash1, VALUE hash2)
void st_cleanup_safe(st_table *, st_data_t)
static int rb_hash_update_func_callback(st_data_t *key, st_data_t *value, st_data_t arg0, int existing)
static VALUE recursive_hash(VALUE hash, VALUE dummy, int recur)
VALUE rb_hash_values_at(int argc, VALUE *argv, VALUE hash)
VALUE rb_str_new_frozen(VALUE)
st_table * st_copy(st_table *)
static int key_i(VALUE key, VALUE value, VALUE arg)
static VALUE rb_hash_rehash(VALUE hash)
int st_foreach_func(st_data_t, st_data_t, st_data_t)
static int env_replace_i(VALUE key, VALUE val, VALUE keys)
void st_clear(st_table *)
VALUE rb_hash_delete_if(VALUE hash)
#define rb_check_frozen(obj)
static VALUE env_empty_p(void)
st_table * st_init_table(const struct st_hash_type *)
static int to_a_i(VALUE key, VALUE value, VALUE ary)
VALUE rb_obj_freeze(VALUE)
void rb_copy_generic_ivar(VALUE, VALUE)
#define SPECIAL_CONST_P(x)
VALUE rb_tainted_str_new(const char *, long)
static VALUE env_reject_bang(VALUE ehash)
static VALUE env_fetch(int argc, VALUE *argv)
VALUE rb_hash_aset(VALUE, VALUE, VALUE)
VALUE rb_hash_select(VALUE hash)
static VALUE env_has_value(VALUE dmy, VALUE obj)
static VALUE env_update(VALUE env, VALUE hash)
int st_delete_safe(st_table *, st_data_t *, st_data_t *, st_data_t)
static VALUE rb_hash_delete_key(VALUE hash, VALUE key)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
void ruby_setenv(const char *name, const char *value)
VALUE rb_str_new2(const char *)
void rb_warn(const char *fmt,...)
static void default_proc_arity_check(VALUE proc)
st_index_t rb_hash_start(st_index_t)
VALUE rb_hash_rassoc(VALUE hash, VALUE obj)
static VALUE rb_hash_to_a(VALUE hash)
static VALUE rb_hash_initialize(int argc, VALUE *argv, VALUE hash)
static VALUE env_str_new(const char *ptr, long len)
static VALUE rb_hash_default_proc(VALUE hash)
#define RUBY_DTRACE_HASH_CREATE(arg0, arg1, arg2)
static VALUE rb_hash_inspect(VALUE hash)
VALUE rb_str_new(const char *, long)
VALUE rb_obj_class(VALUE)