From 67dcad92b7fb9f8b95c8e4925061527fc8a8db3d Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 23 Jun 2003 06:52:39 +0000 Subject: * string.c (rb_str_upto): generate sequence according to "succ" order. formerly check was done by dictionary order. [ruby-talk:74138] * string.c (rb_string_value): fill constant empty string along with setting ELTS_SHARED if str->ptr is NULL. [ruby-core:01179] * string.c (rb_string_value_ptr): ditto. * string.c (rb_check_string_type): ditto. * string.c (str_gsub): move END(0) check before mbclen2(). * string.c (scan_once): reduce END(0) check. * io.c (rb_io_initialize): accept fixnum mode. * eval.c (error_print): replace strchr() by memchr(), einfo may contain "\0". * pack.c (pack_unpack): range check for "@" move; initialize check for "m". * error.c (syserr_initialize): avoid buffer overflow. * file.c (rb_file_s_readlink): expand buffer until readlink succeed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- hash.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'hash.c') diff --git a/hash.c b/hash.c index cf7a14bb34..8f636e1590 100644 --- a/hash.c +++ b/hash.c @@ -997,6 +997,7 @@ static VALUE env_str_new2(ptr) const char *ptr; { + if (!ptr) return Qnil; return env_str_new(ptr, strlen(ptr)); } @@ -1606,7 +1607,7 @@ env_index(dmy, value) char **env; VALUE str; - if (TYPE(value) != T_STRING) return Qnil; + StringValue(value); env = GET_ENVIRON(environ); while (*env) { char *s = strchr(*env, '=')+1; @@ -1638,15 +1639,12 @@ env_indexes(argc, argv) rb_warn("ENV.%s is deprecated; use ENV.values_at", rb_id2name(rb_frame_last_func())); for (i=0;iptr); - } - if (v) { - RARRAY(indexes)->ptr[i] = env_str_new2(v); + VALUE tmp = rb_check_string_type(argv[i]); + if (NIL_P(tmp)) { + RARRAY(indexes)->ptr[i] = Qnil; } else { - RARRAY(indexes)->ptr[i] = Qnil; + RARRAY(indexes)->ptr[i] = env_str_new2(getenv(RSTRING(tmp)->ptr)); } RARRAY(indexes)->len = i+1; } -- cgit v1.2.3