summaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-12 06:19:06 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-12 06:19:06 +0000
commitdf6e07822bf0748e9ec6c2f227ce531203c6db38 (patch)
tree127cdc91b84ebb3523ae0c368653c05acc8fe83d /parse.y
parentb6b1be9ff980f8c1bcf61d4bdcf04e775e0c443d (diff)
downloadruby-df6e07822bf0748e9ec6c2f227ce531203c6db38.tar.gz
ruby-df6e07822bf0748e9ec6c2f227ce531203c6db38.tar.xz
ruby-df6e07822bf0748e9ec6c2f227ce531203c6db38.zip
* io.c (rb_io_s_sysopen): should not use alloca for unknowen size
input. [ruby-dev:31775] * parse.y (rb_id2str): ditto. * marshal.c (w_float): use snprintf instead of sprintf. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y20
1 files changed, 8 insertions, 12 deletions
diff --git a/parse.y b/parse.y
index 541c336f7..91d0bac21 100644
--- a/parse.y
+++ b/parse.y
@@ -8553,21 +8553,17 @@ rb_id2str(ID id)
if (is_attrset_id(id)) {
ID id2 = (id & ~ID_SCOPE_MASK) | ID_LOCAL;
+ VALUE str;
- again:
- name = rb_id2name(id2);
- if (name) {
- char *buf = ALLOCA_N(char, strlen(name)+2);
-
- strcpy(buf, name);
- strcat(buf, "=");
- rb_intern(buf);
- return rb_id2str(id);
- }
- if (is_local_id(id2)) {
+ while (!(str = rb_id2str(id2))) {
+ if (!is_local_id(id2)) return 0;
id2 = (id & ~ID_SCOPE_MASK) | ID_CONST;
- goto again;
}
+ str = rb_str_dup(str);
+ rb_str_cat(buf, "=", 1);
+ rb_intern_str(str);
+ if (st_lookup(global_symbols.id_str, id, &data))
+ return (VALUE)data;
}
return 0;
}