From 18d0c0fb8b040e9fa16d8ea57d37516e815f368a Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 19 Dec 2011 17:01:37 +0000 Subject: [PATCH] * syscalls.cc (rename): Fix typo in comment. Fix condition to handle the case oldpath is no .lnk symlink and newpath points to an existing .lnk symlink or .exe file and no explicit .lnk suffix has been given in oldpath. Add a comment to explain. --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/syscalls.cc | 10 +++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 85a8a9633..507593289 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2011-12-19 Corinna Vinschen + + * syscalls.cc (rename): Fix typo in comment. Fix condition to handle + the case oldpath is no .lnk symlink and newpath points to an existing + .lnk symlink or .exe file and no explicit .lnk suffix has been given + in oldpath. Add a comment to explain. + 2011-12-19 Corinna Vinschen * dcrt0.cc (dll_crt0_0): Check for wincap.wow64_has_secondary_stack diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index f86e0442a..e96116e84 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -2162,7 +2162,7 @@ rename (const char *oldpath, const char *newpath) { /* Never append .exe suffix if oldpath had .exe suffix given explicitely, or if newfile is a binary (in which case the given - name probably makes sesne as it is), or if the destination + name probably makes sense as it is), or if the destination filename has one of the blessed executable suffixes. */ if (!old_explicit_suffix && oldpc.known_suffix && !newpc.is_binary () @@ -2174,8 +2174,12 @@ rename (const char *oldpath, const char *newpath) } else { - if ((RtlEqualUnicodePathSuffix (newpc.get_nt_native_path (), - &ro_u_lnk, TRUE) + /* If the new path is an existing .lnk symlink or a .exe file, + but the new path has not been specified with explicit suffix, + rename to the new name without suffix, as expected, but also + remove the clashing symlink or executable. Did I ever mention + how I hate the file suffix idea? */ + if ((newpc.is_lnk_special () || RtlEqualUnicodePathSuffix (newpc.get_nt_native_path (), &ro_u_exe, TRUE)) && !new_explicit_suffix)