mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
file.c: hide result
* file.c (rb_file_join): hide the result under construction until return. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a583f42062
commit
37b8f7b84f
2 changed files with 6 additions and 1 deletions
|
@ -1,4 +1,7 @@
|
||||||
Tue Oct 16 11:27:04 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Oct 16 11:30:18 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* file.c (rb_file_join): hide the result under construction until
|
||||||
|
return.
|
||||||
|
|
||||||
* file.c (rb_file_join): check nul-byte only for strings, since
|
* file.c (rb_file_join): check nul-byte only for strings, since
|
||||||
FilePathStringValue() does it. [ruby-core:48012] [Bug #7168]
|
FilePathStringValue() does it. [ruby-core:48012] [Bug #7168]
|
||||||
|
|
2
file.c
2
file.c
|
@ -3936,6 +3936,7 @@ rb_file_join(VALUE ary, VALUE sep)
|
||||||
len += RSTRING_LEN(sep) * (RARRAY_LEN(ary) - 1);
|
len += RSTRING_LEN(sep) * (RARRAY_LEN(ary) - 1);
|
||||||
}
|
}
|
||||||
result = rb_str_buf_new(len);
|
result = rb_str_buf_new(len);
|
||||||
|
RBASIC(result)->klass = 0;
|
||||||
OBJ_INFECT(result, ary);
|
OBJ_INFECT(result, ary);
|
||||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||||
tmp = RARRAY_PTR(ary)[i];
|
tmp = RARRAY_PTR(ary)[i];
|
||||||
|
@ -3973,6 +3974,7 @@ rb_file_join(VALUE ary, VALUE sep)
|
||||||
}
|
}
|
||||||
rb_str_buf_append(result, tmp);
|
rb_str_buf_append(result, tmp);
|
||||||
}
|
}
|
||||||
|
RBASIC(result)->klass = rb_cString;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue