aboutsummaryrefslogtreecommitdiffstats
path: root/win32
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-28 06:54:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-28 06:54:03 +0000
commitb6e36b96cde8890cc4f267a92f4bf2284e8033e1 (patch)
tree23329acc5b6a21679cf612d79deba6ff93631583 /win32
parent2aa92684525fcc5e378586913b09b85fcc00beca (diff)
downloadruby-b6e36b96cde8890cc4f267a92f4bf2284e8033e1.tar.gz
win32/file.c: remove unnecessary code
* win32/file.c (replace_to_long_name): remove unnecessary backward scan for the last directory separator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/file.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/win32/file.c b/win32/file.c
index becbd5f38c..25c9027d29 100644
--- a/win32/file.c
+++ b/win32/file.c
@@ -257,24 +257,19 @@ replace_to_long_name(wchar_t **wfullpath, size_t size, int heap)
find_handle = FindFirstFileW(*wfullpath, &find_data);
if (find_handle != INVALID_HANDLE_VALUE) {
- size_t trail_pos = wcslen(*wfullpath);
+ size_t trail_pos = pos - *wfullpath + IS_DIR_SEPARATOR_P(*pos);
size_t file_len = wcslen(find_data.cFileName);
FindClose(find_handle);
- while (trail_pos > 0) {
- if (IS_DIR_SEPARATOR_P((*wfullpath)[trail_pos]))
- break;
- trail_pos--;
- }
- size = trail_pos + 1 + file_len;
+ size = trail_pos + file_len;
if ((size + 1) > sizeof(*wfullpath) / sizeof((*wfullpath)[0])) {
wchar_t *buf = (wchar_t *)xmalloc((size + 1) * sizeof(wchar_t));
- wcsncpy(buf, *wfullpath, trail_pos + 1);
+ wcsncpy(buf, *wfullpath, trail_pos);
if (heap)
xfree(*wfullpath);
*wfullpath = buf;
}
- wcsncpy(*wfullpath + trail_pos + 1, find_data.cFileName, file_len + 1);
+ wcsncpy(*wfullpath + trail_pos, find_data.cFileName, file_len + 1);
}
return size;
}