From d1b243d5c8b723788868eaf9cff7e239ac5a6590 Mon Sep 17 00:00:00 2001 From: aamine Date: Wed, 18 Feb 2004 17:42:54 +0000 Subject: * 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: http://svn.ruby-lang.org/repos/ruby/trunk@5775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 ++++++++- ext/strscan/strscan.c | 8 ++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index aa58782dc..a44c523dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,13 @@ +Thu Feb 19 02:42:19 2004 Minero Aoki + + * ext/strscan/strscan.c: don't use rb_eval_string, it defines + classes under the module when required in module clauses. + [ruby-dev:22951] + Thu Feb 19 02:37:28 2004 Minero Aoki - * ext/strscan/strscan.c: merge documentation from 1.8 branch. Thanks Gavin Sinclair. + * ext/strscan/strscan.c: merge documentation from 1.8 branch. + Thanks Gavin Sinclair. Wed Feb 19 00:20:00 2004 Gavin Sinclair diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c index 39d3d8bcb..8997cbf8b 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); -- cgit