Changeset 1807


Ignore:
Timestamp:
Feb 2, 2005, 1:15:37 AM (21 years ago)
Author:
bird
Message:

Fixed bubble sort in collate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/locale/setlocale.c

    • Property cvs2svn:cvs-rev changed from 1.18 to 1.19
    r1806 r1807  
    413413         */
    414414        struct __collate_weight     aCW[256];
    415         int                         i, j;
     415        int                         i, c;
    416416
    417417        /* Initialize character weights. */
     
    439439         * of equal elements stays the same.
    440440         */
    441         /** @todo check this algorithm, it doesn't look right! */
    442         for (i = 0; i < 255; i++)
    443             for (j = i; j < 255; j++)
    444                 if (UniStrncmp(aCW[j].ucsWeight, aCW[j + 1].ucsWeight, MIN(aCW[j].len, aCW[j + 1].len)) > 0)
    445                     _memswap(&aCW[j], &aCW[j + 1], sizeof(aCW[j]));
     441        c = 256 - 1;
     442        do
     443        {
     444            int j = 0;
     445            for (i = 0; i < c; i++)
     446                if (UniStrncmp(aCW[i].ucsWeight, aCW[i + 1].ucsWeight, MIN(aCW[i].len, aCW[i + 1].len)) > 0)
     447                {
     448                    _memswap(&aCW[i], &aCW[i + 1], sizeof(aCW[i]));
     449                    j = i;
     450                }
     451            c = j;
     452        } while (c);
    446453
    447454        /*
Note: See TracChangeset for help on using the changeset viewer.