зеркало из https://github.com/github/ruby.git
* win32/file.c (rb_freopen): need to terminate by NUL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
93446fedd3
Коммит
3e01334fae
|
@ -1,3 +1,7 @@
|
|||
Tue Jun 30 18:38:16 2015 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* win32/file.c (rb_freopen): need to terminate by NUL.
|
||||
|
||||
Tue Jun 30 17:28:25 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* io.c (rb_io_reopen): freopen(3) with OS encoding path.
|
||||
|
|
|
@ -725,11 +725,13 @@ int
|
|||
rb_freopen(VALUE fname, const char *mode, FILE *file)
|
||||
{
|
||||
WCHAR *wname, wmode[4];
|
||||
long len;
|
||||
int e = 0, n = MultiByteToWideChar(CP_ACP, 0, mode, -1, NULL, 0);
|
||||
if (n > numberof(wmode)) return EINVAL;
|
||||
MultiByteToWideChar(CP_ACP, 0, mode, -1, wmode, numberof(wmode));
|
||||
wname = rb_w32_mbstr_to_wstr(CP_UTF8, RSTRING_PTR(fname),
|
||||
rb_long2int(RSTRING_LEN(fname)), NULL);
|
||||
rb_long2int(RSTRING_LEN(fname)) + 1, &len);
|
||||
wname[len - 1] = L'\0';
|
||||
RB_GC_GUARD(fname);
|
||||
#if RUBY_MSVCRT_VERSION < 80 && !defined(HAVE__WFREOPEN_S)
|
||||
e = _wfreopen(wname, wmode, file) ? 0 : errno;
|
||||
|
@ -737,6 +739,7 @@ rb_freopen(VALUE fname, const char *mode, FILE *file)
|
|||
{
|
||||
FILE *newfp = 0;
|
||||
e = _wfreopen_s(&newfp, wname, wmode, file);
|
||||
if (e != 0) cprintf("DEBUG: %d [%ls] [%ls]\n", e, wname, wmode);
|
||||
}
|
||||
#endif
|
||||
xfree(wname);
|
||||
|
|
Загрузка…
Ссылка в новой задаче