static VALUE rb_struct_inspect(VALUE s) { if (rb_inspecting_p(s)) { const char *cname = rb_class2name(rb_obj_class(s)); size_t len = strlen(cname) + 14; VALUE str = rb_str_new(0, len); snprintf(RSTRING(str)->ptr, len+1, "#<struct %s:...>", cname); RSTRING(str)->len = strlen(RSTRING(str)->ptr); return str; } return rb_protect_inspect(inspect_struct, s, 0); }
static VALUE rg_puts(int argc, VALUE *argv, VALUE self) { int i; VALUE line; /* if no argument given, print newline. */ if (argc == 0) { rg_write(self, default_rs); return Qnil; } for (i=0; i<argc; i++) { if (NIL_P(argv[i])) { line = rb_str_new2("nil"); } else { line = rbg_check_array_type(argv[i]); if (!NIL_P(line)) { #ifdef HAVE_RB_EXEC_RECURSIVE rb_exec_recursive(ioc_puts_ary, line, self); #else rb_protect_inspect(ioc_puts_ary, line, self); #endif continue; } line = rb_obj_as_string(argv[i]); } rg_write(self, line); if (RSTRING_LEN(line) == 0 || RSTRING_PTR(line)[RSTRING_LEN(line)-1] != '\n') { rg_write(self, default_rs); } } return Qnil; }
static VALUE c_attrs_inspect (VALUE self) { return rb_protect_inspect (attrs_inspect, self, 0); }
static VALUE array_spec_rb_protect_inspect(VALUE self, VALUE obj) { return rb_protect_inspect(rec_pi, obj, Qtrue); }
static VALUE c_dict_inspect (VALUE self) { return rb_protect_inspect (dict_inspect, self, 0); }