summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2003-06-02 15:58:45 (GMT)
committervincentdarley <vincentdarley>2003-06-02 15:58:45 (GMT)
commit753ae00890d0e80ad9d637fea2871c566e67bb17 (patch)
tree94b30a67a604eb763213f7df1908a1b51a649906
parentac8bb107ca7d45115b1877f6ed9d25b16456b4b4 (diff)
downloadtcl-753ae00890d0e80ad9d637fea2871c566e67bb17.zip
tcl-753ae00890d0e80ad9d637fea2871c566e67bb17.tar.gz
tcl-753ae00890d0e80ad9d637fea2871c566e67bb17.tar.bz2
fix to WinTcl file rename error message
-rw-r--r--ChangeLog8
-rw-r--r--tests/fCmd.test27
-rw-r--r--win/tclWinFCmd.c12
3 files changed, 44 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 71614d4..54bd747 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-06-02 Vince Darley <vincentdarley@users.sourceforge.net>
+
+ * win/tclWinFCmd.c:
+ * tests/fCmd.test: fix to [Bug #747575] in which a bad error
+ message is given when trying to rename a busy directory to
+ one with the same prefix, but not the same name. Added three
+ new tests.
+
2003-05-23 D. Richard Hipp <drh@hwaci.com>
* win/tclWinTime.c: Add tests to detect and avoid a division by zero
diff --git a/tests/fCmd.test b/tests/fCmd.test
index 8c5d944..5b2a89f 100644
--- a/tests/fCmd.test
+++ b/tests/fCmd.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: fCmd.test,v 1.27 2003/04/11 15:59:59 vincentdarley Exp $
+# RCS: @(#) $Id: fCmd.test,v 1.28 2003/06/02 15:58:46 vincentdarley Exp $
#
if {[lsearch [namespace children] ::tcltest] == -1} {
@@ -861,6 +861,31 @@ test fCmd-9.14 {file rename: comprehensive: dir into self} {notRoot} {
file mkdir td1
list [glob td*] [list [catch {file rename td1 td1} msg] $msg]
} [subst {td1 {1 {error renaming "td1" to "[file join td1 td1]": trying to rename a volume or move a directory into itself}}}]
+test fCmd-9.14.1 {file rename: comprehensive: dir into self} {notRoot} {
+ cleanup
+ file mkdir td1
+ file rename td1 td1x
+ file rename td1x td1
+ set msg "ok"
+} {ok}
+test fCmd-9.14.2 {file rename: comprehensive: dir into self} {notRoot} {
+ cleanup
+ file mkdir td1
+ set dir [pwd]
+ cd td1
+ set res [list [catch {file rename [file join .. td1] [file join .. td1x]} msg] $msg]
+ cd $dir
+ set res
+} [subst {1 {error renaming "[file join .. td1]" to "[file join .. td1x]": permission denied}}]
+test fCmd-9.14.3 {file rename: comprehensive: dir into self} {notRoot} {
+ cleanup
+ file mkdir td1
+ set dir [pwd]
+ cd td1
+ set res [list [catch {file rename [file join .. td1] [file join .. td1 foo]} msg] $msg]
+ cd $dir
+ set res
+} [subst {1 {error renaming "[file join .. td1]" to "[file join .. td1 foo]": trying to rename a volume or move a directory into itself}}]
test fCmd-9.15 {file rename: comprehensive: source and target incompatible} \
{notRoot} {
cleanup
diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c
index 621d352..3f2addb 100644
--- a/win/tclWinFCmd.c
+++ b/win/tclWinFCmd.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinFCmd.c,v 1.35 2003/02/07 15:29:33 vincentdarley Exp $
+ * RCS: @(#) $Id: tclWinFCmd.c,v 1.36 2003/06/02 15:58:47 vincentdarley Exp $
*/
#include "tclWinInt.h"
@@ -302,7 +302,15 @@ DoRenameFile(
src = Tcl_WinTCharToUtf((TCHAR *) nativeSrcPath, -1, &srcString);
dst = Tcl_WinTCharToUtf((TCHAR *) nativeDstPath, -1, &dstString);
- if (strncmp(src, dst, (size_t) Tcl_DStringLength(&srcString)) == 0) {
+ /*
+ * Check whether the destination path is actually inside the
+ * source path. This is true if the prefix matches, and the next
+ * character is either end-of-string or a directory separator
+ */
+ if ((strncmp(src, dst, (size_t) Tcl_DStringLength(&srcString)) == 0)
+ && (dst[Tcl_DStringLength(&srcString)] == '\\'
+ || dst[Tcl_DStringLength(&srcString)] == '/'
+ || dst[Tcl_DStringLength(&srcString)] == '\0')) {
/*
* Trying to move a directory into itself.
*/