Changeset 3002 for trunk


Ignore:
Timestamp:
Apr 7, 2007, 1:59:21 AM (18 years ago)
Author:
bird
Message:

Fixed a typo in the collate default data. Optimized strcoll and added a primitive strcoll testcase.

Location:
trunk/libc
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/libc/src/libc/locale/locale_collate.c

    r2717 r3002  
    3333    {
    3434          0,   1,   2,   3,   4,   5,   6,   7,   8,   9,
    35          10,  11,  13,  12,  14,  15,  16,  17,  18,  19,
    36          20,  21,  23,  22,  24,  25,  26,  27,  28,  29,
    37          30,  31,  33,  32,  34,  35,  36,  37,  38,  39,
    38          40,  41,  43,  42,  44,  45,  46,  47,  48,  49,
    39          50,  51,  53,  52,  54,  55,  56,  57,  58,  59,
    40          60,  61,  63,  62,  64,  65,  66,  67,  68,  69,
    41          70,  71,  73,  72,  74,  75,  76,  77,  78,  79,
    42          80,  81,  83,  82,  84,  85,  86,  87,  88,  89,
    43          90,  91,  93,  92,  94,  95,  96,  97,  98,  99,
    44         100, 101, 103, 102, 104, 105, 106, 107, 108, 109,
    45         110, 111, 113, 112, 114, 115, 116, 117, 118, 119,
    46         120, 121, 123, 122, 124, 125, 126, 127, 128, 129,
    47         130, 131, 133, 132, 134, 135, 136, 137, 138, 139,
    48         140, 141, 143, 142, 144, 145, 146, 147, 148, 149,
    49         150, 151, 153, 152, 154, 155, 156, 157, 158, 159,
    50         160, 161, 163, 162, 164, 165, 166, 167, 168, 169,
    51         170, 171, 173, 172, 174, 175, 176, 177, 178, 179,
    52         180, 181, 183, 182, 184, 185, 186, 187, 188, 189,
    53         190, 191, 193, 192, 194, 195, 196, 197, 198, 199,
    54         200, 201, 203, 202, 204, 205, 206, 207, 208, 209,
    55         210, 211, 213, 212, 214, 215, 216, 217, 218, 219,
    56         220, 221, 223, 222, 224, 225, 226, 227, 228, 229,
    57         230, 231, 233, 232, 234, 235, 236, 237, 238, 239,
    58         240, 241, 243, 242, 244, 245, 246, 247, 248, 249,
    59         250, 251, 253, 252, 254, 255
     35         10,  11,  12,  13,  14,  15,  16,  17,  18,  19,
     36         20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
     37         30,  31,  32,  33,  34,  35,  36,  37,  38,  39,
     38         40,  41,  42,  43,  44,  45,  46,  47,  48,  49,
     39         50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
     40         60,  61,  62,  63,  64,  65,  66,  67,  68,  69,
     41         70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
     42         80,  81,  82,  83,  84,  85,  86,  87,  88,  89,
     43         90,  91,  92,  93,  94,  95,  96,  97,  98,  99,
     44        100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
     45        110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
     46        120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
     47        130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
     48        140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
     49        150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
     50        160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
     51        170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
     52        180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
     53        190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
     54        200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
     55        210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
     56        220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
     57        230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
     58        240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
     59        250, 251, 252, 253, 254, 255
    6060    },
    6161    .au2MBCSPrefixs =
  • trunk/libc/src/libc/str/strcoll.c

    r2717 r3002  
    3131  if (__libc_gLocaleCollate.mbcs)
    3232  {
    33     FS_VAR();
    34     FS_SAVE_LOAD();
    3533    /* MBCS case. We compare the strings as usual, but as soon as we
    3634       encounter a MBCS character we translate the rests of the strings
     
    4543        UniChar *ucs [2];
    4644        const char *sbcs [2] = { s1, s2 };
     45        FS_VAR_SAVE_LOAD();
    4746
    4847        /* I can't imagine X bytes to convert into more
     
    5554          UniChar *outbuf = ucs [i] = alloca (sl * sizeof (UniChar));
    5655
    57           if (UniUconvToUcs (__libc_gLocaleCollate.uobj, &inbuf, &in_left, &outbuf,
    58                 &out_left, &nonid))
     56          if (UniUconvToUcs (__libc_gLocaleCollate.uobj, &inbuf, &in_left, &outbuf, &out_left, &nonid))
    5957          {
    6058            /* Oops, something bad happened (invalid character code). Suppose
     
    7270#endif
    7371
    74       d = __libc_gLocaleCollate.auchWeight [c1] - __libc_gLocaleCollate.auchWeight [c2];
    75       if (d || !c1 || !c2)
     72      if (c1 != c2)
    7673      {
    77         FS_RESTORE();
    78         return d;
     74        d = __libc_gLocaleCollate.auchWeight [c1] - __libc_gLocaleCollate.auchWeight [c2];
     75        if (d || !c1 || !c2)
     76          return d;
    7977      }
     78      else if (!c1)
     79        return 0;
    8080      c1 = *++s1;
    8181      c2 = *++s2;
    8282    } /* endfor */
    83     FS_RESTORE();
    8483  }
    8584  else
     
    8786    for (;;)
    8887    {
    89       d = __libc_gLocaleCollate.auchWeight [c1] - __libc_gLocaleCollate.auchWeight [c2];
    90       if (d || !c1 || !c2)
    91         return d;
     88      if (c1 != c2)
     89      {
     90        d = __libc_gLocaleCollate.auchWeight [c1] - __libc_gLocaleCollate.auchWeight [c2];
     91        if (d || !c1 || !c2)
     92          return d;
     93      }
     94      else if (!c1)
     95        return 0;
    9296      c1 = *++s1;
    9397      c2 = *++s2;
  • trunk/libc/tests/libc/Makefile

    r2810 r3002  
    8181        smoketests/spm-1.c \
    8282        smoketests/stat-1.c \
     83        smoketests/strcoll-1.c \
    8384        smoketests/strnlen-1.c \
    8485        smoketests/strtof-1.c \
Note: See TracChangeset for help on using the changeset viewer.