ruby-changes:37778
From: usa <ko1@a...>
Date: Fri, 6 Mar 2015 02:28:21 +0900 (JST)
Subject: [ruby-changes:37778] usa:r49859 (trunk): * dir.c (replace_real_basename): shouldn't create Ruby object before
usa 2015-03-06 02:28:07 +0900 (Fri, 06 Mar 2015) New Revision: 49859 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49859 Log: * dir.c (replace_real_basename): shouldn't create Ruby object before the object system is loaded. [ruby-core:68430] [Bug #10941] Modified files: trunk/ChangeLog trunk/dir.c Index: ChangeLog =================================================================== --- ChangeLog (revision 49858) +++ ChangeLog (revision 49859) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Mar 6 02:26:03 2015 NAKAMURA Usaku <usa@r...> + + * dir.c (replace_real_basename): shouldn't create Ruby object before + the object system is loaded. + [ruby-core:68430] [Bug #10941] + Wed Mar 5 16:58:43 2015 Kazuki Tanaka <gogotanaka@r...> * hash.c: [DOC] #delete method actually returns nil, if the key Index: dir.c =================================================================== --- dir.c (revision 49858) +++ dir.c (revision 49859) @@ -1488,12 +1488,22 @@ replace_real_basename(char *path, long b https://github.com/ruby/ruby/blob/trunk/dir.c#L1488 free(wplain); if (h == INVALID_HANDLE_VALUE) return path; FindClose(h); - tmp = rb_w32_conv_from_wchar(fd.cFileName, enc); - wlen = RSTRING_LEN(tmp); - path = GLOB_REALLOC(path, base + wlen + 1); - memcpy(path + base, RSTRING_PTR(tmp), wlen); + if (tmp) { + tmp = rb_w32_conv_from_wchar(fd.cFileName, enc); + wlen = RSTRING_LEN(tmp); + path = GLOB_REALLOC(path, base + wlen + 1); + memcpy(path + base, RSTRING_PTR(tmp), wlen); + rb_str_resize(tmp, 0); + } + else { + char *utf8filename; + wlen = WideCharToMultiByte(CP_UTF8, 0, fd.cFileName, -1, NULL, 0, NULL, NULL); + utf8filename = GLOB_REALLOC(0, wlen); + WideCharToMultiByte(CP_UTF8, 0, fd.cFileName, -1, utf8filename, wlen, NULL, NULL); + memcpy(path + base, utf8filename, wlen); + GLOB_FREE(utf8filename); + } path[base + wlen] = 0; - rb_str_resize(tmp, 0); return path; } #elif USE_NAME_ON_FS == 1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/