Skip to content
Tcl Source Code History Of Ticket 217912ffffffffff
Login

History Of Ticket 217912ffffffffff

Artifacts Associated With Ticket 217912ffffffffff

  1. Ticket change [180032ae3f] (rid 122592) by nobody on 2000-10-26 00:45:51:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 2812 RFE
      Version: 8.2
      SubmitDate: '1999-09-16'
      LastModified: '1999-12-15'
      Severity: MED
      Status: Closed
      Submitter: techsupp
      ChangedBy: hobbs
      RelatedBugIDs: 3758
      OS: Solaris
      OSVersion: 2.7
      Machine: Other
      FixedDate: '2000-10-25'
      ClosedDate: '1999-12-15'
      
      
      Name:
      
      Michael Karo
      
      
      
      CustomShell:
      
      See above patch. There are no known conflicts.
      
      
      
      Comments:
      
      The above patch has been provided in hopes that this functionality will
      
          appear as part of the Tcl core as soon as possible.
      
      
      
      DesiredBehavior:
      
      The lsort command does not currently have a means of sorting lists while
      
          eliminating redundant entries. This capability is present in the UNIX
      
          sort(1) command by specifying the -u flag. Although a workaround can be
      
          created in a Tcl script to iterate over a list and remove redundant
      
          entries,
      
          it is an inefficient solution for very large lists.
      
      
      
      Patch:
      
      *** tclCmdIL.c.old      Wed Sep 15 13:00:46 1999
      
      --- tclCmdIL.c.new      Wed Sep 15 13:03:41 1999
      
      ***************
      
      *** 44,49 ****
      
      --- 44,51 ----
      
        
      
        typedef struct SortInfo {
      
            int isIncreasing;         /* Nonzero means sort in increasing order. */
      
      +     int isUnique;             /* Nonzero means supress all but one of
      
      +                                * each list element having equal keys. */
      
            int sortMode;             /* The sort mode.  One of SORTMODE_*
      
                                       * values defined below */
      
            Tcl_Obj *compareCmdPtr;     /* The Tcl comparison command when sortMode
      
      ***************
      
      *** 2435,2441 ****
      
                                                 * comparison function */
      
            static char *switches[] =
      
                  {"-ascii", "-command", "-decreasing", "-dictionary",
      
      !           "-increasing", "-index", "-integer", "-real", (char *) NULL};
      
        
      
            resultPtr = Tcl_GetObjResult(interp);
      
            if (objc < 2) {
      
      --- 2437,2444 ----
      
                                                 * comparison function */
      
            static char *switches[] =
      
                  {"-ascii", "-command", "-decreasing", "-dictionary",
      
      !           "-increasing", "-index", "-integer", "-real", "-unique",
      
      !           (char *) NULL};
      
        
      
            resultPtr = Tcl_GetObjResult(interp);
      
            if (objc < 2) {
      
      ***************
      
      *** 2448,2453 ****
      
      --- 2451,2457 ----
      
             */
      
        
      
            sortInfo.isIncreasing = 1;
      
      +     sortInfo.isUnique = 0;
      
            sortInfo.sortMode = SORTMODE_ASCII;
      
            sortInfo.index = -1;
      
            sortInfo.interp = interp;
      
      ***************
      
      *** 2502,2507 ****
      
      --- 2506,2514 ----
      
                  case 7:                     /* -real */
      
                      sortInfo.sortMode = SORTMODE_REAL;
      
                      break;
      
      +           case 8:                     /* -unique */
      
      +               sortInfo.isUnique = 1;
      
      +               break;
      
              }
      
            }
      
            if (sortInfo.sortMode == SORTMODE_COMMAND) {
      
      ***************
      
      *** 2662,2667 ****
      
      --- 2669,2687 ----
      
            }
      
            headPtr = tailPtr;
      
            while ((leftPtr != NULL) && (rightPtr != NULL)) {
      
      +       if (infoPtr->isUnique != 0) {
      
      +           while ((leftPtr != NULL) && (SortCompare(tailPtr->objPtr,
      
      +                   leftPtr->objPtr, infoPtr) == 0)) {
      
      +               leftPtr = leftPtr->nextPtr;
      
      +           }
      
      +           while ((rightPtr != NULL) && (SortCompare(tailPtr->objPtr,
      
      +                   rightPtr->objPtr, infoPtr) == 0)) {
      
      +               rightPtr = rightPtr->nextPtr;
      
      +           }
      
      +           if ((leftPtr == NULL) || (rightPtr == NULL)) {
      
      +               break;
      
      +           }
      
      +       }
      
              if (SortCompare(leftPtr->objPtr, rightPtr->objPtr, infoPtr) > 0) {
      
                  tailPtr->nextPtr = rightPtr;
      
                  tailPtr = rightPtr;
      
      ***************
      
      *** 2673,2681 ****
      
              }
      
            }
      
            if (leftPtr != NULL) {
      
      !        tailPtr->nextPtr = leftPtr;
      
            } else {
      
      !        tailPtr->nextPtr = rightPtr;
      
            }
      
            return headPtr;
      
        }
      
      --- 2693,2723 ----
      
              }
      
            }
      
            if (leftPtr != NULL) {
      
      !       if (infoPtr->isUnique != 0) {
      
      !           while (leftPtr != NULL) {
      
      !               if (SortCompare(tailPtr->objPtr, leftPtr->objPtr,
      
      !                       infoPtr) != 0) {
      
      !                   tailPtr->nextPtr = leftPtr;
      
      !                   tailPtr = leftPtr;
      
      !               }
      
      !               leftPtr = leftPtr->nextPtr;
      
      !           }
      
      !       } else {
      
      !           tailPtr->nextPtr = leftPtr;
      
      !       }
      
            } else {
      
      !       if (infoPtr->isUnique != 0) {
      
      !           while (rightPtr != NULL) {
      
      !               if (SortCompare(tailPtr->objPtr, rightPtr->objPtr,
      
      !                       infoPtr) != 0) {
      
      !                   tailPtr->nextPtr = rightPtr;
      
      !                   tailPtr = rightPtr;
      
      !               }
      
      !               rightPtr = rightPtr->nextPtr;
      
      !           }
      
      !       } else {
      
      !           tailPtr->nextPtr = rightPtr;
      
      !       }
      
            }
      
            return headPtr;
      
        }
      
      
      
      PatchFiles:
      
      generic/tclCmdIL.c
      
      
      
      
      
      Would be a good new feature.  Must be tested. 
      -- 09/18/1999 hobbs
      Through the magic of the byte code compiler, this is actually
      slower than:
      
      # lunique --
      #   order independent list unique proc.  most efficient, but requires
      #   __LIST never be an element of the input list
      # Arguments:
      #   __LISTlist of items to make unique
      # Returns:
      #   list of only unique items, order not defined
      #
      ;proc lunique __LIST {
          if {[llength $__LIST]} {
      foreach $__LIST $__LIST break
      unset __LIST
      return [info locals]
          }
      }
      
      lsort [lunique $list]
      
      Still working on something though, because it'd be nice. 
      -- 12/15/1999 hobbs
      
    4. foundin initialized to: "obsolete: 8.2"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "69. Other"
    10. title initialized to: "lsort -unique flag"
    11. type initialized to: "RFE"
  2. Ticket change [83793c138d] (rid 117387) by welch on 2000-10-26 08:09:12:

    1. closedate changed to: "2000-10-26T01:09:12"
    2. closer changed to: "welch"
    3. priority changed to: "3 Low"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  3. Ticket change [47cc2b4467] (rid 99766) by dgp on 2001-04-14 02:12:13:

    1. foundin changed to: "None"
    2. status changed to: "Open"
    3. subsystem changed to: "None"
  4. Ticket change [8693959ed6] (rid 131535) by dgp on 2001-04-14 02:12:47:

    1. closedate changed to: "2001-04-13T19:12:47"
    2. closer changed to: "dgp"
    3. status changed to: "Closed"
    4. subsystem changed to: "17. Commands I-L"