Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-04-13
23:35 • Ticket [217867ffff] concat support for list objects status still Closed with... artifact: 229a5eb0e7 user: dgp
2000-10-26
07:59 • Closed ticket [217867ffff]. artifact: b14c44e238 user: welch
00:45 • New ticket [217867ffff]. artifact: 22dff9fb0d user: nobody

concat support for list objects

Closed / Invalid217867ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:45:06
OriginalBugID: 2098 RFE
Version: 8.1
SubmitDate: '1999-05-19'
LastModified: '1999-08-06'
Severity: LOW
Status: Closed
Submitter: pat
ChangedBy: hobbs
RelatedBugIDs: 2101 2257
OS: Solaris
OSVersion: 2.5.1
Machine: Other
FixedDate: '2000-10-25'
ClosedDate: '1999-08-06'


Name:
Jeffrey Hobbs

CVS:
May 17, tclUtil.c $Id: tclUtil.c,v 1.11 1999/05/06 19:21:11 stanton Exp $

CustomShell:
mod core? not me...

Comments:
In tests on larger lists, this actually takes a bit more time to return
    to assemble and return the object than the regular bytes concat mode.
    However, when the returned object is next used as a list (like with
    foreach), there is a notable time savings.
    
    Again, this only affects calls to concat where all args passed are
    already recgonized list objects.  This passes all tests, and doesn't
    break any syntax logic.

DesiredBehavior:
As pointed out on c.l.tcl, concat actually converts everything to
    strings
    and returns a string, as opposed to what the docs say.  This features
    enhancement involves situations where concat was passed only objects of
    the list type.  In this case, it concats them together into one list,
    and returns an object of type list.

Patch:
The following needs to be inserted as the first code in Tcl_ConcatObj
in tclUtil.c:

    for (i = 0;  i < objc;  i++) {
if (objv[i]->typePtr != &tclListType) {
    break;
}
    }
    if (i == objc) {
Tcl_Obj **listv;
int listc;
/*
 * All the items are of list type, concat them together
 * as lists, and return as a list obj
 */
objPtr = Tcl_NewListObj(0, NULL);
for (i = 0;  i < objc;  i++) {
    /*
     * No check is made on the result code, as we checked
     * above that they are all of list type...
     */
    Tcl_ListObjGetElements(NULL, objv[i], &listc, &listv);
    Tcl_ListObjReplace(NULL, objPtr, INT_MAX, 0, listc, listv);
}
return objPtr;
    }

PatchFiles:
generic/tclUtil.c
welch Closed ticket [217867ffff]. [History diff]2000-10-26 07:59:48
dgp Ticket [217867ffff]: 3 changes [History diff]2001-04-13 23:35:26
Log in (anonymous is fine) to add a comment.