Tcl Source Code

Check-in [6a24d9dea4]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the "package files" command. Due to the NRE enabling of "package" it always started to return an empty list.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-branch
Files: files | file ages | folders
SHA3-256: 6a24d9dea479f261fef72c98e0690c1e477b8a09bf9ed044fc2e7ac87dd2862c
User & Date: jan.nijtmans 2018-03-06 22:53:00
Context
2018-03-07
19:35
Fix handling of "pkgIndex" file in "package files" command. This was broken as well, as result of NR... check-in: c2b3db3af1 user: jan.nijtmans tags: core-8-branch
15:13
merge 8.7 check-in: f43a6f6ea8 user: dgp tags: core_zip_vfs
2018-03-06
22:53
Fix the "package files" command. Due to the NRE enabling of "package" it always started to return an... check-in: 6a24d9dea4 user: jan.nijtmans tags: core-8-branch
12:59
merge 8.6 check-in: 3d06c4a172 user: dgp tags: core-8-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclPkg.c.

724
725
726
727
728
729
730



731
732
733
734
735
736








737
738
739
740
741
742
743
744
745
746
747
748
749
750

751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
	 * We found an ifneeded script for the package. Be careful while
	 * executing it: this could cause reentrancy, so (a) protect the
	 * script itself from deletion and (b) don't assume that bestPtr
	 * will still exist when the script completes.
	 */

	char *versionToProvide = bestPtr->version;



	Tcl_Preserve(versionToProvide);
	pkgPtr->clientData = versionToProvide;
	if (bestPtr->pkgIndex) {
	    TclPkgFileSeen(interp, bestPtr->pkgIndex);
	}
	reqPtr->versionToProvide = versionToProvide;








	Tcl_NRAddCallback(interp, SelectPackageFinal, reqPtr, INT2PTR(reqc), (void *)reqv, data[3]);
	Tcl_NREvalObj(interp, Tcl_NewStringObj(bestPtr->script, -1), TCL_EVAL_GLOBAL);
    }
    return TCL_OK;
}
 
static int
SelectPackageFinal(ClientData data[], Tcl_Interp *interp, int result) {
    Require *reqPtr = data[0];
    int reqc = PTR2INT(data[1]);
    Tcl_Obj **const reqv = data[2];
    const char *name = reqPtr->name;
    char *versionToProvide = reqPtr->versionToProvide;


    PkgFiles *pkgFiles;
    PkgName *pkgName;

    pkgFiles = TclInitPkgFiles(interp);
    /* Push "ifneeded" package name in "tclPkgFiles" assocdata. */
    pkgName = ckalloc(sizeof(PkgName) + strlen(name));
    pkgName->nextPtr = pkgFiles->names;
    strcpy(pkgName->name, name);
    pkgFiles->names = pkgName;

    /* Pop the "ifneeded" package name from "tclPkgFiles" assocdata*/
    pkgFiles->names = pkgName->nextPtr;
    ckfree(pkgName);

    reqPtr->pkgPtr = FindPackage(interp, name);
    if (result == TCL_OK) {
	Tcl_ResetResult(interp);
	if (reqPtr->pkgPtr->version == NULL) {
	    result = TCL_ERROR;
	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(






>
>
>






>
>
>
>
>
>
>
>













<
>

<


|
<
|
<
|
<
<
<
|







724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760

761
762

763
764
765

766

767



768
769
770
771
772
773
774
775
	 * We found an ifneeded script for the package. Be careful while
	 * executing it: this could cause reentrancy, so (a) protect the
	 * script itself from deletion and (b) don't assume that bestPtr
	 * will still exist when the script completes.
	 */

	char *versionToProvide = bestPtr->version;
	PkgFiles *pkgFiles;
	PkgName *pkgName;

	Tcl_Preserve(versionToProvide);
	pkgPtr->clientData = versionToProvide;
	if (bestPtr->pkgIndex) {
	    TclPkgFileSeen(interp, bestPtr->pkgIndex);
	}
	reqPtr->versionToProvide = versionToProvide;

    pkgFiles = TclInitPkgFiles(interp);
    /* Push "ifneeded" package name in "tclPkgFiles" assocdata. */
    pkgName = ckalloc(sizeof(PkgName) + strlen(name));
    pkgName->nextPtr = pkgFiles->names;
    strcpy(pkgName->name, name);
    pkgFiles->names = pkgName;

	Tcl_NRAddCallback(interp, SelectPackageFinal, reqPtr, INT2PTR(reqc), (void *)reqv, data[3]);
	Tcl_NREvalObj(interp, Tcl_NewStringObj(bestPtr->script, -1), TCL_EVAL_GLOBAL);
    }
    return TCL_OK;
}
 
static int
SelectPackageFinal(ClientData data[], Tcl_Interp *interp, int result) {
    Require *reqPtr = data[0];
    int reqc = PTR2INT(data[1]);
    Tcl_Obj **const reqv = data[2];
    const char *name = reqPtr->name;
    char *versionToProvide = reqPtr->versionToProvide;

    void *toBeRemoved;
    PkgFiles *pkgFiles;


    pkgFiles = TclInitPkgFiles(interp);
    /* Pop the "ifneeded" package name from "tclPkgFiles" assocdata*/

    toBeRemoved = pkgFiles->names;

    pkgFiles->names = pkgFiles->names->nextPtr;



    ckfree(toBeRemoved);

    reqPtr->pkgPtr = FindPackage(interp, name);
    if (result == TCL_OK) {
	Tcl_ResetResult(interp);
	if (reqPtr->pkgPtr->version == NULL) {
	    result = TCL_ERROR;
	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(