[前][次][番号順一覧][スレッド一覧]

ruby-changes:40703

From: nobu <ko1@a...>
Date: Sun, 29 Nov 2015 11:25:39 +0900 (JST)
Subject: [ruby-changes:40703] nobu:r52782 (trunk): version.c: remove ruby_engine_name

nobu	2015-11-29 11:25:12 +0900 (Sun, 29 Nov 2015)

  New Revision: 52782

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52782

  Log:
    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.

  Modified files:
    trunk/internal.h
    trunk/ruby.c
    trunk/version.c
    trunk/vm_backtrace.c
Index: vm_backtrace.c
===================================================================
--- vm_backtrace.c	(revision 52781)
+++ vm_backtrace.c	(revision 52782)
@@ -333,7 +333,7 @@ location_to_str(rb_backtrace_location_t https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L333
 	}
 	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) https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L683
     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;
 }
 
Index: internal.h
===================================================================
--- internal.h	(revision 52781)
+++ internal.h	(revision 52782)
@@ -1187,7 +1187,7 @@ VALUE rb_attr_delete(VALUE, ID); https://github.com/ruby/ruby/blob/trunk/internal.h#L1187
 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);
Index: version.c
===================================================================
--- version.c	(revision 52781)
+++ version.c	(revision 52782)
@@ -33,7 +33,6 @@ const int ruby_patchlevel = RUBY_PATCHLE https://github.com/ruby/ruby/blob/trunk/version.c#L33
 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) https://github.com/ruby/ruby/blob/trunk/version.c#L41
     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) https://github.com/ruby/ruby/blob/trunk/version.c#L75
      * 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.
      */
Index: ruby.c
===================================================================
--- ruby.c	(revision 52781)
+++ ruby.c	(revision 52782)
@@ -1678,7 +1678,7 @@ load_file_internal(VALUE argp_v) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1678
 		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) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1694
 		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 **ar https://github.com/ruby/ruby/blob/trunk/ruby.c#L2083
 {
     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);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]