summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-29 02:25:12 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-29 02:25:12 +0000
commitfc0c2d1cc2f4ec1fb15c73e91cc8aa8d19854c8a (patch)
tree46a96ea9047262f1186214dcede563bfbb879be2
parentd6beaf3215602eac993bebc1aa1bf9b21c947d63 (diff)
version.c: remove ruby_engine_name
* ruby.c (load_file_internal, ruby_process_options): share ruby_engine instead of literal strings. * version.c (Init_version): remove internal `ruby_engine_name`, but set the VM program name in addition to the global constant. * vm_backtrace.c (location_to_str, oldbt_init): use th eVM program name always. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--internal.h2
-rw-r--r--ruby.c6
-rw-r--r--version.c3
-rw-r--r--vm_backtrace.c4
4 files changed, 8 insertions, 7 deletions
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;
}