[前][次][番号順一覧][スレッド一覧]

ruby-changes:42732

From: nobu <ko1@a...>
Date: Thu, 28 Apr 2016 14:57:28 +0900 (JST)
Subject: [ruby-changes:42732] nobu:r54806 (trunk): win32/file.c: remove unnecessary code

nobu	2016-04-28 15:54:03 +0900 (Thu, 28 Apr 2016)

  New Revision: 54806

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54806

  Log:
    win32/file.c: remove unnecessary code
    
    * win32/file.c (replace_to_long_name): remove unnecessary backward
      scan for the last directory separator.

  Modified files:
    trunk/win32/file.c
Index: win32/file.c
===================================================================
--- win32/file.c	(revision 54805)
+++ win32/file.c	(revision 54806)
@@ -257,24 +257,19 @@ replace_to_long_name(wchar_t **wfullpath https://github.com/ruby/ruby/blob/trunk/win32/file.c#L257
 
     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;
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]