diff options
author | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-02-18 17:42:54 +0000 |
---|---|---|
committer | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-02-18 17:42:54 +0000 |
commit | e55e640a6f1a710bf1e344d462cc94316d5ecb39 (patch) | |
tree | 6b4f506ce863670bcf17d63a1649379f1d5c3bf2 /ext/strscan | |
parent | 6f77e4b4ba78f0d74d297219cae251161b466a48 (diff) | |
download | ruby-e55e640a6f1a710bf1e344d462cc94316d5ecb39.tar.gz |
* ext/strscan/strscan.c: don't use rb_eval_string, it defines classes under the module when required in module clauses. [ruby-dev:22951]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/strscan')
-rw-r--r-- | ext/strscan/strscan.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c index 39d3d8bcb6..8997cbf8b4 100644 --- a/ext/strscan/strscan.c +++ b/ext/strscan/strscan.c @@ -1245,10 +1245,14 @@ inspect2(p) void Init_strscan() { - volatile VALUE tmp; + ID id_scanerr = rb_intern("ScanError"); + VALUE tmp; StringScanner = rb_define_class("StringScanner", rb_cObject); - ScanError = rb_eval_string("class StringScanner; class Error < StandardError; end; end; ScanError = StringScanner::Error unless defined?(ScanError); StringScanner::Error"); + ScanError = rb_define_class_under(StringScanner, "Error", rb_eStandardError); + if (!rb_const_defined(rb_cObject, id_scanerr)) { + rb_const_set(rb_cObject, id_scanerr, ScanError); + } tmp = rb_str_new2(STRSCAN_VERSION); rb_obj_freeze(tmp); rb_const_set(StringScanner, rb_intern("Version"), tmp); |