From c423d3cbf2b8413560c20cc44a4424e7c5062109 Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 12 Dec 2005 03:04:53 +0000 Subject: [PATCH] precedes registering global VALUE variables before initializing it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- eval.c | 8 ++++---- gc.c | 2 +- io.c | 11 +++++------ object.c | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/eval.c b/eval.c index 7be4861ceb..54737f825d 100644 --- a/eval.c +++ b/eval.c @@ -7612,8 +7612,8 @@ Init_eval(void) rb_define_method(rb_mKernel, "respond_to?", obj_respond_to, -1); respond_to = rb_intern("respond_to?"); - basic_respond_to = rb_method_node(rb_cObject, respond_to); rb_global_variable((VALUE*)&basic_respond_to); + basic_respond_to = rb_method_node(rb_cObject, respond_to); rb_define_global_function("raise", rb_f_raise, -1); rb_define_global_function("fail", rb_f_raise, -1); @@ -9355,13 +9355,13 @@ Init_Proc(void) rb_define_method(rb_eLocalJumpError, "exit_value", localjump_xvalue, 0); rb_define_method(rb_eLocalJumpError, "reason", localjump_reason, 0); - exception_error = rb_exc_new2(rb_eFatal, "exception reentered"); rb_global_variable(&exception_error); + exception_error = rb_exc_new2(rb_eFatal, "exception reentered"); rb_eSysStackError = rb_define_class("SystemStackError", rb_eException); + rb_global_variable(&sysstack_error); sysstack_error = rb_exc_new2(rb_eSysStackError, "stack level too deep"); OBJ_TAINT(sysstack_error); - rb_global_variable(&sysstack_error); rb_cProc = rb_define_class("Proc", rb_cObject); rb_undef_alloc_func(rb_cProc); @@ -12815,9 +12815,9 @@ Init_Thread(void) rb_define_method(cThGroup, "enclose", thgroup_enclose, 0); rb_define_method(cThGroup, "enclosed?", thgroup_enclosed_p, 0); rb_define_method(cThGroup, "add", thgroup_add, 1); + rb_global_variable(&thgroup_default); thgroup_default = rb_obj_alloc(cThGroup); rb_define_const(cThGroup, "Default", thgroup_default); - rb_global_variable(&thgroup_default); /* allocate main thread */ main_thread = rb_thread_alloc(rb_cThread); diff --git a/gc.c b/gc.c index 46523dcdc4..41793890ee 100644 --- a/gc.c +++ b/gc.c @@ -1909,6 +1909,6 @@ Init_GC(void) source_filenames = st_init_strtable(); - nomem_error = rb_exc_new2(rb_eNoMemError, "failed to allocate memory"); rb_global_variable(&nomem_error); + nomem_error = rb_exc_new2(rb_eNoMemError, "failed to allocate memory"); } diff --git a/io.c b/io.c index dc91b41f74..be3984e7d7 100644 --- a/io.c +++ b/io.c @@ -5557,12 +5557,12 @@ Init_IO(void) rb_define_method(rb_cIO, "pid", rb_io_pid, 0); rb_define_method(rb_cIO, "inspect", rb_io_inspect, 0); - rb_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO, ""); rb_define_variable("$stdin", &rb_stdin); - rb_stdout = prep_stdio(stdout, FMODE_WRITABLE, rb_cIO, ""); + rb_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO, ""); rb_define_hooked_variable("$stdout", &rb_stdout, 0, stdout_setter); - rb_stderr = prep_stdio(stderr, FMODE_WRITABLE|FMODE_SYNC, rb_cIO, ""); + rb_stdout = prep_stdio(stdout, FMODE_WRITABLE, rb_cIO, ""); rb_define_hooked_variable("$stderr", &rb_stderr, 0, stdout_setter); + rb_stderr = prep_stdio(stderr, FMODE_WRITABLE|FMODE_SYNC, rb_cIO, ""); rb_define_hooked_variable("$>", &rb_stdout, 0, stdout_setter); orig_stdout = rb_stdout; rb_deferr = orig_stderr = rb_stderr; @@ -5576,10 +5576,9 @@ Init_IO(void) rb_define_global_const("STDOUT", rb_stdout); rb_define_global_const("STDERR", rb_stderr); + rb_define_readonly_variable("$<", &argf); argf = rb_obj_alloc(rb_cObject); rb_extend_object(argf, rb_mEnumerable); - - rb_define_readonly_variable("$<", &argf); rb_define_global_const("ARGF", argf); rb_define_singleton_method(argf, "to_s", argf_to_s, 0); @@ -5619,8 +5618,8 @@ Init_IO(void) rb_define_singleton_method(argf, "lineno=", argf_set_lineno, 1); rb_global_variable(¤t_file); - filename = rb_str_new2("-"); rb_define_readonly_variable("$FILENAME", &filename); + filename = rb_str_new2("-"); rb_define_virtual_variable("$-i", opt_i_get, opt_i_set); diff --git a/object.c b/object.c index 825c4e627b..4c6667ac05 100644 --- a/object.c +++ b/object.c @@ -2524,8 +2524,8 @@ Init_Object(void) rb_cData = rb_define_class("Data", rb_cObject); rb_undef_alloc_func(rb_cData); - ruby_top_self = rb_obj_alloc(rb_cObject); rb_global_variable(&ruby_top_self); + ruby_top_self = rb_obj_alloc(rb_cObject); rb_define_singleton_method(ruby_top_self, "to_s", main_to_s, 0); rb_cTrueClass = rb_define_class("TrueClass", rb_cObject);