summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixChan.c19
-rw-r--r--unix/tclUnixFile.c4
2 files changed, 21 insertions, 2 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 1844a23..e072cd7 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
@@ -1418,6 +1419,24 @@ 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.
+ */
+ 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);
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index c39e7b6..9769b13 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -1076,9 +1076,9 @@ TclNativeCreateNativeRep(
Tcl_Obj *validPathPtr;
int len;
- if (TclFSCwdIsNative()) {
+ if (TclFSCwdIsNative() || Tcl_FSGetPathType(pathPtr) == TCL_PATH_ABSOLUTE) {
/*
- * The cwd is native, which means we can use the translated path
+ * The cwd is native (or path is absolute), use the translated path
* without worrying about normalization (this will also usually be
* shorter so the utf-to-external conversion will be somewhat faster).
*/