aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-17 04:55:47 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-17 04:55:47 +0000
commitc2eea795741f3975ac62dd6b56f09ad590b999fb (patch)
tree15f33dd753ed7d23321d3116810d9586f0471bba /file.c
parent071e705e05744b62c0f9ffd54411a9bf5f82c081 (diff)
downloadruby-c2eea795741f3975ac62dd6b56f09ad590b999fb.tar.gz
string.c: rb_str_cat_conv_enc_opts
* file.c (rb_file_expand_path_internal): concatenate converted string to the result instead of making converted string and append it. * string.c (rb_str_cat_conv_enc_opts): from rb_str_conv_enc_opts, separate function to concatenate with transcoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/file.c b/file.c
index 60975104f7..15ce4c1f4e 100644
--- a/file.c
+++ b/file.c
@@ -3604,14 +3604,16 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
++p;
wlen = (int)len;
len = WideCharToMultiByte(CP_UTF8, 0, wfd.cFileName, wlen, NULL, 0, NULL, NULL);
- BUFCHECK(bdiff + len >= buflen);
- WideCharToMultiByte(CP_UTF8, 0, wfd.cFileName, wlen, p, len + 1, NULL, NULL);
- if (tmp != result) {
- rb_str_buf_cat(tmp, p, len);
- tmp = rb_str_encode(tmp, rb_enc_from_encoding(enc), 0, Qnil);
- len = RSTRING_LEN(tmp);
+ if (tmp == result) {
BUFCHECK(bdiff + len >= buflen);
- memcpy(p, RSTRING_PTR(tmp), len);
+ WideCharToMultiByte(CP_UTF8, 0, wfd.cFileName, wlen, p, len + 1, NULL, NULL);
+ }
+ else {
+ rb_str_modify_expand(tmp, len);
+ WideCharToMultiByte(CP_UTF8, 0, wfd.cFileName, wlen, RSTRING_PTR(tmp), len + 1, NULL, NULL);
+ rb_str_cat_conv_enc_opts(result, bdiff, RSTRING_PTR(tmp), len,
+ rb_utf8_encoding(), 0, Qnil);
+ BUFINIT();
rb_str_resize(tmp, 0);
}
p += len;