diff --git a/internal.h b/internal.h index 3b1266fe91..82de64fa60 100644 --- a/internal.h +++ b/internal.h @@ -1187,7 +1187,7 @@ VALUE rb_attr_delete(VALUE, ID); VALUE rb_ivar_lookup(VALUE obj, ID id, VALUE undef); /* version.c */ -extern VALUE ruby_engine_name; +extern const char ruby_engine[]; /* vm_insnhelper.h */ rb_serial_t rb_next_class_serial(void); diff --git a/ruby.c b/ruby.c index 6468ef9710..56ad6c4442 100644 --- a/ruby.c +++ b/ruby.c @@ -1678,7 +1678,7 @@ load_file_internal(VALUE argp_v) if (RSTRING_LEN(line) > 2 && RSTRING_PTR(line)[0] == '#' && RSTRING_PTR(line)[1] == '!') { - if ((p = strstr(RSTRING_PTR(line), "ruby")) != 0) { + if ((p = strstr(RSTRING_PTR(line), ruby_engine)) != 0) { goto start_read; } } @@ -1694,7 +1694,7 @@ load_file_internal(VALUE argp_v) if (NIL_P(line)) return 0; - if ((p = strstr(RSTRING_PTR(line), "ruby")) == 0) { + if ((p = strstr(RSTRING_PTR(line), ruby_engine)) == 0) { /* not ruby script, assume -x flag */ goto search_shebang; } @@ -2083,7 +2083,7 @@ ruby_process_options(int argc, char **argv) { struct cmdline_options opt; VALUE iseq; - const char *script_name = (argc > 0 && argv[0]) ? argv[0] : "ruby"; + const char *script_name = (argc > 0 && argv[0]) ? argv[0] : ruby_engine; ruby_script(script_name); /* for the time being */ rb_argv0 = rb_str_new4(rb_progname); diff --git a/version.c b/version.c index 0aafa926b2..6caf91226a 100644 --- a/version.c +++ b/version.c @@ -33,7 +33,6 @@ const int ruby_patchlevel = RUBY_PATCHLEVEL; const char ruby_description[] = RUBY_DESCRIPTION; const char ruby_copyright[] = RUBY_COPYRIGHT; const char ruby_engine[] = "ruby"; -VALUE ruby_engine_name = Qnil; /*! Defines platform-depended Ruby-level constants */ void @@ -42,6 +41,7 @@ Init_version(void) enum {ruby_patchlevel = RUBY_PATCHLEVEL}; enum {ruby_revision = RUBY_REVISION}; VALUE version; + VALUE ruby_engine_name; /* * The running version of ruby */ @@ -75,6 +75,7 @@ Init_version(void) * The engine or interpreter this ruby uses. */ rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine)); + ruby_set_script_name(ruby_engine_name); /* * The version of the engine or interpreter this ruby uses. */ diff --git a/vm_backtrace.c b/vm_backtrace.c index 077ed5049f..4267b0dd71 100644 --- a/vm_backtrace.c +++ b/vm_backtrace.c @@ -333,7 +333,7 @@ location_to_str(rb_backtrace_location_t *loc) } else { rb_thread_t *th = GET_THREAD(); - file = th->vm->progname ? th->vm->progname : ruby_engine_name; + file = th->vm->progname; lineno = INT2FIX(0); } name = rb_id2str(loc->body.cfunc.mid); @@ -683,7 +683,7 @@ oldbt_init(void *ptr, size_t dmy) struct oldbt_arg *arg = (struct oldbt_arg *)ptr; rb_thread_t *th = GET_THREAD(); - arg->filename = th->vm->progname ? th->vm->progname : ruby_engine_name;; + arg->filename = th->vm->progname; arg->lineno = 0; }