* 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:
parent
85c476a342
commit
9ba4002960
@ -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>
|
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
|
* ext/socket/socket.c (socks_init): typo fixed. a patch from Sven
|
||||||
|
2
array.c
2
array.c
@ -2826,7 +2826,7 @@ rb_ary_shuffle_bang(VALUE ary)
|
|||||||
* call-seq:
|
* call-seq:
|
||||||
* array.shuffle -> an_array
|
* 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 = [ 1, 2, 3 ] #=> [1, 2, 3]
|
||||||
* a.shuffle #=> [2, 3, 1]
|
* a.shuffle #=> [2, 3, 1]
|
||||||
|
7
string.c
7
string.c
@ -682,12 +682,15 @@ rb_str_resize(VALUE str, long len)
|
|||||||
rb_str_modify(str);
|
rb_str_modify(str);
|
||||||
if (len != RSTRING_LEN(str)) {
|
if (len != RSTRING_LEN(str)) {
|
||||||
if (STR_EMBED_P(str)) {
|
if (STR_EMBED_P(str)) {
|
||||||
|
char *ptr;
|
||||||
if (len <= RSTRING_EMBED_LEN_MAX) {
|
if (len <= RSTRING_EMBED_LEN_MAX) {
|
||||||
STR_SET_EMBED_LEN(str, len);
|
STR_SET_EMBED_LEN(str, len);
|
||||||
RSTRING_PTR(str)[len] = '\0';
|
RSTRING_PTR(str)[len] = '\0';
|
||||||
return str;
|
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);
|
STR_SET_NOEMBED(str);
|
||||||
}
|
}
|
||||||
else if (RSTRING_LEN(str) < len || RSTRING_LEN(str) - len > 1024) {
|
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) {
|
if (RSTRING_LEN(s) != 1) {
|
||||||
rb_raise(rb_eTypeError,
|
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));
|
RSTRING_LEN(s));
|
||||||
}
|
}
|
||||||
c = RSTRING_PTR(s)[0] & 0xff;
|
c = RSTRING_PTR(s)[0] & 0xff;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user