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) {
485 if (
RHASH(hash)->iter_lev > 0) {
489 if (!
RHASH(hash)->ntbl)
493 RHASH(tmp)->ntbl = tbl;
497 RHASH(hash)->ntbl = tbl;
498 RHASH(tmp)->ntbl = 0;
590 if (block_given && argc == 2) {
591 rb_warn(
"block supersedes default value argument");
594 if (block_given)
return rb_yield(key);
643 if (argc == 0)
return Qnil;
724 "wrong default_proc type %s (expected Proc)",
777 rb_warn(
"Hash#index is deprecated; use Hash#key");
786 if (!
RHASH(hash)->ntbl)
788 if (
RHASH(hash)->iter_lev > 0) {
824 if (val !=
Qundef)
return val;
867 if (
RHASH(hash)->iter_lev == 0) {
938 if (!
RHASH(hash)->ntbl)
940 n =
RHASH(hash)->ntbl->num_entries;
942 if (n ==
RHASH(hash)->ntbl->num_entries)
return Qnil;
980 for (i=0; i<
argc; i++) {
1046 if (!
RHASH(hash)->ntbl)
1048 n =
RHASH(hash)->ntbl->num_entries;
1050 if (n ==
RHASH(hash)->ntbl->num_entries)
return Qnil;
1096 if (!
RHASH(hash)->ntbl)
1098 if (
RHASH(hash)->ntbl->num_entries > 0) {
1099 if (
RHASH(hash)->iter_lev > 0)
1173 if (hash == hash2)
return hash;
1175 if (
RHASH(hash2)->ntbl) {
1177 RHASH(hash)->ntbl->type =
RHASH(hash2)->ntbl->type;
1207 if (!
RHASH(hash)->ntbl)
1516 if (!
RHASH(hash)->ntbl)
1590 if (recur)
return Qtrue;
1603 if (hash1 == hash2)
return Qtrue;
1609 return rb_eql(hash2, hash1);
1615 if (!
RHASH(hash1)->ntbl || !
RHASH(hash2)->ntbl)
1617 if (
RHASH(hash1)->ntbl->type !=
RHASH(hash2)->ntbl->type)
1678 *hval ^=
st_hash(hdata,
sizeof(hdata), 0);
1687 if (!
RHASH(hash)->ntbl)
1689 hval =
RHASH(hash)->ntbl->num_entries;
2006 if (!
RHASH(hash)->ntbl)
2008 if (
RHASH(hash)->ntbl->type == &identhash) {
2018 #define GET_ENVIRON(e) ((e) = rb_w32_get_environ())
2019 #define FREE_ENVIRON(e) rb_w32_free_environ(e)
2020 static char **my_environ;
2022 #define environ my_environ
2023 #elif defined(__APPLE__)
2025 #define environ (*_NSGetEnviron())
2026 #define GET_ENVIRON(e) (e)
2027 #define FREE_ENVIRON(e)
2030 #define GET_ENVIRON(e) (e)
2031 #define FREE_ENVIRON(e)
2033 #ifdef ENV_IGNORECASE
2034 #define ENVMATCH(s1, s2) (STRCASECMP((s1), (s2)) == 0)
2035 #define ENVNMATCH(s1, s2, n) (STRNCASECMP((s1), (s2), (n)) == 0)
2037 #define ENVMATCH(n1, n2) (strcmp((n1), (n2)) == 0)
2038 #define ENVNMATCH(s1, s2, n) (memcmp((s1), (s2), (n)) == 0)
2053 if (!ptr)
return Qnil;
2157 if (block_given && argc == 2) {
2158 rb_warn(
"block supersedes default value argument");
2167 if (block_given)
return rb_yield(key);
2187 if (path_tainted < 0) {
2196 if (path_tainted < 0) {
2202 #if defined(_WIN32) || (defined(HAVE_SETENV) && defined(HAVE_UNSETENV))
2203 #elif defined __sun__
2205 in_origenv(
const char *str)
2208 for (env = origenviron; *env; ++env) {
2209 if (*env == str)
return 1;
2221 for (i = 0; env[
i]; i++) {
2222 if (
ENVNMATCH(env[i],nam,len) && env[i][len] ==
'=')
2232 getenvsize(
const char*
p)
2234 const char* porg =
p;
2235 while (*p++) p +=
strlen(p) + 1;
2236 return p - porg + 1;
2257 const char* p = GetEnvironmentStringsA();
2259 if (
strlen(name) + 2 +
strlen(value) + getenvsize(p) >= getenvblocksize()) {
2271 if (!value || !*value) {
2273 if (!SetEnvironmentVariable(name, value) &&
2274 GetLastError() != ERROR_ENVVAR_NOT_FOUND)
goto fail;
2276 if (failed)
goto fail;
2277 #elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV)
2281 if (
setenv(name, value, 1))
2284 #ifdef VOID_UNSETENV
2291 #elif defined __sun__
2293 char **env_ptr, *str;
2299 for (env_ptr =
GET_ENVIRON(environ); (str = *env_ptr) != 0; ++env_ptr) {
2300 if (!strncmp(str, name, len) && str[
len] ==
'=') {
2301 if (!in_origenv(str))
free(str);
2302 while ((env_ptr[0] = env_ptr[1]) != 0) env_ptr++;
2308 snprintf(str, len,
"%s=%s", name, value);
2321 if (environ == origenviron) {
2326 for (max = i; environ[
max]; max++) ;
2327 tmpenv =
ALLOC_N(
char*, max+2);
2328 for (j=0; j<
max; j++)
2335 while (*envp && *envp != environ[i]) envp++;
2339 while (environ[i]) {
2340 environ[
i] = environ[i+1];
2353 snprintf(environ[i],len,
"%s=%s",name,value);
2424 char *s =
strchr(*env,
'=');
2473 char *s =
strchr(*env,
'=');
2530 char *s =
strchr(*env,
'=');
2557 volatile VALUE keys;
2573 if (del == 0)
return Qnil;
2609 for (i=0; i<
argc; i++) {
2635 char *s =
strchr(*env,
'=');
2660 volatile VALUE keys;
2676 if (del == 0)
return Qnil;
2706 volatile VALUE keys;
2747 char *s =
strchr(*env,
'=');
2749 if (env != environ) {
2787 char *s =
strchr(*env,
'=');
2826 for(i=0; env[
i]; i++)
2913 char *s =
strchr(*env,
'=');
2944 char *s =
strchr(*env,
'=');
2976 char *s =
strchr(*env,
'=');
3000 rb_warn(
"ENV.index is deprecated; use ENV.key");
3021 char *s =
strchr(*env,
'=');
3061 char *s =
strchr(*env,
'=');
3108 volatile VALUE keys;
3112 if (env == hash)
return env;
3148 if (env == hash)
return env;
3170 #define rb_intern(str) rb_intern_const(str)