diff options
| author | sebres <sebres@users.sourceforge.net> | 2024-09-17 14:32:28 (GMT) |
|---|---|---|
| committer | sebres <sebres@users.sourceforge.net> | 2024-09-17 14:32:28 (GMT) |
| commit | 56763a32c0e55f0c454f9d958cae56033640d80f (patch) | |
| tree | e0086edf90b575f28012974b29b82cfe44a107f3 /unix/tclUnixChan.c | |
| parent | 98f40f7dfb43b05f93fda380e4f936f0c49ecdf6 (diff) | |
| parent | a680486042c9cb4f65899abb15dbc6bdcec5ec0a (diff) | |
| download | tcl-56763a32c0e55f0c454f9d958cae56033640d80f.zip tcl-56763a32c0e55f0c454f9d958cae56033640d80f.tar.gz tcl-56763a32c0e55f0c454f9d958cae56033640d80f.tar.bz2 | |
merge 8.6 (fix attempt for [02d5d65d70adab97], however the small bottleneck is still visible)
Diffstat (limited to 'unix/tclUnixChan.c')
| -rw-r--r-- | unix/tclUnixChan.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index b9b04ef..55287cc 100644 --- a/unix/tclUnixChan.c +++ b/unix/tclUnixChan.c @@ -12,6 +12,7 @@ */ #include "tclInt.h" /* Internal definitions for Tcl. */ +#include "tclFileSystem.h" #include "tclIO.h" /* To get Channel type declaration. */ #undef SUPPORTS_TTY @@ -1844,6 +1845,26 @@ TclpOpenFileChannel( native = (const char *)Tcl_FSGetNativePath(pathPtr); if (native == 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: since paths starting with ~ are absolute, it also considers tilde expansion, + * (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", (char *)NULL); |
