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;
873 if (
RHASH(hash)->iter_lev > 0) {
936 if (!
RHASH(hash)->ntbl)
938 n =
RHASH(hash)->ntbl->num_entries;
940 if (n ==
RHASH(hash)->ntbl->num_entries)
return Qnil;
978 for (i=0; i<
argc; i++) {
1044 if (!
RHASH(hash)->ntbl)
1046 n =
RHASH(hash)->ntbl->num_entries;
1048 if (n ==
RHASH(hash)->ntbl->num_entries)
return Qnil;
1094 if (!
RHASH(hash)->ntbl)
1096 if (
RHASH(hash)->ntbl->num_entries > 0) {
1097 if (
RHASH(hash)->iter_lev > 0)
1171 if (hash == hash2)
return hash;
1173 if (
RHASH(hash2)->ntbl) {
1175 RHASH(hash)->ntbl->type =
RHASH(hash2)->ntbl->type;
1205 if (!
RHASH(hash)->ntbl)
1514 if (!
RHASH(hash)->ntbl)
1588 if (recur)
return Qtrue;
1601 if (hash1 == hash2)
return Qtrue;
1607 return rb_eql(hash2, hash1);
1613 if (!
RHASH(hash1)->ntbl || !
RHASH(hash2)->ntbl)
1615 if (
RHASH(hash1)->ntbl->type !=
RHASH(hash2)->ntbl->type)
1676 *hval ^=
st_hash(hdata,
sizeof(hdata), 0);
1685 if (!
RHASH(hash)->ntbl)
1687 hval =
RHASH(hash)->ntbl->num_entries;
2004 if (!
RHASH(hash)->ntbl)
2006 if (
RHASH(hash)->ntbl->type == &identhash) {
2016 #define GET_ENVIRON(e) ((e) = rb_w32_get_environ())
2017 #define FREE_ENVIRON(e) rb_w32_free_environ(e)
2018 static char **my_environ;
2020 #define environ my_environ
2021 #elif defined(__APPLE__)
2023 #define environ (*_NSGetEnviron())
2024 #define GET_ENVIRON(e) (e)
2025 #define FREE_ENVIRON(e)
2028 #define GET_ENVIRON(e) (e)
2029 #define FREE_ENVIRON(e)
2031 #ifdef ENV_IGNORECASE
2032 #define ENVMATCH(s1, s2) (STRCASECMP((s1), (s2)) == 0)
2033 #define ENVNMATCH(s1, s2, n) (STRNCASECMP((s1), (s2), (n)) == 0)
2035 #define ENVMATCH(n1, n2) (strcmp((n1), (n2)) == 0)
2036 #define ENVNMATCH(s1, s2, n) (memcmp((s1), (s2), (n)) == 0)
2051 if (!ptr)
return Qnil;
2155 if (block_given && argc == 2) {
2156 rb_warn(
"block supersedes default value argument");
2165 if (block_given)
return rb_yield(key);
2185 if (path_tainted < 0) {
2194 if (path_tainted < 0) {
2200 #if defined(_WIN32) || (defined(HAVE_SETENV) && defined(HAVE_UNSETENV))
2201 #elif defined __sun__
2203 in_origenv(
const char *str)
2206 for (env = origenviron; *env; ++env) {
2207 if (*env == str)
return 1;
2219 for (i = 0; env[
i]; i++) {
2220 if (
ENVNMATCH(env[i],nam,len) && env[i][len] ==
'=')
2230 getenvsize(
const char*
p)
2232 const char* porg =
p;
2233 while (*p++) p +=
strlen(p) + 1;
2234 return p - porg + 1;
2255 const char* p = GetEnvironmentStringsA();
2257 if (
strlen(name) + 2 +
strlen(value) + getenvsize(p) >= getenvblocksize()) {
2269 if (!value || !*value) {
2271 if (!SetEnvironmentVariable(name, value) &&
2272 GetLastError() != ERROR_ENVVAR_NOT_FOUND)
goto fail;
2274 if (failed)
goto fail;
2275 #elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV)
2279 if (
setenv(name, value, 1))
2282 #ifdef VOID_UNSETENV
2289 #elif defined __sun__
2291 char **env_ptr, *str;
2297 for (env_ptr =
GET_ENVIRON(environ); (str = *env_ptr) != 0; ++env_ptr) {
2298 if (!strncmp(str, name, len) && str[
len] ==
'=') {
2299 if (!in_origenv(str))
free(str);
2300 while ((env_ptr[0] = env_ptr[1]) != 0) env_ptr++;
2306 snprintf(str, len,
"%s=%s", name, value);
2319 if (environ == origenviron) {
2324 for (max = i; environ[
max]; max++) ;
2325 tmpenv =
ALLOC_N(
char*, max+2);
2326 for (j=0; j<
max; j++)
2333 while (*envp && *envp != environ[i]) envp++;
2337 while (environ[i]) {
2338 environ[
i] = environ[i+1];
2351 snprintf(environ[i],len,
"%s=%s",name,value);
2422 char *s =
strchr(*env,
'=');
2471 char *s =
strchr(*env,
'=');
2528 char *s =
strchr(*env,
'=');
2555 volatile VALUE keys;
2571 if (del == 0)
return Qnil;
2607 for (i=0; i<
argc; i++) {
2633 char *s =
strchr(*env,
'=');
2658 volatile VALUE keys;
2674 if (del == 0)
return Qnil;
2704 volatile VALUE keys;
2745 char *s =
strchr(*env,
'=');
2747 if (env != environ) {
2785 char *s =
strchr(*env,
'=');
2824 for(i=0; env[
i]; i++)
2911 char *s =
strchr(*env,
'=');
2942 char *s =
strchr(*env,
'=');
2974 char *s =
strchr(*env,
'=');
2998 rb_warn(
"ENV.index is deprecated; use ENV.key");
3019 char *s =
strchr(*env,
'=');
3059 char *s =
strchr(*env,
'=');
3106 volatile VALUE keys;
3110 if (env == hash)
return env;
3146 if (env == hash)
return env;
3168 #define rb_intern(str) rb_intern_const(str)