*** tcl8.4.6/generic/tclCmdIL.c	Thu Jul 17 13:29:19 2003
--- tclCmdIL.c	Fri Aug 27 03:50:19 2004
***************
*** 3255,3261 ****
      int objc;			/* Number of arguments. */
      Tcl_Obj *CONST objv[];	/* Argument values. */
  {
!     int i, index, unique;
      Tcl_Obj *resultPtr;
      int length;
      Tcl_Obj *cmdPtr, **listObjPtrs;
--- 3255,3261 ----
      int objc;			/* Number of arguments. */
      Tcl_Obj *CONST objv[];	/* Argument values. */
  {
!     int i, index, unique, indices;
      Tcl_Obj *resultPtr;
      int length;
      Tcl_Obj *cmdPtr, **listObjPtrs;
***************
*** 3266,3272 ****
                                           * comparison function */
      static CONST char *switches[] = {
  	"-ascii", "-command", "-decreasing", "-dictionary", "-increasing",
! 	"-index", "-integer", "-real", "-unique", (char *) NULL
      };
  
      resultPtr = Tcl_GetObjResult(interp);
--- 3266,3272 ----
                                           * comparison function */
      static CONST char *switches[] = {
  	"-ascii", "-command", "-decreasing", "-dictionary", "-increasing",
! 	"-index", "-integer", "-real", "-unique", "-indices", (char *) NULL
      };
  
      resultPtr = Tcl_GetObjResult(interp);
***************
*** 3286,3291 ****
--- 3286,3292 ----
      sortInfo.resultCode = TCL_OK;
      cmdPtr = NULL;
      unique = 0;
+     indices = 0;
      for (i = 1; i < objc-1; i++) {
  	if (Tcl_GetIndexFromObj(interp, objv[i], switches, "option", 0, &index)
  		!= TCL_OK) {
***************
*** 3337,3342 ****
--- 3338,3346 ----
  	    case 8:			/* -unique */
  		unique = 1;
  		break;
+ 	    case 9:                     /* -indices */
+ 		indices = 1;
+ 		break;
  	}
      }
      if (sortInfo.sortMode == SORTMODE_COMMAND) {
***************
*** 3385,3398 ****
  	if (unique) {
  	    for (; elementPtr != NULL; elementPtr = elementPtr->nextPtr){
  		if (elementPtr->count == 0) {
! 		    Tcl_ListObjAppendElement(interp, resultPtr,
  			    elementPtr->objPtr);
  		}
  	    }
  	} else {
  	    for (; elementPtr != NULL; elementPtr = elementPtr->nextPtr){
! 		Tcl_ListObjAppendElement(interp, resultPtr,
  			elementPtr->objPtr);
  	    }
  	}
      }
--- 3389,3412 ----
  	if (unique) {
  	    for (; elementPtr != NULL; elementPtr = elementPtr->nextPtr){
  		if (elementPtr->count == 0) {
! 		    if (indices) {
! 			Tcl_ListObjAppendElement(interp, resultPtr,
! 			    Tcl_NewIntObj(elementPtr - &elementArray[0]));
! 		    } else {
! 	 		Tcl_ListObjAppendElement(interp, resultPtr,
  			    elementPtr->objPtr);
+ 		    }
  		}
  	    }
  	} else {
  	    for (; elementPtr != NULL; elementPtr = elementPtr->nextPtr){
! 		if (indices) {
! 		    Tcl_ListObjAppendElement(interp, resultPtr,
! 			Tcl_NewIntObj(elementPtr - &elementArray[0]));
! 		} else {
! 		    Tcl_ListObjAppendElement(interp, resultPtr,
  			elementPtr->objPtr);
+ 		}
  	    }
  	}
      }
