summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-11-29 09:45:20 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-11-29 09:45:20 (GMT)
commit99d3d95f4b8ae074c1c23d5599e32d976a6cb529 (patch)
tree32806de0ac66f26d7dd94bfb21af0ae79f94224a
parent5f5b7e42b2337f1fc7e33bccf2bcd8155fe968bc (diff)
downloadtcl-99d3d95f4b8ae074c1c23d5599e32d976a6cb529.zip
tcl-99d3d95f4b8ae074c1c23d5599e32d976a6cb529.tar.gz
tcl-99d3d95f4b8ae074c1c23d5599e32d976a6cb529.tar.bz2
Implement the "package forget" part, which was still missing. Handle the case that a filename contains spaces.
-rw-r--r--generic/tclPkg.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/generic/tclPkg.c b/generic/tclPkg.c
index c8f418c..42dd08d 100644
--- a/generic/tclPkg.c
+++ b/generic/tclPkg.c
@@ -243,15 +243,16 @@ void TclPkgFileSeen(Tcl_Interp *interp, const char *fileName)
Tcl_HashTable *table = &pkgFiles->table;
int new;
Tcl_HashEntry *entry = Tcl_CreateHashEntry(table, name, &new);
- Tcl_Obj *obj = Tcl_NewStringObj(fileName, -1);
+ Tcl_Obj *list;
if (new) {
- Tcl_SetHashValue(entry, obj);
- Tcl_IncrRefCount(obj);
+ list = Tcl_NewObj();
+ Tcl_SetHashValue(entry, list);
+ Tcl_IncrRefCount(list);
} else {
- Tcl_Obj *list = Tcl_GetHashValue(entry);
- Tcl_ListObjAppendElement(interp, list, obj);
+ list = Tcl_GetHashValue(entry);
}
+ Tcl_ListObjAppendElement(interp, list, Tcl_NewStringObj(fileName, -1));
}
}
@@ -889,9 +890,19 @@ Tcl_PackageObjCmd(
}
case PKG_FORGET: {
const char *keyString;
+ PkgFiles *pkgFiles = (PkgFiles *) Tcl_GetAssocData(interp, "tclPkgFiles", NULL);
for (i = 2; i < objc; i++) {
keyString = TclGetString(objv[i]);
+ if (pkgFiles) {
+ hPtr = Tcl_FindHashEntry(&pkgFiles->table, keyString);
+ if (hPtr) {
+ Tcl_Obj *obj = Tcl_GetHashValue(hPtr);
+ Tcl_DeleteHashEntry(hPtr);
+ Tcl_DecrRefCount(obj);
+ }
+ }
+
hPtr = Tcl_FindHashEntry(&iPtr->packageTable, keyString);
if (hPtr == NULL) {
continue;