summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-03 01:56:16 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-03 01:56:16 +0000
commit27c4fb3361d0e731d2deff6093ebd33b69231323 (patch)
tree367d35fbab506ca4838d9157560d2090828271f5 /ext
parent1d670ab0f090c0232e2a7a619b70ebb559453331 (diff)
ext: get rid of inadvertent ID creation
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/-test-/symbol/type.c2
-rw-r--r--ext/objspace/object_tracing.c5
-rw-r--r--ext/objspace/objspace.c2
-rw-r--r--ext/objspace/objspace_dump.c6
-rw-r--r--ext/openssl/ossl_pkcs7.c5
-rw-r--r--ext/strscan/strscan.c3
-rw-r--r--ext/tk/tkutil/tkutil.c22
7 files changed, 29 insertions, 16 deletions
diff --git a/ext/-test-/symbol/type.c b/ext/-test-/symbol/type.c
index 296c74c..e51e09e 100644
--- a/ext/-test-/symbol/type.c
+++ b/ext/-test-/symbol/type.c
@@ -38,7 +38,7 @@ bug_sym_attrset(VALUE self, VALUE name)
static VALUE
bug_id2str(VALUE self, VALUE sym)
{
- return rb_id2str(SYM2ID(sym));
+ return rb_sym2str(sym);
}
static VALUE
diff --git a/ext/objspace/object_tracing.c b/ext/objspace/object_tracing.c
index 45b06ae..975518c 100644
--- a/ext/objspace/object_tracing.c
+++ b/ext/objspace/object_tracing.c
@@ -287,7 +287,10 @@ object_allocations_reporter_i(st_data_t key, st_data_t val, st_data_t ptr)
if (info->class_path) fprintf(out, "C: %s", info->class_path);
else fprintf(out, "C: %p", (void *)info->klass);
fprintf(out, "@%s:%lu", info->path ? info->path : "", info->line);
- if (!NIL_P(info->mid)) fprintf(out, " (%s)", rb_id2name(SYM2ID(info->mid)));
+ if (!NIL_P(info->mid)) {
+ VALUE m = rb_sym2str(info->mid);
+ fprintf(out, " (%s)", RSTRING_PTR(m));
+ }
fprintf(out, ")\n");
return ST_CONTINUE;
diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c
index b1f1358..88ebfca 100644
--- a/ext/objspace/objspace.c
+++ b/ext/objspace/objspace.c
@@ -545,7 +545,7 @@ iow_inspect(VALUE self)
VALUE obj = (VALUE)DATA_PTR(self);
VALUE type = type2sym(BUILTIN_TYPE(obj));
- return rb_sprintf("#<InternalObject:%p %s>", (void *)obj, rb_id2name(SYM2ID(type)));
+ return rb_sprintf("#<InternalObject:%p %"PRIsVALUE">", (void *)obj, rb_sym2str(type));
}
/* Returns the Object#object_id of the internal object. */
diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c
index e13cc39..cb8f943 100644
--- a/ext/objspace/objspace_dump.c
+++ b/ext/objspace/objspace_dump.c
@@ -244,8 +244,10 @@ dump_object(VALUE obj, struct dump_config *dc)
if ((ainfo = objspace_lookup_allocation_info(obj))) {
dump_append(dc, ", \"file\":\"%s\", \"line\":%lu", ainfo->path, ainfo->line);
- if (RTEST(ainfo->mid))
- dump_append(dc, ", \"method\":\"%s\"", rb_id2name(SYM2ID(ainfo->mid)));
+ if (RTEST(ainfo->mid)) {
+ VALUE m = rb_sym2str(ainfo->mid);
+ dump_append(dc, ", \"method\":\"%s\"", RSTRING_PTR(m));
+ }
dump_append(dc, ", \"generation\":%"PRIuSIZE, ainfo->generation);
}
diff --git a/ext/openssl/ossl_pkcs7.c b/ext/openssl/ossl_pkcs7.c
index 66c2053..8b1a519 100644
--- a/ext/openssl/ossl_pkcs7.c
+++ b/ext/openssl/ossl_pkcs7.c
@@ -376,7 +376,10 @@ ossl_pkcs7_sym2typeid(VALUE sym)
{ NULL, 0 },
};
- if (RB_TYPE_P(sym, T_SYMBOL)) s = rb_id2name(SYM2ID(sym));
+ if (RB_TYPE_P(sym, T_SYMBOL)) {
+ sym = rb_sym2str(sym);
+ s = RSTRING_PTR(sym);
+ }
else s = StringValuePtr(sym);
for(i = 0; i < numberof(p7_type_tab); i++){
if(p7_type_tab[i].name == NULL)
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index fd61b54..167b5f8 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -1032,7 +1032,8 @@ strscan_aref(VALUE self, VALUE idx)
switch (TYPE(idx)) {
case T_SYMBOL:
- name = rb_id2name(SYM2ID(idx));
+ idx = rb_sym2str(idx);
+ name = RSTRING_PTR(idx);
goto name_to_backref;
break;
case T_STRING:
diff --git a/ext/tk/tkutil/tkutil.c b/ext/tk/tkutil/tkutil.c
index 2cde226..cb387c5 100644
--- a/ext/tk/tkutil/tkutil.c
+++ b/ext/tk/tkutil/tkutil.c
@@ -831,15 +831,15 @@ get_eval_string_core(obj, enc_flag, self)
if (RTEST(enc_flag)) {
if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) {
return rb_funcall(self, ID_toUTF8, 1,
- rb_str_new2(rb_id2name(SYM2ID(obj))));
+ rb_str_dup(rb_sym2str(obj)));
} else {
- return fromDefaultEnc_toUTF8(rb_str_new2(rb_id2name(SYM2ID(obj))), self);
+ return fromDefaultEnc_toUTF8(rb_sym2str(obj), self);
}
} else {
#ifdef HAVE_RB_SYM_TO_S
return rb_sym_to_s(obj);
#else
- return rb_str_new2(rb_id2name(SYM2ID(obj)));
+ return rb_sym2str(obj);
#endif
}
@@ -1312,9 +1312,9 @@ cbsubst_sym_to_subst(self, sym)
struct cbsubst_info, inf);
if (!NIL_P(ret = rb_hash_aref(inf->aliases, sym))) {
- str = rb_id2str(SYM2ID(ret));
+ str = rb_sym2str(ret);
} else {
- str = rb_id2str(SYM2ID(sym));
+ str = rb_sym2str(sym);
}
id = rb_intern_str(rb_sprintf("@%"PRIsVALUE, str));
@@ -1370,26 +1370,30 @@ cbsubst_get_subst_arg(argc, argv, self)
switch(TYPE(argv[i])) {
case T_STRING:
str = argv[i];
- arg_sym = ID2SYM(rb_intern_str(argv[i]));
+ arg_sym = rb_check_symbol(&str);
+ if (NIL_P(arg_sym)) goto not_found;
break;
case T_SYMBOL:
arg_sym = argv[i];
- str = rb_id2str(SYM2ID(arg_sym));
+ str = rb_sym2str(arg_sym);
break;
default:
rb_raise(rb_eArgError, "arg #%d is not a String or a Symbol", i);
}
if (!NIL_P(ret = rb_hash_aref(inf->aliases, arg_sym))) {
- str = rb_id2str(SYM2ID(ret));
+ str = rb_sym2str(ret);
}
- id = rb_intern_str(rb_sprintf("@%"PRIsVALUE, str));
+ ret = rb_sprintf("@%"PRIsVALUE, str);
+ id = rb_check_id(&ret);
+ if (!id) goto not_found;
for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) {
if (inf->ivar[idx] == id) break;
}
if (idx >= CBSUBST_TBL_MAX) {
+ not_found:
rb_raise(rb_eArgError, "cannot find attribute :%"PRIsVALUE, str);
}