Skip to content
Tcl Source Code History Of Ticket 3613609fffffffff
Login

History Of Ticket 3613609fffffffff

Artifacts Associated With Ticket 3613609fffffffff

  1. Ticket change [29137b4d39] (rid 88810) by apnadkarni on 2013-05-20 17:42:15:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      From the chat
      
      I don't expect the following two commands to give the same answer
      [00:00]apn(wits) 93 % lsort  [list \u101 \u100]
      Ā ā
      (wits) 94 % lsort  -nocase [list \u101 \u100]
      Ā ā
      [00:01]apnWith -nocase, I would expect the second command to return ā Ā
      [00:02]yukonbob exits, stage left!
      [00:02]apnjust like
      [00:02]apn(wits) 96 % lsort [list a A]
      A a
      (wits) 97 % lsort -nocase [list a A]
      a A
      [00:04]dgpfile the bug
      
      The issue boils down to MergeLists using strcasecmp which does not handle non-ASCII characters.
      
    4. foundin initialized to: "current: 8.6.0"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "apnadkarni"
    10. subsystem initialized to: "17. Commands I-L"
    11. title initialized to: "lsort -nocase does not sort non-ASCII correctly"
    12. type initialized to: "Bug"
  2. Ticket change [dfd1744538] (rid 115080) by dkf on 2013-05-21 03:03:30:

    1. icomment:
      Line 4236 of tclCmdIL.c on the trunk has strcasecmp() in use, and it seems that at least some versions of that function don't handle non-ASCII right. (What a surprise, NOT!)
      
      There's a Tcl_UtfNcasecmp() but there's no Tcl_UtfCasecmp()…
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  3. Ticket change [5e6ec1d4ce] (rid 115637) by dkf on 2013-05-21 03:04:24:

    1. icomment:
      Also, [lsearch] has an equivalent problem.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  4. Ticket change [37cb9ff0b0] (rid 112093) by apnadkarni on 2013-05-21 09:59:01:

    1. icomment:
      I wrote a replacement stub along the lines of 
      
          char *a, *b;
          int alen, blen, len;
          int comparison;
      
          a = Tcl_GetStringFromObj(oaP, &alen);
          b = Tcl_GetStringFromObj(obP, &blen);
          
          /* TBD - maybe check first letter before calling ? */
      
          // This is much slower than the strcmp method 
          alen = Tcl_NumUtfChars(a, alen); /* Num bytes -> num chars */
          blen = Tcl_NumUtfChars(b, blen); /* Num bytes -> num chars */
      
          len = alen < blen ? alen : blen; /* len is the shorter length */
          comparison = (ignorecase ? Tcl_UtfNcasecmp : Tcl_UtfNcmp)(a, b, len);
          if (comparison == 0) {
              comparison = alen-blen;
          }
          return (comparison > 0) ? 1 : ((comparison < 0) ? -1 : 0);
      
      This seems to work correctly (for the single test case!). However, by my measurements, it is almost "3 times slower" than the current strcmp based code. I don't know if that can be fixed. And if it has not bothered anyone else for so many years, well... 
      
      Failure in the lsearch case is quite likely more important (comparing paths on Windows for instance).
      
      string compare seems to do the right thing
      
      /Ashok
      
      
      
    2. login: "apnadkarni"
    3. mimetype: "text/plain"
    4. username: "apnadkarni"
  5. Ticket change [76b3de12a1] (rid 105628) by dkf on 2013-05-21 16:22:31:

    1. icomment:
      [string compare] uses Tcl_UtfNcasecmp, which does the right thing (well, in 8.6 it does and I've not checked earlier versions).
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  6. Ticket change [595e7001f2] (rid 117969) by nijtmans on 2013-05-21 16:28:28:

    1. icomment:
      Proposed solution here:
          <http://core.tcl.tk/tcl/info/66c30c4369>
      
      @dkf, please evaluate
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  7. Ticket change [01a3397a2c] (rid 119512) by nijtmans on 2013-05-21 16:39:03:

    1. icomment:
      Slight improvement: if cs = "\xC0\x80" and ct = "\x00", loop would continue after NUL-byte, this should not happen.  See:
          <http://core.tcl.tk/tcl/info/a765f37f78>
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  8. Ticket change [a8b40118f9] (rid 99039) by dkf on 2013-05-21 19:41:27:

    1. icomment:
      Changes to implementation look OK at first glance. Will need to check test suite for whether that's also got enough tests.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  9. Ticket change [ff6e397e1c] (rid 108750) by dkf on 2013-05-22 19:37:22:

    1. icomment:
      Found a problem in TclUtfCasecmp(); I get the wrong result from this:
        lsort -ascii -nocase [list a\u0000a a]
      
      The problem comes when two strings are a different length but the character in the longer at the index of the length of the shorter is \u0000; we're saying the wrong string is shorter (or that the two strings are the same).
      
      (Evil edge cases 'Я' us!)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  10. Ticket change [3e77a73eac] (rid 121271) by nijtmans on 2013-05-22 19:40:16:

    1. icomment:
      Good catch! I'll have a look.
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  11. Ticket change [4b5082cdcf] (rid 126686) by nijtmans on 2013-05-22 19:42:57:

    1. icomment:
      ... but if you have a suggestion how to fix this, that's great too.
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  12. Ticket change [060726fd4c] (rid 89146) by dkf on 2013-05-22 19:52:17:

    1. icomment:
      I'm just testing the fix
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  13. Ticket change [d3b4b5e179] (rid 123331) by dkf on 2013-05-22 20:01:28:

    1. icomment:
      Fixed in 8.5 branch; rolling forward into trunk.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. resolution changed to: "Fixed"
    5. username: "dkf"
  14. Ticket change [deb79e2f57] (rid 114899) by nijtmans on 2013-05-22 20:03:02:

    1. icomment:
      Thanks! I couldn't have done it better!
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  15. Ticket change [438fa7badb] (rid 116576) by dkf on 2013-05-22 20:08:06:

    1. closedate changed to: "2013-05-22T13:08:06"
    2. closer changed to: "dkf"
    3. icomment:
      
      
      allow_comments - 1
      
      All sorted. Thanks for your help.
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "dkf"