21 #include <crt_externs.h>
26 #define HASH_DELETED FL_USER1
27 #define HASH_PROC_DEFAULT FL_USER2
128 status = (*arg->
func)(key, value, arg->
arg);
183 RHASH(hash)->iter_lev--;
185 if (
RHASH(hash)->iter_lev == 0) {
208 if (!
RHASH(hash)->ntbl)
210 RHASH(hash)->iter_lev++;
260 if (!
RHASH(hash)->ntbl) {
263 return RHASH(hash)->ntbl;
377 if (
RHASH(tmp)->ntbl) {
392 if (
NIL_P(v))
continue;
409 for (i=0; i<
argc; i+=2) {
479 if (
RHASH(hash)->iter_lev > 0) {
483 if (!
RHASH(hash)->ntbl)
488 RHASH(hash)->ntbl = tbl;
580 if (block_given && argc == 2) {
581 rb_warn(
"block supersedes default value argument");
584 if (block_given)
return rb_yield(key);
633 if (argc == 0)
return Qnil;
714 "wrong default_proc type %s (expected Proc)",
767 rb_warn(
"Hash#index is deprecated; use Hash#key");
776 if (!
RHASH(hash)->ntbl)
778 if (
RHASH(hash)->iter_lev > 0) {
814 if (val !=
Qundef)
return val;
857 if (
RHASH(hash)->iter_lev == 0) {
928 if (!
RHASH(hash)->ntbl)
930 n =
RHASH(hash)->ntbl->num_entries;
932 if (n ==
RHASH(hash)->ntbl->num_entries)
return Qnil;
970 for (i=0; i<
argc; i++) {
1036 if (!
RHASH(hash)->ntbl)
1038 n =
RHASH(hash)->ntbl->num_entries;
1040 if (n ==
RHASH(hash)->ntbl->num_entries)
return Qnil;
1086 if (!
RHASH(hash)->ntbl)
1088 if (
RHASH(hash)->ntbl->num_entries > 0) {
1089 if (
RHASH(hash)->iter_lev > 0)
1163 if (hash == hash2)
return hash;
1165 if (
RHASH(hash2)->ntbl) {
1167 RHASH(hash)->ntbl->type =
RHASH(hash2)->ntbl->type;
1197 if (!
RHASH(hash)->ntbl)
1506 if (!
RHASH(hash)->ntbl)
1580 if (recur)
return Qtrue;
1593 if (hash1 == hash2)
return Qtrue;
1599 return rb_eql(hash2, hash1);
1605 if (!
RHASH(hash1)->ntbl || !
RHASH(hash2)->ntbl)
1607 if (
RHASH(hash1)->ntbl->type !=
RHASH(hash2)->ntbl->type)
1668 *hval ^=
st_hash(hdata,
sizeof(hdata), 0);
1677 if (!
RHASH(hash)->ntbl)
1679 hval =
RHASH(hash)->ntbl->num_entries;
1996 if (!
RHASH(hash)->ntbl)
1998 if (
RHASH(hash)->ntbl->type == &identhash) {
2008 #define GET_ENVIRON(e) ((e) = rb_w32_get_environ())
2009 #define FREE_ENVIRON(e) rb_w32_free_environ(e)
2010 static char **my_environ;
2012 #define environ my_environ
2013 #elif defined(__APPLE__)
2015 #define environ (*_NSGetEnviron())
2016 #define GET_ENVIRON(e) (e)
2017 #define FREE_ENVIRON(e)
2020 #define GET_ENVIRON(e) (e)
2021 #define FREE_ENVIRON(e)
2023 #ifdef ENV_IGNORECASE
2024 #define ENVMATCH(s1, s2) (STRCASECMP((s1), (s2)) == 0)
2025 #define ENVNMATCH(s1, s2, n) (STRNCASECMP((s1), (s2), (n)) == 0)
2027 #define ENVMATCH(n1, n2) (strcmp((n1), (n2)) == 0)
2028 #define ENVNMATCH(s1, s2, n) (memcmp((s1), (s2), (n)) == 0)
2043 if (!ptr)
return Qnil;
2147 if (block_given && argc == 2) {
2148 rb_warn(
"block supersedes default value argument");
2157 if (block_given)
return rb_yield(key);
2177 if (path_tainted < 0) {
2186 if (path_tainted < 0) {
2192 #if defined(_WIN32) || (defined(HAVE_SETENV) && defined(HAVE_UNSETENV))
2193 #elif defined __sun__
2195 in_origenv(
const char *str)
2198 for (env = origenviron; *env; ++env) {
2199 if (*env == str)
return 1;
2211 for (i = 0; env[
i]; i++) {
2212 if (
ENVNMATCH(env[i],nam,len) && env[i][len] ==
'=')
2222 getenvsize(
const char*
p)
2224 const char* porg =
p;
2225 while (*p++) p +=
strlen(p) + 1;
2226 return p - porg + 1;
2247 const char* p = GetEnvironmentStringsA();
2249 if (
strlen(name) + 2 +
strlen(value) + getenvsize(p) >= getenvblocksize()) {
2261 if (!value || !*value) {
2263 if (!SetEnvironmentVariable(name, value) &&
2264 GetLastError() != ERROR_ENVVAR_NOT_FOUND)
goto fail;
2266 if (failed)
goto fail;
2267 #elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV)
2271 if (
setenv(name, value, 1))
2274 #ifdef VOID_UNSETENV
2281 #elif defined __sun__
2283 char **env_ptr, *str;
2289 for (env_ptr =
GET_ENVIRON(environ); (str = *env_ptr) != 0; ++env_ptr) {
2290 if (!strncmp(str, name, len) && str[
len] ==
'=') {
2291 if (!in_origenv(str))
free(str);
2292 while ((env_ptr[0] = env_ptr[1]) != 0) env_ptr++;
2298 snprintf(str, len,
"%s=%s", name, value);
2311 if (environ == origenviron) {
2316 for (max = i; environ[
max]; max++) ;
2317 tmpenv =
ALLOC_N(
char*, max+2);
2318 for (j=0; j<
max; j++)
2325 while (*envp && *envp != environ[i]) envp++;
2329 while (environ[i]) {
2330 environ[
i] = environ[i+1];
2343 snprintf(environ[i],len,
"%s=%s",name,value);
2414 char *s =
strchr(*env,
'=');
2463 char *s =
strchr(*env,
'=');
2520 char *s =
strchr(*env,
'=');
2547 volatile VALUE keys;
2563 if (del == 0)
return Qnil;
2599 for (i=0; i<
argc; i++) {
2625 char *s =
strchr(*env,
'=');
2650 volatile VALUE keys;
2666 if (del == 0)
return Qnil;
2696 volatile VALUE keys;
2737 char *s =
strchr(*env,
'=');
2739 if (env != environ) {
2777 char *s =
strchr(*env,
'=');
2816 for(i=0; env[
i]; i++)
2903 char *s =
strchr(*env,
'=');
2934 char *s =
strchr(*env,
'=');
2966 char *s =
strchr(*env,
'=');
2990 rb_warn(
"ENV.index is deprecated; use ENV.key");
3011 char *s =
strchr(*env,
'=');
3051 char *s =
strchr(*env,
'=');
3098 volatile VALUE keys;
3102 if (env == hash)
return env;
3138 if (env == hash)
return env;
3160 #define rb_intern(str) rb_intern_const(str)