Tcl Source Code

Check-in [5011be2338]
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:but ... don't call Tcl_GetObjResult() twice
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | jn-bug-39fed4dae5
Files: files | file ages | folders
SHA3-256: 5011be2338fa0d5352edd7d90ff7fa56d2fb612a91a31082239e120fe06f7f54
User & Date: jan.nijtmans 2019-03-07 09:45:03
Context
2019-03-07
09:45
but ... don't call Tcl_GetObjResult() twice Closed-Leaf check-in: 5011be2338 user: jan.nijtmans tags: jn-bug-39fed4dae5
09:43
Better fix, not hackish any-more, but retaining the original idea check-in: 0a4f70654f user: jan.nijtmans tags: jn-bug-39fed4dae5
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclPkg.c.

337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
...
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
     * Translate between old and new API, and defer to the new function.
     */

    if (version == NULL) {
	if (Tcl_PkgRequireProc(interp, name, 0, NULL, clientDataPtr) == TCL_OK) {
		Tcl_Obj *obj = Tcl_GetObjResult(interp);
		if (obj->typePtr == &tclPkgVersionType) {
		    result = Tcl_GetObjResult(interp)->internalRep.twoPtrValue.ptr1;
		}
	    Tcl_ResetResult(interp);
	}
    } else {
	if (exact && TCL_OK
		!= CheckVersionAndConvert(interp, version, NULL, NULL)) {
	    return NULL;
................................................................................
	if (exact) {
	    Tcl_AppendStringsToObj(ov, "-", version, NULL);
	}
	Tcl_IncrRefCount(ov);
	if (Tcl_PkgRequireProc(interp, name, 1, &ov, clientDataPtr) == TCL_OK) {
		Tcl_Obj *obj = Tcl_GetObjResult(interp);
		if (obj->typePtr == &tclPkgVersionType) {
		    result = Tcl_GetObjResult(interp)->internalRep.twoPtrValue.ptr1;
		}
	    Tcl_ResetResult(interp);
	}
	TclDecrRefCount(ov);
    }
    return result;
}






|







 







|







337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
...
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
     * Translate between old and new API, and defer to the new function.
     */

    if (version == NULL) {
	if (Tcl_PkgRequireProc(interp, name, 0, NULL, clientDataPtr) == TCL_OK) {
		Tcl_Obj *obj = Tcl_GetObjResult(interp);
		if (obj->typePtr == &tclPkgVersionType) {
		    result = obj->internalRep.twoPtrValue.ptr1;
		}
	    Tcl_ResetResult(interp);
	}
    } else {
	if (exact && TCL_OK
		!= CheckVersionAndConvert(interp, version, NULL, NULL)) {
	    return NULL;
................................................................................
	if (exact) {
	    Tcl_AppendStringsToObj(ov, "-", version, NULL);
	}
	Tcl_IncrRefCount(ov);
	if (Tcl_PkgRequireProc(interp, name, 1, &ov, clientDataPtr) == TCL_OK) {
		Tcl_Obj *obj = Tcl_GetObjResult(interp);
		if (obj->typePtr == &tclPkgVersionType) {
		    result = obj->internalRep.twoPtrValue.ptr1;
		}
	    Tcl_ResetResult(interp);
	}
	TclDecrRefCount(ov);
    }
    return result;
}