summaryrefslogtreecommitdiff
path: root/ext/strscan/strscan.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/strscan/strscan.c')
-rw-r--r--ext/strscan/strscan.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index 39d3d8b..8997cbf 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);