summaryrefslogtreecommitdiffstats
path: root/win/tclWinFile.c
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2004-07-02 16:52:17 (GMT)
committervincentdarley <vincentdarley>2004-07-02 16:52:17 (GMT)
commit236570f0308763b7305fcff43431ac39f7e2d835 (patch)
tree03e96b9bdf3fa1670ff4ef064d46d27dd3d089c0 /win/tclWinFile.c
parent427b3847a04534c1a0703535fe306878274bcf20 (diff)
downloadtcl-236570f0308763b7305fcff43431ac39f7e2d835.zip
tcl-236570f0308763b7305fcff43431ac39f7e2d835.tar.gz
tcl-236570f0308763b7305fcff43431ac39f7e2d835.tar.bz2
backport of recent fs fixes from cvs head
Diffstat (limited to 'win/tclWinFile.c')
-rw-r--r--win/tclWinFile.c63
1 files changed, 46 insertions, 17 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index b29e9d1..574577e 100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinFile.c,v 1.44.2.8 2004/05/19 22:50:23 dkf Exp $
+ * RCS: @(#) $Id: tclWinFile.c,v 1.44.2.9 2004/07/02 16:52:20 vincentdarley Exp $
*/
//#define _WIN32_WINNT 0x0500
@@ -2263,26 +2263,55 @@ TclpObjNormalizePath(interp, pathPtr, nextCheckpoint)
}
Tcl_DStringAppend(&dsNorm,nativePath,Tcl_DStringLength(&ds));
} else {
- WIN32_FIND_DATAW fData;
- HANDLE handle;
+ char *checkDots = NULL;
- handle = FindFirstFileW((WCHAR*)nativePath, &fData);
- if (handle == INVALID_HANDLE_VALUE) {
- /* This is usually the '/' in 'c:/' at end of string */
- Tcl_DStringAppend(&dsNorm,(CONST char*)L"/",
- sizeof(WCHAR));
+ if (lastValidPathEnd[1] == '.') {
+ checkDots = lastValidPathEnd + 1;
+ while (checkDots < currentPathEndPosition) {
+ if (*checkDots != '.') {
+ checkDots = NULL;
+ break;
+ }
+ checkDots++;
+ }
+ }
+ if (checkDots != NULL) {
+ int dotLen = currentPathEndPosition - lastValidPathEnd;
+ /*
+ * Path is just dots. We shouldn't really
+ * ever see a path like that. However, to be
+ * nice we at least don't mangle the path --
+ * we just add the dots as a path segment and
+ * continue
+ */
+ Tcl_DStringAppend(&dsNorm,
+ (TCHAR*)((WCHAR*)(nativePath
+ + Tcl_DStringLength(&ds))
+ - dotLen),
+ (int)(dotLen * sizeof(WCHAR)));
} else {
- WCHAR *nativeName;
- if (fData.cFileName[0] != '\0') {
- nativeName = fData.cFileName;
+ /* Normal path */
+ WIN32_FIND_DATAW fData;
+ HANDLE handle;
+
+ handle = FindFirstFileW((WCHAR*)nativePath, &fData);
+ if (handle == INVALID_HANDLE_VALUE) {
+ /* This is usually the '/' in 'c:/' at end of string */
+ Tcl_DStringAppend(&dsNorm,(CONST char*)L"/",
+ sizeof(WCHAR));
} else {
- nativeName = fData.cAlternateFileName;
+ WCHAR *nativeName;
+ if (fData.cFileName[0] != '\0') {
+ nativeName = fData.cFileName;
+ } else {
+ nativeName = fData.cAlternateFileName;
+ }
+ FindClose(handle);
+ Tcl_DStringAppend(&dsNorm,(CONST char*)L"/",
+ sizeof(WCHAR));
+ Tcl_DStringAppend(&dsNorm,(TCHAR*)nativeName,
+ (int) (wcslen(nativeName)*sizeof(WCHAR)));
}
- FindClose(handle);
- Tcl_DStringAppend(&dsNorm,(CONST char*)L"/",
- sizeof(WCHAR));
- Tcl_DStringAppend(&dsNorm,(TCHAR*)nativeName,
- (int) (wcslen(nativeName)*sizeof(WCHAR)));
}
}
Tcl_DStringFree(&ds);