23 # ifdef HAVE_CRT_EXTERNS_H 30 #define HAS_EXTRA_STATES(hash, klass) ( \ 31 ((klass = has_extra_methods(rb_obj_class(hash))) != 0) || \ 32 FL_TEST((hash), FL_EXIVAR|FL_TAINT|HASH_PROC_DEFAULT) || \ 33 !NIL_P(RHASH_IFNONE(hash))) 35 #define SET_DEFAULT(hash, ifnone) ( \ 36 FL_UNSET_RAW(hash, HASH_PROC_DEFAULT), \ 37 RHASH_SET_IFNONE(hash, ifnone)) 39 #define SET_PROC_DEFAULT(hash, proc) set_proc_default(hash, proc) 41 #define COPY_DEFAULT(hash, hash2) copy_default(RHASH(hash), RHASH(hash2)) 102 if (a == b)
return 0;
121 if (recurse)
return INT2FIX(0);
136 ul &= (1UL << (
sizeof(long)*
CHAR_BIT-1)) - 1;
152 if (d == 0.0) d = 0.0;
153 #if SIZEOF_INT == SIZEOF_VOIDP 198 hnum = other_func(a);
202 return (
long)RSHIFT(hnum, 1);
230 #if defined(__GNUC__) && UINT_MAX != ULONG_MAX 231 __uint128_t r = (__uint128_t) m1 * (__uint128_t) m2;
234 uint64_t hm1 = m1 >> 32, hm2 = m2 >> 32;
237 uint64_t v32_96 = hm1 * lm2 + lm1 * hm2;
240 return (v64_128 + (v32_96 >> 32)) ^ ((v32_96 << 32) + v1_32);
280 #define rb_ident_cmp st_numcmp 319 status = (*arg->
func)(key, value, arg->
arg);
406 if (!
RHASH(hash)->ntbl)
476 if (!
RHASH(hash)->ntbl) {
479 return RHASH(hash)->ntbl;
514 #define NOINSERT_UPDATE_CALLBACK(func) \ 516 func##_noinsert(st_data_t *key, st_data_t *val, st_data_t arg, int existing) \ 518 if (!existing) no_new_key(); \ 519 return func(key, val, (struct update_arg *)arg, existing); \ 523 func##_insert(st_data_t *key, st_data_t *val, st_data_t arg, int existing) \ 525 return func(key, val, (struct update_arg *)arg, existing); \ 545 arg.
arg = optional_arg;
552 result =
st_update(
RHASH(hash)->ntbl, (st_data_t)key, func, (st_data_t)&arg);
556 if (arg.new_value)
RB_OBJ_WRITTEN(hash, arg.old_value, arg.new_value);
561 #define UPDATE_CALLBACK(iter_lev, func) ((iter_lev) > 0 ? func##_noinsert : func##_insert) 563 #define RHASH_UPDATE_ITER(h, iter_lev, key, func, a) do { \ 564 tbl_update((h), (key), UPDATE_CALLBACK((iter_lev), func), (st_data_t)(a)); \ 567 #define RHASH_UPDATE(hash, key, func, arg) \ 568 RHASH_UPDATE_ITER(hash, RHASH_ITER_LEV(hash), key, func, arg) 576 if (n != 2 && (n >= 0 || n < -3)) {
634 ifnone = argc == 0 ?
Qnil : argv[0];
671 if (
RHASH(tmp)->ntbl) {
693 rb_warn(
"wrong element type %s at %ld (expected array)",
695 rb_warn(
"ignoring wrong elements is deprecated, remove them explicitly");
696 rb_warn(
"this causes ArgumentError in the next release");
722 for (i=0; i<
argc; i+=2) {
768 st_insert(tbl, (st_data_t)key, (st_data_t)value);
802 if (!
RHASH(hash)->ntbl)
806 RHASH(tmp)->ntbl = tbl;
810 RHASH(hash)->ntbl = tbl;
811 RHASH(tmp)->ntbl = 0;
912 if (block_given && argc == 2) {
913 rb_warn(
"block supersedes default value argument");
916 if (block_given)
return rb_yield(key);
960 VALUE args[2], ifnone;
965 if (argc == 0)
return Qnil;
1051 "wrong default_proc type %s (expected Proc)",
1102 rb_warn(
"Hash#index is deprecated; use Hash#key");
1116 if (!
RHASH(hash)->ntbl) {
1142 if (deleted_value !=
Qundef) {
1143 return deleted_value;
1223 if (
RHASH(hash)->ntbl) {
1276 if (
RHASH(hash)->ntbl)
1298 if (!n)
return Qnil;
1300 if (n ==
RHASH(hash)->ntbl->num_entries)
return Qnil;
1363 for (i=0; i<
argc; i++) {
1391 for (i=0; i<
argc; i++) {
1458 if (!
RHASH(hash)->ntbl)
1460 n =
RHASH(hash)->ntbl->num_entries;
1462 if (n ==
RHASH(hash)->ntbl->num_entries)
return Qnil;
1483 if (
RHASH(hash)->ntbl)
1509 if (!
RHASH(hash)->ntbl)
1511 if (
RHASH(hash)->ntbl->num_entries > 0) {
1542 return hash_aset(key, val, arg, existing);
1614 if (hash == hash2)
return hash;
1616 ntbl =
RHASH(hash)->ntbl;
1617 if (
RHASH(hash2)->ntbl) {
1650 if (hash == hash2)
return hash;
1655 table2 =
RHASH(hash2)->ntbl;
1876 if (
RHASH(hash)->ntbl)
2023 if (size == 0)
return keys;
2067 if (size == 0)
return values;
2107 if (!
RHASH(hash)->ntbl)
2179 if (recur)
return Qtrue;
2192 if (hash1 == hash2)
return Qtrue;
2198 if (
rb_eql(hash2, hash1)) {
2211 if (!
RHASH(hash1)->ntbl || !
RHASH(hash2)->ntbl)
2213 if (
RHASH(hash1)->ntbl->type !=
RHASH(hash2)->ntbl->type)
2280 *hval ^=
st_hash(hdata,
sizeof(hdata), 0);
2580 table =
RHASH(hash)->ntbl;
2581 orighash = table->
type;
2583 if (orighash != &identhash) {
2590 table->
type = &assochash;
2680 if (level - 1 > 0) {
2684 else if (level < 0) {
2708 if (!
NIL_P(value)) {
2752 if (
RHASH(hash)->ntbl) {
2755 if (n !=
RHASH(hash)->ntbl->num_entries)
2799 if (!
RHASH(hash)->ntbl)
2801 if (
RHASH(hash)->ntbl->type == &identhash) {
2897 if (!--argc)
return self;
3047 #define GET_ENVIRON(e) ((e) = rb_w32_get_environ()) 3048 #define FREE_ENVIRON(e) rb_w32_free_environ(e) 3049 static char **my_environ;
3051 #define environ my_environ 3053 static char *(*w32_getenv)(
const char*);
3055 w32_getenv_unknown(
const char *
name)
3057 char *(*func)(
const char*);
3067 static char *(*w32_getenv)(
const char*) = w32_getenv_unknown;
3068 #define getenv(n) w32_getenv(n) 3069 #elif defined(__APPLE__) 3071 #define environ (*_NSGetEnviron()) 3072 #define GET_ENVIRON(e) (e) 3073 #define FREE_ENVIRON(e) 3076 #define GET_ENVIRON(e) (e) 3077 #define FREE_ENVIRON(e) 3079 #ifdef ENV_IGNORECASE 3080 #define ENVMATCH(s1, s2) (STRCASECMP((s1), (s2)) == 0) 3081 #define ENVNMATCH(s1, s2, n) (STRNCASECMP((s1), (s2), (n)) == 0) 3083 #define ENVMATCH(n1, n2) (strcmp((n1), (n2)) == 0) 3084 #define ENVNMATCH(s1, s2, n) (memcmp((s1), (s2), (n)) == 0) 3125 if (!ptr)
return Qnil;
3151 volatile VALUE *pstr,
3179 #define get_env_ptr(var, val) \ 3180 (var = get_env_cstr(&(val), #var)) 3182 #define get_env_ptr(var, val) \ 3183 (var = get_env_cstr(val, #var)) 3186 static inline const char *
3195 #define env_name(s) env_name(&(s)) 3200 const char *nam, *
val;
3246 const char *nam, *
env;
3275 const char *nam, *
env;
3280 if (block_given && argc == 2) {
3281 rb_warn(
"block supersedes default value argument");
3286 if (block_given)
return rb_yield(key);
3304 if (path_tainted < 0) {
3313 if (path_tainted < 0) {
3319 #if defined(_WIN32) || (defined(HAVE_SETENV) && defined(HAVE_UNSETENV)) 3322 in_origenv(
const char *str)
3325 for (env = origenviron; *
env; ++
env) {
3326 if (*env == str)
return 1;
3338 for (i = 0; env[i]; i++) {
3339 if (
ENVNMATCH(env[i],nam,len) && env[i][len] ==
'=')
3349 getenvsize(
const WCHAR* p)
3351 const WCHAR* porg = p;
3352 while (*p++) p += lstrlenW(p) + 1;
3353 return p - porg + 1;
3356 getenvblocksize(
void)
3362 #if defined(_WIN32) || \ 3363 (defined(__sun) && !(defined(HAVE_SETENV) && defined(HAVE_UNSETENV))) 3365 NORETURN(
static void invalid_envname(
const char *
name));
3368 invalid_envname(
const char *name)
3374 check_envname(
const char *name)
3377 invalid_envname(name);
3387 # if defined(MINGW_HAS_SECURE_API) || RUBY_MSVCRT_VERSION >= 80 3388 # define HAVE__WPUTENV_S 1 3395 check_envname(name);
3396 len = MultiByteToWideChar(CP_UTF8, 0, name, -1,
NULL, 0);
3398 WCHAR* p = GetEnvironmentStringsW();
3402 n = lstrlen(name) + 2 +
strlen(value) + getenvsize(p);
3403 FreeEnvironmentStringsW(p);
3404 if (n >= getenvblocksize()) {
3407 len2 = MultiByteToWideChar(CP_UTF8, 0, value, -1,
NULL, 0);
3408 wname =
ALLOCV_N(WCHAR, buf, len + len2);
3409 wvalue = wname +
len;
3410 MultiByteToWideChar(CP_UTF8, 0, name, -1, wname, len);
3411 MultiByteToWideChar(CP_UTF8, 0, value, -1, wvalue, len2);
3412 #ifndef HAVE__WPUTENV_S 3413 wname[len-1] =
L'=';
3417 wname =
ALLOCV_N(WCHAR, buf, len + 1);
3418 MultiByteToWideChar(CP_UTF8, 0, name, -1, wname, len);
3419 wvalue = wname +
len;
3421 #ifndef HAVE__WPUTENV_S 3422 wname[len-1] =
L'=';
3425 #ifndef HAVE__WPUTENV_S 3426 failed = _wputenv(wname);
3428 failed = _wputenv_s(wname, wvalue);
3433 if (!value || !*value) {
3435 if (!SetEnvironmentVariable(name, value) &&
3436 GetLastError() != ERROR_ENVVAR_NOT_FOUND)
goto fail;
3440 invalid_envname(name);
3442 #elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV) 3444 if (setenv(name, value, 1))
3448 #ifdef VOID_UNSETENV 3460 size_t len, mem_size;
3461 char **env_ptr, *str, *mem_ptr;
3463 check_envname(name);
3466 mem_size = len +
strlen(value) + 2;
3467 mem_ptr =
malloc(mem_size);
3468 if (mem_ptr ==
NULL)
3470 snprintf(mem_ptr, mem_size,
"%s=%s", name, value);
3472 for (env_ptr =
GET_ENVIRON(environ); (str = *env_ptr) != 0; ++env_ptr) {
3473 if (!strncmp(str, name, len) && str[
len] ==
'=') {
3474 if (!in_origenv(str))
free(str);
3475 while ((env_ptr[0] = env_ptr[1]) != 0) env_ptr++;
3480 if (putenv(mem_ptr)) {
3491 if (environ == origenviron) {
3496 for (max = i; environ[
max]; max++) ;
3497 tmpenv =
ALLOC_N(
char*, max+2);
3498 for (j=0; j<
max; j++)
3505 while (*envp && *envp != environ[i]) envp++;
3509 while (environ[i]) {
3510 environ[i] = environ[i+1];
3522 environ[i] =
ALLOC_N(
char, len);
3523 snprintf(environ[i],len,
"%s=%s",name,value);
3589 char *s =
strchr(*env,
'=');
3653 char *s =
strchr(*env,
'=');
3709 char *s =
strchr(*env,
'=');
3761 if (del == 0)
return Qnil;
3796 for (i=0; i<
argc; i++) {
3863 if (del == 0)
return Qnil;
3934 char *s =
strchr(*env,
'=');
3936 if (env != environ) {
3973 char *s =
strchr(*env,
'=');
4011 for (i=0; env[i]; i++)
4091 char *s =
strchr(*env,
'=');
4122 char *s =
strchr(*env,
'=');
4153 char *s =
strchr(*env,
'=');
4177 rb_warn(
"ENV.index is deprecated; use ENV.key");
4198 char *s =
strchr(*env,
'=');
4238 char *s =
strchr(*env,
'=');
4287 if (env == hash)
return env;
4321 if (env == hash)
return env;
4444 #define rb_intern(str) rb_intern_const(str) RUBY_EXTERN VALUE rb_cString
void rb_define_global_const(const char *, VALUE)
#define RBASIC_CLEAR_CLASS(obj)
#define RHASH_UPDATE(hash, key, func, arg)
static VALUE empty_hash_alloc(VALUE klass)
#define SET_PROC_DEFAULT(hash, proc)
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 st_index_t objid_hash(VALUE obj)
static int each_pair_i(VALUE key, VALUE value)
int rb_integer_pack(VALUE val, void *words, size_t numwords, size_t wordsize, size_t nails, int flags)
const struct st_hash_type * orighash
#define get_env_ptr(var, val)
static VALUE env_each_value(VALUE ehash)
VALUE rb_ary_new_capa(long capa)
char * rb_w32_ugetenv(const char *)
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)
static VALUE rb_hash_gt(VALUE hash, VALUE other)
size_t strlen(const char *)
static VALUE rb_hash_has_value(VALUE hash, VALUE val)
static uint64_t mult_and_mix(uint64_t m1, uint64_t m2)
static VALUE hash_alloc_flags(VALUE klass, VALUE flags, VALUE ifnone)
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,...)
#define RB_OBJ_WRITTEN(a, oldv, b)
static int max(int a, int b)
static unsigned int hash(str, len) register const char *str
static int keep_if_i(VALUE key, VALUE value, VALUE hash)
VALUE rb_obj_hash(VALUE obj)
static void no_new_key(void)
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_empty_p(VALUE hash)
#define RHASH_ITER_LEV(h)
static VALUE env_invert(void)
static int hash_aset_str(st_data_t *key, st_data_t *val, struct update_arg *arg, int existing)
#define rb_usascii_str_new2
static VALUE rb_hash_default(int argc, VALUE *argv, VALUE hash)
static int rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash)
static void rb_hash_modify(VALUE hash)
static VALUE env_str_new2(const char *ptr)
st_table * rb_init_identtable_with_size(st_index_t size)
st_index_t rb_hash_end(st_index_t)
static VALUE hash_proc_call(VALUE key, VALUE hash, int argc, const VALUE *argv, VALUE passed_proc)
static int foreach_safe_i(st_data_t key, st_data_t value, st_data_t args, int error)
VALUE rb_hash_select_bang(VALUE hash)
static int keys_i(VALUE key, VALUE value, VALUE ary)
double rb_float_value(VALUE v)
static ID id_flatten_bang
static VALUE env_to_s(void)
int rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val)
int rb_env_path_tainted(void)
static VALUE env_keys(void)
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *)
int rb_hash_iter_lev(VALUE h)
static VALUE env_delete_if(VALUE ehash)
static VALUE env_shift(void)
static VALUE rb_hash_lt(VALUE hash, VALUE other)
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)
if(len<=MAX_WORD_LENGTH &&len >=MIN_WORD_LENGTH)
static VALUE env_each_pair(VALUE ehash)
static VALUE rb_env_size(VALUE ehash, VALUE args, VALUE eobj)
#define SET_DEFAULT(hash, ifnone)
st_index_t rb_memhash(const void *ptr, long len)
struct st_table * rb_hash_tbl_raw(VALUE hash)
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)
#define INTEGER_PACK_NATIVE_BYTE_ORDER
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)
char * rb_str_fill_terminator(VALUE str, const int termlen)
static const uint64_t prime1
static VALUE inspect_hash(VALUE hash, VALUE dummy, int recur)
long rb_dbl_long_hash(double d)
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)
st_index_t rb_str_hash(VALUE)
#define ENVNMATCH(s1, s2, n)
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)
int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg)
static VALUE env_keep_if(VALUE ehash)
static int rb_hash_update_i(VALUE key, VALUE value, VALUE hash)
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_ary_cat(VALUE ary, const VALUE *argv, long len)
VALUE rb_str_buf_append(VALUE, VALUE)
static VALUE rb_hash_replace(VALUE hash, VALUE hash2)
static int any_p_i_fast(VALUE key, VALUE value, VALUE arg)
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
#define NOINSERT_UPDATE_CALLBACK(func)
const char * rb_obj_classname(VALUE)
static VALUE rb_hash_fetch_m(int argc, VALUE *argv, VALUE hash)
VALUE rb_big_hash(VALUE x)
static VALUE env_rassoc(VALUE dmy, VALUE obj)
static int rb_hash_update_func_i(VALUE key, VALUE value, VALUE arg0)
static VALUE env_each_key(VALUE ehash)
#define RHASH_SET_IFNONE(h, ifnone)
static st_index_t obj_any_hash(VALUE obj)
VALUE rb_hash_keys(VALUE hash)
VALUE rb_str_buf_cat(VALUE, const char *, long)
RUBY_SYMBOL_EXPORT_BEGIN typedef unsigned long st_data_t
VALUE rb_hash_default_value(VALUE hash, VALUE key)
#define NEWOBJ_OF(obj, type, klass, flags)
VALUE rb_utf8_str_new(const char *, long)
void rb_hash_foreach(VALUE hash, int(*func)(ANYARGS), VALUE farg)
#define HAS_EXTRA_STATES(hash, klass)
#define RB_TYPE_P(obj, type)
static VALUE rb_hash_to_proc(VALUE hash)
static VALUE rb_hash_transform_values_bang(VALUE hash)
static VALUE hash_le(VALUE hash1, VALUE hash2)
VALUE rb_hash_rehash(VALUE hash)
static int rb_hash_rehash_i(VALUE key, VALUE value, VALUE arg)
static VALUE env_key(VALUE dmy, VALUE value)
unsigned long long uint64_t
static int transform_values_i(VALUE key, VALUE value, VALUE result)
#define COPY_DEFAULT(hash, hash2)
int rb_block_given_p(void)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
static VALUE env_assoc(VALUE env, VALUE key)
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 int assoc_cmp(VALUE a, VALUE b)
#define st_init_table_with_size
static VALUE rb_hash_initialize_copy(VALUE hash, VALUE hash2)
static int hash_le_i(VALUE key, VALUE value, VALUE arg)
char * ruby_strdup(const char *)
static int hash_i(VALUE key, VALUE val, VALUE arg)
VALUE rb_hash_delete_entry(VALUE hash, VALUE key)
#define ECONV_INVALID_REPLACE
static int add_new_i(st_data_t *key, st_data_t *val, st_data_t arg, int existing)
VALUE rb_str_buf_cat2(VALUE, const char *)
#define OBJ_WB_UNPROTECT(x)
int rb_ascii8bit_encindex(void)
long rb_objid_hash(st_index_t index)
int rb_class_has_methods(VALUE c)
static int each_value_i(VALUE key, VALUE value)
VALUE rb_hash_set_ifnone(VALUE hash, VALUE ifnone)
static char * w32_getenv(const char *name, UINT cp)
static void copy_default(struct RHash *hash, const struct RHash *hash2)
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)
void rb_sys_fail_str(VALUE mesg)
rb_atomic_t cnt[RUBY_NSIG]
VALUE rb_hash_update_func(VALUE newkey, VALUE oldkey, VALUE value)
static VALUE rb_hash_any_p(VALUE hash)
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)
VALUE rb_hash_has_key(VALUE hash, VALUE key)
#define ALLOCV_N(type, v, n)
int rb_locale_encindex(void)
static const struct st_hash_type objhash
VALUE rb_hash_ifnone(VALUE h)
static int rb_any_cmp(VALUE a, VALUE b)
static VALUE env_name_new(const char *name, const char *ptr)
VALUE rb_hash_reject(VALUE hash)
VALUE rb_obj_alloc(VALUE)
st_index_t(* hash)(ANYARGS)
static VALUE reset_hash_type(VALUE arg)
VALUE rb_hash_size(VALUE hash)
#define HASH_PROC_DEFAULT
static int reject_i(VALUE key, VALUE value, VALUE result)
static VALUE rb_hash_to_hash(VALUE hash)
#define RUBY_DTRACE_CREATE_HOOK(name, arg)
static VALUE env_replace(VALUE env, VALUE hash)
static VALUE rb_hash_set_default(VALUE hash, VALUE ifnone)
static long any_hash(VALUE a, st_index_t(*other_func)(VALUE))
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)
st_index_t st_hash(const void *ptr, size_t len, st_index_t h)
static int tbl_update(VALUE hash, VALUE key, tbl_update_func func, st_data_t optional_arg)
static VALUE hash_foreach_ensure(VALUE hash)
VALUE rb_obj_is_proc(VALUE)
static VALUE env_inspect(void)
VALUE rb_sprintf(const char *format,...)
st_table * rb_init_identtable(void)
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)
#define RARRAY_PTR_USE(ary, ptr_name, expr)
VALUE rb_ary_delete(VALUE ary, VALUE item)
static VALUE env_has_key(VALUE env, VALUE key)
VALUE rb_hash_values(VALUE hash)
static const struct st_hash_type identhash
int(* tbl_update_func)(st_data_t *, st_data_t *, st_data_t, int)
static int each_pair_i_fast(VALUE key, VALUE value)
VALUE rb_check_hash_type(VALUE hash)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_assoc_new(VALUE car, VALUE cdr)
static int rb_hash_update_block_callback(st_data_t *key, st_data_t *value, struct update_arg *arg, int existing)
rb_encoding * rb_locale_encoding(void)
static VALUE lookup2_call(VALUE arg)
char * rb_w32_getenv(const char *)
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)
static VALUE env_aset(VALUE obj, VALUE nm, VALUE val)
static VALUE env_to_a(void)
st_index_t st_values_check(st_table *table, st_data_t *values, st_index_t size, st_data_t never)
static VALUE hash_equal(VALUE hash1, VALUE hash2, int eql)
static VALUE rb_hash_flatten(int argc, VALUE *argv, VALUE hash)
#define rb_enc_asciicompat(enc)
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)
static VALUE env_enc_str_new(const char *ptr, long len, rb_encoding *enc)
static VALUE env_select(VALUE ehash)
VALUE rb_hash_freeze(VALUE hash)
NORETURN(static void no_new_key(void))
int rb_respond_to(VALUE, ID)
register unsigned int len
static VALUE env_none(void)
static VALUE env_size(void)
static int delete_if_i(VALUE key, VALUE value, VALUE hash)
static VALUE has_extra_methods(VALUE klass)
static void * get_env_cstr(VALUE str, const char *name)
static st_index_t rb_ident_hash(st_data_t n)
#define ECONV_UNDEF_REPLACE
VALUE rb_equal(VALUE, VALUE)
rb_encoding * rb_enc_get(VALUE obj)
static int inspect_i(VALUE key, VALUE value, VALUE str)
static VALUE rb_hash_compare_by_id(VALUE hash)
VALUE rb_ident_hash_new(void)
VALUE rb_yield_values2(int n, const VALUE *argv)
VALUE rb_hash_lookup2(VALUE hash, VALUE key, VALUE def)
static VALUE to_hash(VALUE hash)
#define UNLIMITED_ARGUMENTS
VALUE rb_hash_compare_by_id_p(VALUE hash)
int st_shift(st_table *, st_data_t *, st_data_t *)
static VALUE hash_enum_size(VALUE hash, VALUE args, VALUE eobj)
#define RARRAY_AREF(a, i)
int rb_path_check(const char *path)
VALUE rb_check_convert_type(VALUE, int, const char *, const char *)
VALUE rb_block_proc(void)
static int flatten_i(VALUE key, VALUE val, VALUE ary)
VALUE rb_str_buf_cat_ascii(VALUE, const char *)
static VALUE env_to_hash(void)
VALUE rb_check_array_type(VALUE ary)
VALUE rb_hash_aref(VALUE hash, VALUE key)
VALUE rb_obj_dig(int argc, VALUE *argv, VALUE self, VALUE notfound)
static VALUE hash_dup(VALUE hash, VALUE klass, VALUE flags)
#define RHASH_UPDATE_ITER(h, iter_lev, key, func, a)
static int hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
void rb_syserr_fail_str(int e, VALUE mesg)
static VALUE env_enc_str_new_cstr(const char *ptr, rb_encoding *enc)
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 rb_encoding * env_encoding_for(const char *name, const char *ptr)
static uint64_t key64_hash(uint64_t key, uint32_t seed)
static VALUE rb_hash_hash(VALUE hash)
static VALUE rb_hash_ge(VALUE hash, VALUE other)
static VALUE recursive_eql(VALUE hash, VALUE dt, int recur)
VALUE rb_func_proc_new(rb_block_call_func_t func, VALUE val)
const struct st_hash_type * type
static int any_p_i(VALUE key, VALUE value, VALUE arg)
void rb_gc_writebarrier_remember(VALUE obj)
static int rassoc_i(VALUE key, VALUE val, VALUE arg)
#define SafeStringValue(v)
st_index_t st_keys_check(st_table *table, st_data_t *keys, st_index_t size, st_data_t never)
VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc)
static VALUE rb_hash_merge(VALUE hash1, VALUE hash2)
static VALUE rb_hash_delete_m(VALUE hash, VALUE key)
VALUE rb_hash_values_at(int argc, VALUE *argv, VALUE hash)
static int hash_aset(st_data_t *key, st_data_t *val, struct update_arg *arg, int existing)
VALUE rb_str_new_frozen(VALUE)
static int key_i(VALUE key, VALUE value, VALUE arg)
#define ST_DATA_COMPATIBLE_P(type)
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 *)
rb_hash_update_func * func
VALUE rb_hash_delete_if(VALUE hash)
#define rb_check_frozen(obj)
void ruby_register_rollback_func_for_ensure(VALUE(*ensure_func)(ANYARGS), VALUE(*rollback_func)(ANYARGS))
static VALUE env_empty_p(void)
VALUE rb_hash_assoc(VALUE hash, VALUE key)
static int to_a_i(VALUE key, VALUE value, VALUE ary)
static VALUE rb_hash_compact(VALUE hash)
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 hash_recursive(VALUE obj, VALUE arg, int recurse)
int rb_enc_str_asciionly_p(VALUE)
static VALUE rb_hash_le(VALUE hash, VALUE other)
static VALUE hash_foreach_ensure_rollback(VALUE hash)
static VALUE rb_hash_compact_bang(VALUE hash)
static VALUE env_reject_bang(VALUE ehash)
static const uint64_t prime2
static VALUE env_fetch(int argc, VALUE *argv)
VALUE rb_hash_select(VALUE hash)
static VALUE env_has_value(VALUE dmy, VALUE obj)
static VALUE env_update(VALUE env, VALUE hash)
static int set_if_not_nil(VALUE key, VALUE value, VALUE hash)
#define RGENGC_WB_PROTECTED_HASH
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
void ruby_setenv(const char *name, const char *value)
static int delete_if_nil(VALUE key, VALUE value, VALUE hash)
void rb_warn(const char *fmt,...)
static VALUE rb_hash_transform_values(VALUE hash)
static struct st_table * hash_tbl(VALUE hash)
st_index_t rb_hash_start(st_index_t)
static int rb_hash_update_callback(st_data_t *key, st_data_t *value, struct update_arg *arg, int existing)
#define RB_OBJ_WRITE(a, slot, b)
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 int rb_hash_update_func_callback(st_data_t *key, st_data_t *value, struct update_arg *arg, int existing)
VALUE rb_hash_fetch_values(int argc, VALUE *argv, VALUE hash)
static VALUE env_str_new(const char *ptr, long len)
static VALUE rb_hash_default_proc(VALUE hash)
static VALUE rb_hash_inspect(VALUE hash)
void rb_ary_set_len(VALUE ary, long len)
static void set_proc_default(VALUE hash, VALUE proc)
VALUE rb_obj_class(VALUE)
VALUE rb_hash_dig(int argc, VALUE *argv, VALUE self)