Index: generic/tclCmdIL.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCmdIL.c,v
retrieving revision 1.97
diff -u -r1.97 tclCmdIL.c
--- generic/tclCmdIL.c	6 Feb 2007 21:15:14 -0000	1.97
+++ generic/tclCmdIL.c	26 Feb 2007 19:57:48 -0000
@@ -2461,17 +2461,10 @@
     int objc,			/* Number of arguments. */
     Tcl_Obj *CONST objv[])	/* The argument objects. */
 {
-    char *joinString, *bytes;
-    int joinLength, listLen, length, i, result;
-    Tcl_Obj **elemPtrs;
-    Tcl_Obj *resObjPtr;
+    int listLen, i;
+    Tcl_Obj *resObjPtr, *joinObjPtr, **elemPtrs;
 
-    if (objc == 2) {
-	joinString = " ";
-	joinLength = 1;
-    } else if (objc == 3) {
-	joinString = Tcl_GetStringFromObj(objv[2], &joinLength);
-    } else {
+    if ((objc < 2) || (objc > 3)) {
 	Tcl_WrongNumArgs(interp, 1, objv, "list ?joinString?");
 	return TCL_ERROR;
     }
@@ -2481,23 +2474,21 @@
      * pointer to its array of element pointers.
      */
 
-    result = Tcl_ListObjGetElements(interp, objv[1], &listLen, &elemPtrs);
-    if (result != TCL_OK) {
-	return result;
+    if (TCL_OK != Tcl_ListObjGetElements(interp, objv[1], &listLen, &elemPtrs)) {
+	return TCL_ERROR;
     }
 
-    /*
-     * Now concatenate strings to form the "joined" result.
-     */
+    joinObjPtr = (objc == 2) ? Tcl_NewStringObj(" ", 1) : objv[2];
+    Tcl_IncrRefCount(joinObjPtr);
 
     resObjPtr = Tcl_NewObj();
     for (i = 0;  i < listLen;  i++) {
-	bytes = Tcl_GetStringFromObj(elemPtrs[i], &length);
 	if (i > 0) {
-	    Tcl_AppendToObj(resObjPtr, joinString, joinLength);
+	    Tcl_AppendObjToObj(resObjPtr, joinObjPtr);
 	}
-	Tcl_AppendToObj(resObjPtr, bytes, length);
+	Tcl_AppendObjToObj(resObjPtr, elemPtrs[i]);
     }
+    Tcl_DecrRefCount(joinObjPtr);
     Tcl_SetObjResult(interp, resObjPtr);
     return TCL_OK;
 }
