summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-12-05 09:36:54 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-12-05 09:36:54 +0000
commit03581d5826a7f2ed7b7f9c0691220c1a5ac00988 (patch)
tree123b6e6109b307d0006908538b2daaa653f0639f /hash.c
parentafa2732b784aaac7800ba03d5617d5d395964149 (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/hash.c b/hash.c
index 62d6145..cc58f60 100644
--- a/hash.c
+++ b/hash.c
@@ -1257,6 +1257,35 @@ env_to_s()
}
static VALUE
+env_inspect()
+{
+ char **env;
+ VALUE str = rb_str_new2("{");
+ VALUE i;
+
+ env = environ;
+ while (*env) {
+ char *s = strchr(*env, '=');
+
+ if (env != environ) {
+ rb_str_cat2(str, ", ");
+ }
+ if (s) {
+ rb_str_cat2(str, "\"");
+ rb_str_cat(str, *env, s-*env);
+ rb_str_cat2(str, "\"=>");
+ i = rb_inspect(rb_str_new2(s+1));
+ rb_str_append(str, i);
+ }
+ env++;
+ }
+ rb_str_cat2(str, "}");
+ OBJ_TAINT(str);
+
+ return str;
+}
+
+static VALUE
env_to_a()
{
char **env;
@@ -1473,6 +1502,7 @@ Init_Hash()
rb_define_singleton_method(envtbl,"reject", env_reject, 0);
rb_define_singleton_method(envtbl,"reject!", env_reject_bang, 0);
rb_define_singleton_method(envtbl,"to_s", env_to_s, 0);
+ rb_define_singleton_method(envtbl,"inspect", env_inspect, 0);
rb_define_singleton_method(envtbl,"rehash", env_none, 0);
rb_define_singleton_method(envtbl,"to_a", env_to_a, 0);
rb_define_singleton_method(envtbl,"index", env_index, 1);