ruby-changes:39030
From: nobu <ko1@a...>
Date: Fri, 3 Jul 2015 07:13:55 +0900 (JST)
Subject: [ruby-changes:39030] nobu:r51111 (trunk): dir.c: set errno
nobu 2015-07-03 07:13:17 +0900 (Fri, 03 Jul 2015) New Revision: 51111 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51111 Log: dir.c: set errno * dir.c (replace_real_basename): Win32 API does not set errno, get the last error by GetLastError() and map to errno. [Bug #10015] Modified files: trunk/ChangeLog trunk/dir.c Index: ChangeLog =================================================================== --- ChangeLog (revision 51110) +++ ChangeLog (revision 51111) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jul 3 07:13:11 2015 Nobuyoshi Nakada <nobu@r...> + + * dir.c (replace_real_basename): Win32 API does not set errno, get + the last error by GetLastError() and map to errno. [Bug #10015] + Thu Jul 2 21:32:06 2015 Nobuyoshi Nakada <nobu@r...> * dir.c (replace_real_basename): show warnings at errors. Index: dir.c =================================================================== --- dir.c (revision 51110) +++ dir.c (revision 51111) @@ -1525,6 +1525,7 @@ replace_real_basename(char *path, long b https://github.com/ruby/ruby/blob/trunk/dir.c#L1525 WCHAR *wplain; HANDLE h = INVALID_HANDLE_VALUE; long wlen; + int e = 0; if (enc && enc != rb_usascii_encoding() && enc != rb_ascii8bit_encoding() && @@ -1536,13 +1537,17 @@ replace_real_basename(char *path, long b https://github.com/ruby/ruby/blob/trunk/dir.c#L1537 wplain = rb_w32_mbstr_to_wstr(CP_UTF8, plainname, -1, &wlen); if (tmp) rb_str_resize(tmp, 0); if (!wplain) return path; - if (GetFileAttributesExW(wplain, GetFileExInfoStandard, &fa)) + if (GetFileAttributesExW(wplain, GetFileExInfoStandard, &fa)) { h = FindFirstFileW(wplain, &fd); + e = rb_w32_map_errno(GetLastError()); + } free(wplain); if (h == INVALID_HANDLE_VALUE) { *type = path_noent; - if (!to_be_ignored(errno)) + if (e && !to_be_ignored(e)) { + errno = e; sys_warning(path, enc); + } return path; } FindClose(h); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/