summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-13 01:03:33 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-13 01:03:33 +0000
commite64a495bf8d4467b770f33902b29c91e95d4971e (patch)
treeec30cf01ca1434cf1930b4cbbc908e77a8c8bbf0 /string.c
parent2adcc421f386ac8f8d59858a02422ffcaf0b1f49 (diff)
merges r20651 from trunk into ruby_1_9_1.
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/string.c b/string.c
index a8b3f29cd9..a48dd69c47 100644
--- a/string.c
+++ b/string.c
@@ -1240,7 +1240,8 @@ rb_string_value(volatile VALUE *ptr)
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_str_split_m(int argc, VALUE *argv, VALUE str)
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);
}
@@ -7007,8 +7009,9 @@ rb_to_id(VALUE name)
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 */