diff options
author | sebres <sebres@users.sourceforge.net> | 2024-09-13 14:26:26 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2024-09-13 14:26:26 (GMT) |
commit | f2b14cb7f00034cf7c9ee3e5681e4c912ca7ff9c (patch) | |
tree | 4b4c9c10fce59f32c11fad58a6bcc896c9f810dd /win | |
parent | bddda240611ea5ba0974d4e6d424c29f29f7057c (diff) | |
download | tcl-f2b14cb7f00034cf7c9ee3e5681e4c912ca7ff9c.zip tcl-f2b14cb7f00034cf7c9ee3e5681e4c912ca7ff9c.tar.gz tcl-f2b14cb7f00034cf7c9ee3e5681e4c912ca7ff9c.tar.bz2 |
small amend: move the normalization to the block where the error message really neededcore-bug-02d5d65d70adab97
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinChan.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/win/tclWinChan.c b/win/tclWinChan.c index 666a0b1..0199a37 100644 --- a/win/tclWinChan.c +++ b/win/tclWinChan.c @@ -11,6 +11,7 @@ */ #include "tclWinInt.h" +#include "tclFileSystem.h" #include "tclIO.h" /* @@ -866,6 +867,26 @@ TclpOpenFileChannel( nativeName = (const WCHAR *)Tcl_FSGetNativePath(pathPtr); if (nativeName == NULL) { if (interp != (Tcl_Interp *) NULL) { + /* + * We need this just to ensure we return the correct error messages under + * some circumstances (relative paths only), so because the normalization + * is very expensive, don't invoke it for native or absolute paths. + * Note: TODO - check one needs consider tilde expansion after TIP#602, + * (proper error message of tests *io-40.17 "tilde substitution in open") + */ + if ( + ( + ( + !TclFSCwdIsNative() && + (Tcl_FSGetPathType(pathPtr) != TCL_PATH_ABSOLUTE) + ) || + (*TclGetString(pathPtr) == '~') /* possible tilde expansion */ + ) && + Tcl_FSGetNormalizedPath(interp, pathPtr) == NULL + ) { + return NULL; + } + Tcl_AppendResult(interp, "couldn't open \"", TclGetString(pathPtr), "\": filename is invalid on this platform", NULL); |