diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-07-20 16:22:24 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-07-20 16:22:24 (GMT) |
commit | 216559a0a69b0df8bb91006b20051801a6c745ea (patch) | |
tree | adcc428990f4cbb4900aa0541f8807f5db6919e0 | |
parent | 31d2eacf4146aec4f4650b0493b966660b8bcce0 (diff) | |
download | tcl-216559a0a69b0df8bb91006b20051801a6c745ea.zip tcl-216559a0a69b0df8bb91006b20051801a6c745ea.tar.gz tcl-216559a0a69b0df8bb91006b20051801a6c745ea.tar.bz2 |
Make "cd" encoding-error-aware
-rw-r--r-- | generic/tclCmdAH.c | 7 | ||||
-rw-r--r-- | unix/tclLoadDyld.c | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index c860004..31e3a96 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -283,7 +283,12 @@ Tcl_CdObjCmd( if (Tcl_FSConvertToPathType(interp, dir) != TCL_OK) { result = TCL_ERROR; } else { - result = Tcl_FSChdir(dir); + Tcl_DString ds; + result = Tcl_UtfToExternalDStringEx(NULL, NULL, TclGetString(dir), -1, 0, &ds, NULL); + Tcl_DStringFree(&ds); + if (result == TCL_OK) { + result = Tcl_FSChdir(dir); + } if (result != TCL_OK) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't change working directory to \"%s\": %s", diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c index 0bb56c8..67e1682 100644 --- a/unix/tclLoadDyld.c +++ b/unix/tclLoadDyld.c @@ -189,7 +189,7 @@ TclpDlopen( Tcl_DStringFree(&ds); return TCL_ERROR; } - nativeFileName = Tcl_DStringValue(); + nativeFileName = Tcl_DStringValue(&ds); #if TCL_DYLD_USE_DLFCN /* @@ -347,7 +347,7 @@ FindSymbol( if (Tcl_UtfToExternalDStringEx(interp, NULL, symbol, TCL_INDEX_NONE, 0, &ds, NULL) != TCL_OK) { Tcl_DStringFree(&ds); - return TCL_ERROR; + return NULL; } native = Tcl_DStringValue(&ds); if (dyldLoadHandle->dlHandle) { |