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

ruby-changes:40167

From: nobu <ko1@a...>
Date: Fri, 23 Oct 2015 23:28:04 +0900 (JST)
Subject: [ruby-changes:40167] nobu:r52248 (trunk): error.c: use fake string

nobu	2015-10-23 23:27:37 +0900 (Fri, 23 Oct 2015)

  New Revision: 52248

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

  Log:
    error.c: use fake string
    
    * error.c (name_err_mesg_to_str): use fake string as rb_str_format
      does not require T_STRING to be cannonical VALUE.

  Modified files:
    trunk/error.c
Index: error.c
===================================================================
--- error.c	(revision 52247)
+++ error.c	(revision 52248)
@@ -1219,19 +1219,22 @@ name_err_mesg_to_str(VALUE obj) https://github.com/ruby/ruby/blob/trunk/error.c#L1219
     mesg = ptr[NAME_ERR_MESG__MESG];
     if (NIL_P(mesg)) return Qnil;
     else {
+	struct RString s_str, d_str;
 	VALUE c, s, d = 0, args[4];
 	int state = 0, singleton = 0;
+	rb_encoding *usascii = rb_usascii_encoding();
 
+#define FAKE_CSTR(v, str) rb_setup_fake_str((v), (str), rb_strlen_lit(str), usascii)
 	obj = ptr[NAME_ERR_MESG__RECV];
 	switch (obj) {
 	  case Qnil:
-	    d = rb_fstring_cstr("nil");
+	    d = FAKE_CSTR(&d_str, "nil");
 	    break;
 	  case Qtrue:
-	    d = rb_fstring_cstr("true");
+	    d = FAKE_CSTR(&d_str, "true");
 	    break;
 	  case Qfalse:
-	    d = rb_fstring_cstr("false");
+	    d = FAKE_CSTR(&d_str, "false");
 	    break;
 	  default:
 	    d = rb_protect(rb_inspect, obj, &state);
@@ -1245,11 +1248,11 @@ name_err_mesg_to_str(VALUE obj) https://github.com/ruby/ruby/blob/trunk/error.c#L1248
 	    break;
 	}
 	if (!singleton) {
-	    s = rb_fstring_cstr(":");
+	    s = FAKE_CSTR(&s_str, ":");
 	    c = rb_class_name(CLASS_OF(obj));
 	}
 	else {
-	    c = s = rb_fstring_cstr("");
+	    c = s = FAKE_CSTR(&s_str, "");
 	}
 	args[0] = ptr[NAME_ERR_MESG__NAME];
 	args[1] = d;

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

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