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

ruby-changes:48673

From: ko1 <ko1@a...>
Date: Thu, 16 Nov 2017 14:36:03 +0900 (JST)
Subject: [ruby-changes:48673] ko1:r60789 (trunk): rb_source_location() may return nil.

ko1	2017-11-16 14:35:58 +0900 (Thu, 16 Nov 2017)

  New Revision: 60789

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

  Log:
    rb_source_location() may return nil.
    
    * vm.c (rb_source_location): return nil if path is not found.

  Modified files:
    trunk/eval_error.c
    trunk/vm.c
Index: vm.c
===================================================================
--- vm.c	(revision 60788)
+++ vm.c	(revision 60789)
@@ -1293,7 +1293,7 @@ rb_source_location(int *pline) https://github.com/ruby/ruby/blob/trunk/vm.c#L1293
     }
     else {
 	if (pline) *pline = 0;
-	return 0;
+	return Qnil;
     }
 }
 
@@ -1301,7 +1301,7 @@ const char * https://github.com/ruby/ruby/blob/trunk/vm.c#L1301
 rb_source_loc(int *pline)
 {
     VALUE path = rb_source_location(pline);
-    if (!path) return 0;
+    if (!NIL_P(path)) return NULL;
     return RSTRING_PTR(path);
 }
 
Index: eval_error.c
===================================================================
--- eval_error.c	(revision 60788)
+++ eval_error.c	(revision 60789)
@@ -32,7 +32,7 @@ error_pos_str(void) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L32
     int sourceline;
     VALUE sourcefile = rb_source_location(&sourceline);
 
-    if (sourcefile) {
+    if (!NIL_P(sourcefile)) {
 	ID caller_name;
 	if (sourceline == 0) {
 	    return rb_sprintf("%"PRIsVALUE": ", sourcefile);

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

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