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

ruby-changes:9114

From: nobu <ko1@a...>
Date: Fri, 12 Dec 2008 10:19:41 +0900 (JST)
Subject: [ruby-changes:9114] Ruby:r20651 (trunk): * string.c (rb_string_value_ptr, rb_to_id): do not use a side

nobu	2008-12-12 10:19:23 +0900 (Fri, 12 Dec 2008)

  New Revision: 20651

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

  Log:
    * string.c (rb_string_value_ptr, rb_to_id): do not use a side
      effect expression in RSTRING_PTR.
    * string.c (rb_str_split_m): simplified the argument of
      RSTRING_LEN.

  Modified files:
    trunk/ChangeLog
    trunk/string.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 20650)
+++ ChangeLog	(revision 20651)
@@ -1,3 +1,11 @@
+Fri Dec 12 10:19:21 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c (rb_string_value_ptr, rb_to_id): do not use a side
+	  effect expression in RSTRING_PTR.
+
+	* string.c (rb_str_split_m): simplified the argument of
+	  RSTRING_LEN.
+
 Thu Dec 11 23:48:00 2008  Tadayoshi Funaba  <tadf@d...>
 
 	* lib/cmath.rb (sqrt): should pass nan to the original method.
Index: string.c
===================================================================
--- string.c	(revision 20650)
+++ string.c	(revision 20651)
@@ -1240,7 +1240,8 @@
 char *
 rb_string_value_ptr(volatile VALUE *ptr)
 {
-    return RSTRING_PTR(rb_string_value(ptr));
+    VALUE str = rb_string_value(ptr);
+    return RSTRING_PTR(str);
 }
 
 char *
@@ -5433,8 +5434,9 @@
 	rb_ary_push(result, tmp);
     }
     if (NIL_P(limit) && lim == 0) {
-	while (RARRAY_LEN(result) > 0 &&
-	       RSTRING_LEN(RARRAY_PTR(result)[RARRAY_LEN(result)-1]) == 0)
+	long len;
+	while ((len = RARRAY_LEN(result)) > 0 &&
+	       (tmp = RARRAY_PTR(result)[len-1], RSTRING_LEN(tmp) == 0))
 	    rb_ary_pop(result);
     }
 
@@ -7030,8 +7032,9 @@
       default:
 	tmp = rb_check_string_type(name);
 	if (NIL_P(tmp)) {
+	    tmp = rb_inspect(name);
 	    rb_raise(rb_eTypeError, "%s is not a symbol",
-		     RSTRING_PTR(rb_inspect(name)));
+		     RSTRING_PTR(tmp));
 	}
 	name = tmp;
 	/* fall through */

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

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