Posted to tcl by Stu at Sun Feb 01 02:29:26 GMT 2026view pretty
+ /* parent/lib */
+ Tcl_Obj *dirs[3] = {NULL, NULL, NULL}; /* exedir, exedirparent, lib */
+ Tcl_Size dirCount = TclGetObjExecutableAncestors(interp, 2, dirs);
+ if (dirCount == 2) {
+ assert(dirs[1]);
+ dirs[2] = Tcl_NewStringObj("lib", 3);
+ Tcl_IncrRefCount(dirs[2]);
+ objPtr = TclJoinPath(2, &dirs[1], 0);
+ if (objPtr != NULL) {
+ /* Note: TclListObjAppendIfAbsent handles 0 and non-0 ref counts */
+ (void) TclListObjAppendIfAbsent(NULL, autoPathPtr, objPtr);
+ }
+ }
+ for (size_t i = 0; i < sizeof(dirs) / sizeof(dirs[0]); ++i) {
+ if (dirs[i] != NULL) {
+ Tcl_DecrRefCount(dirs[i]);
+ }
+ }