diff options
Diffstat (limited to 'generic/tclPkg.c')
-rw-r--r-- | generic/tclPkg.c | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/generic/tclPkg.c b/generic/tclPkg.c index aed80c0..53be4af 100644 --- a/generic/tclPkg.c +++ b/generic/tclPkg.c @@ -46,7 +46,7 @@ typedef struct Package { * exist in this interpreter yet. */ PkgAvail *availPtr; /* First in list of all available versions of * this package. */ - ClientData clientData; /* Client data. */ + const void *clientData; /* Client data. */ } Package; /* @@ -71,7 +71,7 @@ static void AddRequirementsToDString(Tcl_DString *dstring, static Package * FindPackage(Tcl_Interp *interp, const char *name); static const char * PkgRequireCore(Tcl_Interp *interp, const char *name, int reqc, Tcl_Obj *const reqv[], - ClientData *clientDataPtr); + void *clientDataPtr); /* * Helper macros. @@ -122,7 +122,7 @@ Tcl_PkgProvideEx( * available. */ const char *name, /* Name of package. */ const char *version, /* Version string for package. */ - ClientData clientData) /* clientdata for this package (normally used + const void *clientData) /* clientdata for this package (normally used * for C callback function table) */ { Package *pkgPtr; @@ -210,7 +210,7 @@ Tcl_PkgRequireEx( int exact, /* Non-zero means that only the particular * version given is acceptable. Zero means use * the latest compatible version. */ - ClientData *clientDataPtr) /* Used to return the client data for this + void *clientDataPtr) /* Used to return the client data for this * package. If it is NULL then the client data * is not returned. This is unchanged if this * call fails for any reason. */ @@ -321,7 +321,7 @@ Tcl_PkgRequireProc( * version. */ Tcl_Obj *const reqv[], /* 0 means to use the latest version * available. */ - ClientData *clientDataPtr) + void *clientDataPtr) { const char *result = PkgRequireCore(interp, name, reqc, reqv, clientDataPtr); @@ -342,7 +342,7 @@ PkgRequireCore( * version. */ Tcl_Obj *const reqv[], /* 0 means to use the latest version * available. */ - ClientData *clientDataPtr) + void *clientDataPtr) { Interp *iPtr = (Interp *) interp; Package *pkgPtr; @@ -475,14 +475,14 @@ PkgRequireCore( * will still exist when the script completes. */ - const char *versionToProvide = bestPtr->version; + char *versionToProvide = bestPtr->version; script = bestPtr->script; - pkgPtr->clientData = (ClientData) versionToProvide; - Tcl_Preserve((ClientData) script); - Tcl_Preserve((ClientData) versionToProvide); + pkgPtr->clientData = versionToProvide; + Tcl_Preserve(script); + Tcl_Preserve(versionToProvide); code = Tcl_EvalEx(interp, script, -1, TCL_EVAL_GLOBAL); - Tcl_Release((ClientData) script); + Tcl_Release(script); pkgPtr = FindPackage(interp, name); if (code == TCL_OK) { @@ -534,7 +534,7 @@ PkgRequireCore( "\n (\"package ifneeded %s %s\" script)", name, versionToProvide)); } - Tcl_Release((ClientData) versionToProvide); + Tcl_Release(versionToProvide); if (code != TCL_OK) { /* @@ -619,7 +619,8 @@ PkgRequireCore( if (satisfies) { if (clientDataPtr) { - *clientDataPtr = pkgPtr->clientData; + const void **ptr = (const void **) clientDataPtr; + *ptr = pkgPtr->clientData; } return pkgPtr->version; } @@ -675,7 +676,7 @@ Tcl_PkgPresentEx( int exact, /* Non-zero means that only the particular * version given is acceptable. Zero means use * the latest compatible version. */ - ClientData *clientDataPtr) /* Used to return the client data for this + void *clientDataPtr) /* Used to return the client data for this * package. If it is NULL then the client data * is not returned. This is unchanged if this * call fails for any reason. */ @@ -740,7 +741,7 @@ Tcl_PackageObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - static const char *pkgOptions[] = { + static const char *const pkgOptions[] = { "forget", "ifneeded", "names", "prefer", "present", "provide", "require", "unknown", "vcompare", "versions", "vsatisfies", NULL @@ -758,10 +759,11 @@ Tcl_PackageObjCmd( Tcl_HashSearch search; Tcl_HashTable *tablePtr; const char *version; - char *argv2, *argv3, *argv4, *iva = NULL, *ivb = NULL; + const char *argv2, *argv3, *argv4; + char *iva = NULL, *ivb = NULL; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } @@ -771,7 +773,7 @@ Tcl_PackageObjCmd( } switch ((enum pkgOptions) optionIndex) { case PKG_FORGET: { - char *keyString; + const char *keyString; for (i = 2; i < objc; i++) { keyString = TclGetString(objv[i]); @@ -787,11 +789,11 @@ Tcl_PackageObjCmd( while (pkgPtr->availPtr != NULL) { availPtr = pkgPtr->availPtr; pkgPtr->availPtr = availPtr->nextPtr; - Tcl_EventuallyFree((ClientData)availPtr->version, TCL_DYNAMIC); - Tcl_EventuallyFree((ClientData)availPtr->script, TCL_DYNAMIC); - ckfree((char *) availPtr); + Tcl_EventuallyFree(availPtr->version, TCL_DYNAMIC); + Tcl_EventuallyFree(availPtr->script, TCL_DYNAMIC); + ckfree(availPtr); } - ckfree((char *) pkgPtr); + ckfree(pkgPtr); } break; } @@ -837,7 +839,7 @@ Tcl_PackageObjCmd( Tcl_SetResult(interp, availPtr->script, TCL_VOLATILE); return TCL_OK; } - Tcl_EventuallyFree((ClientData)availPtr->script, TCL_DYNAMIC); + Tcl_EventuallyFree(availPtr->script, TCL_DYNAMIC); break; } } @@ -847,7 +849,7 @@ Tcl_PackageObjCmd( return TCL_OK; } if (availPtr == NULL) { - availPtr = (PkgAvail *) ckalloc(sizeof(PkgAvail)); + availPtr = ckalloc(sizeof(PkgAvail)); DupBlock(availPtr->version, argv3, (unsigned) length + 1); if (prevPtr == NULL) { @@ -947,7 +949,7 @@ Tcl_PackageObjCmd( if (objc < 3) { requireSyntax: Tcl_WrongNumArgs(interp, 2, objv, - "?-exact? package ?requirement...?"); + "?-exact? package ?requirement ...?"); return TCL_ERROR; } @@ -1013,7 +1015,7 @@ Tcl_PackageObjCmd( break; } case PKG_PREFER: { - static const char *pkgPreferOptions[] = { + static const char *const pkgPreferOptions[] = { "latest", "stable", NULL }; @@ -1098,7 +1100,7 @@ Tcl_PackageObjCmd( if (objc < 4) { Tcl_WrongNumArgs(interp, 2, objv, - "version requirement requirement..."); + "version ?requirement ...?"); return TCL_ERROR; } @@ -1152,7 +1154,7 @@ FindPackage( hPtr = Tcl_CreateHashEntry(&iPtr->packageTable, name, &isNew); if (isNew) { - pkgPtr = (Package *) ckalloc(sizeof(Package)); + pkgPtr = ckalloc(sizeof(Package)); pkgPtr->version = NULL; pkgPtr->availPtr = NULL; pkgPtr->clientData = NULL; @@ -1198,11 +1200,11 @@ TclFreePackageInfo( while (pkgPtr->availPtr != NULL) { availPtr = pkgPtr->availPtr; pkgPtr->availPtr = availPtr->nextPtr; - Tcl_EventuallyFree((ClientData)availPtr->version, TCL_DYNAMIC); - Tcl_EventuallyFree((ClientData)availPtr->script, TCL_DYNAMIC); - ckfree((char *) availPtr); + Tcl_EventuallyFree(availPtr->version, TCL_DYNAMIC); + Tcl_EventuallyFree(availPtr->script, TCL_DYNAMIC); + ckfree(availPtr); } - ckfree((char *) pkgPtr); + ckfree(pkgPtr); } Tcl_DeleteHashTable(&iPtr->packageTable); if (iPtr->packageUnknown != NULL) { @@ -1643,7 +1645,7 @@ AddRequirementsToResult( for (i = 0; i < reqc; i++) { int length; - char *v = Tcl_GetStringFromObj(reqv[i], &length); + const char *v = Tcl_GetStringFromObj(reqv[i], &length); if ((length & 0x1) && (v[length/2] == '-') && (strncmp(v, v+((length+1)/2), length/2) == 0)) { |