Menu

#599 lsort -integer fails with wide integers

open
5
2011-03-16
2011-03-16
No

lsort -integer fails when trying to sort a list of wide integers (i.e. a list with timestamps, like clock milliseconds returns).

I see for example in Tcl_LsortObjCmd(), in file tclCmdIL.c, line 3911 (may have changed I haven't updated to fossil):

} else if (sortMode == SORTMODE_INTEGER) {
long a;
if (TclGetLongFromObj(sortInfo.interp, indexPtr, &a) != TCL_OK) {
sortInfo.resultCode = TCL_ERROR;
goto done1;
}
elementArray[i].index.intValue = a;

I think that Tcl_GetWideIntFromObj() should be called if Tcl_GetLongFromObj() fails, before returning an error to the caller...

Discussion

  • Don Porter

    Don Porter - 2011-03-16
    • labels: 105658 --> 17. Commands I-L
     
  • Don Porter

    Don Porter - 2011-03-16

    This is not a bug. It's preservation of compatible output
    from [lsort -integer] across minor releases.

    That may be an unwise choice, but changing it is a
    feature request.

     
  • Don Porter

    Don Porter - 2011-03-17

    See http://core.tcl.tk/tcl/info/cf82eb92c8
    for a checkin implementing the requested
    functionality as [lsort -entier].

     
  • Don Porter

    Don Porter - 2011-03-17

    Very much un(der)tested at this point, BTW.