From bd46ad21958ec0fd071b216deb774ac45f86835b Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 5 Aug 2016 08:22:35 +0000 Subject: [PATCH] win32.c: call get_final_path pointer * win32/win32.c (get_final_path): initialize this pointer without further comparisons. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- win32/win32.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/win32/win32.c b/win32/win32.c index 8fd00831a6..02ec9c9f74 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1819,21 +1819,27 @@ w32_cmdvector(const WCHAR *cmd, char ***vec, UINT cp, rb_encoding *enc) // UNIX compatible directory access functions for NT // -static DWORD -get_final_path(HANDLE f, WCHAR *buf, DWORD len, DWORD flag) +typedef DWORD (WINAPI *get_final_path_func)(HANDLE, WCHAR*, DWORD, DWORD); +static get_final_path_func get_final_path; + +static DWORD WINAPI +get_final_path_fail(HANDLE f, WCHAR *buf, DWORD len, DWORD flag) { - typedef DWORD (WINAPI *get_final_path_func)(HANDLE, WCHAR*, DWORD, DWORD); - static get_final_path_func func = (get_final_path_func)-1; + return 0; +} - if (func == (get_final_path_func)-1) { - func = (get_final_path_func) - get_proc_address("kernel32", "GetFinalPathNameByHandleW", NULL); - } - - if (!func) return 0; +static DWORD WINAPI +get_final_path_unknown(HANDLE f, WCHAR *buf, DWORD len, DWORD flag) +{ + get_final_path_func func = (get_final_path_func) + get_proc_address("kernel32", "GetFinalPathNameByHandleW", NULL); + if (!func) func = get_final_path_fail; + get_final_path = func; return func(f, buf, len, flag); } +static get_final_path_func get_final_path = get_final_path_unknown; + /* License: Ruby's */ /* TODO: better name */ static HANDLE