diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-17 04:55:47 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-17 04:55:47 +0000 |
commit | 78baa98e69f741ba92823470ffb3875838c912ab (patch) | |
tree | 15f33dd753ed7d23321d3116810d9586f0471bba /file.c | |
parent | c72ddc4467971871fd7b35597663d0c1879f68c6 (diff) |
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.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -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; |