1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* string.c (rb_str_resize): should copy embedded string to

malloc'ed buffer.  a patch from <nobu at ruby-lang.org> in
  [ruby-dev:29369].  fixed: [ruby-dev:29368]

* string.c (rb_str_ord): use %ld specifier since STRING_LEN() is a
  long.  [ruby-dev:29369]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2006-09-01 13:07:05 +00:00
parent 85c476a342
commit 9ba4002960
3 changed files with 15 additions and 3 deletions

View file

@ -1,3 +1,12 @@
Fri Sep 1 22:02:08 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_resize): should copy embedded string to
malloc'ed buffer. a patch from <nobu at ruby-lang.org> in
[ruby-dev:29369]. fixed: [ruby-dev:29368]
* string.c (rb_str_ord): use %ld specifier since STRING_LEN() is a
long. [ruby-dev:29369]
Fri Sep 1 21:41:12 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/socket/socket.c (socks_init): typo fixed. a patch from Sven

View file

@ -2826,7 +2826,7 @@ rb_ary_shuffle_bang(VALUE ary)
* call-seq:
* array.shuffle -> an_array
*
* Returns a new array that with elements of this array shuffled.
* Returns a new array with elements of this array shuffled.
*
* a = [ 1, 2, 3 ] #=> [1, 2, 3]
* a.shuffle #=> [2, 3, 1]

View file

@ -682,12 +682,15 @@ rb_str_resize(VALUE str, long len)
rb_str_modify(str);
if (len != RSTRING_LEN(str)) {
if (STR_EMBED_P(str)) {
char *ptr;
if (len <= RSTRING_EMBED_LEN_MAX) {
STR_SET_EMBED_LEN(str, len);
RSTRING_PTR(str)[len] = '\0';
return str;
}
RSTRING(str)->as.heap.ptr = ALLOC_N(char,len+1);
ptr = ALLOC_N(char,len+1);
MEMCPY(ptr, RSTRING(str)->ary, char, RSTRING_LEN(str));
RSTRING(str)->as.heap.ptr = ptr;
STR_SET_NOEMBED(str);
}
else if (RSTRING_LEN(str) < len || RSTRING_LEN(str) - len > 1024) {
@ -4165,7 +4168,7 @@ rb_str_ord(VALUE s)
if (RSTRING_LEN(s) != 1) {
rb_raise(rb_eTypeError,
"expacted a characer, but string of size %d given",
"expacted a characer, but string of size %ld given",
RSTRING_LEN(s));
}
c = RSTRING_PTR(s)[0] & 0xff;