ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

mbsncoll.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:   See COPYING in the top level directory
00003  * PROJECT:     ReactOS system libraries
00004  * FILE:        lib/msvcrt/mbstring/mbsncoll.c
00005  * PURPOSE:
00006  * PROGRAMER:   Ariadne
00007  * UPDATE HISTORY:
00008  *              12/04/99: Created
00009  */
00010 #include <mbstring.h>
00011 
00012 
00013 int colldif(unsigned short c1, unsigned short c2)
00014 {
00015   return c1 - c2;
00016 }
00017 
00018 /*
00019  * @implemented
00020  */
00021 int _mbsncoll(const unsigned char *str1, const unsigned char *str2, size_t n)
00022 {
00023     unsigned char *s1 = (unsigned char *)str1;
00024     unsigned char *s2 = (unsigned char *)str2;
00025 
00026     unsigned short *short_s1, *short_s2;
00027 
00028     int l1, l2;
00029 
00030     if (n == 0)
00031         return 0;
00032     do {
00033 
00034         if (*s1 == 0)
00035             break;
00036 
00037         l1 = _ismbblead(*s1);
00038         l2 = _ismbblead(*s2);
00039         if ( !l1 &&  !l2  ) {
00040 
00041             if (*s1 != *s2)
00042                 return colldif(*s1, *s2);
00043             else {
00044                 s1 += 1;
00045                 s2 += 1;
00046                 n--;
00047             }
00048         }
00049         else if ( l1 && l2 ){
00050             short_s1 = (unsigned short *)s1;
00051             short_s2 = (unsigned short *)s2;
00052             if ( *short_s1 != *short_s2 )
00053                 return colldif(*short_s1, *short_s2);
00054             else {
00055                 s1 += 2;
00056                 s2 += 2;
00057                 n--;
00058 
00059             }
00060         }
00061         else
00062             return colldif(*s1, *s2);
00063     } while (n > 0);
00064     return 0;
00065 }
00066 
00067 /*
00068  * @implemented
00069  */
00070 int _mbsnbcoll(const unsigned char *str1, const unsigned char *str2, size_t n)
00071 {
00072     unsigned char *s1 = (unsigned char *)str1;
00073     unsigned char *s2 = (unsigned char *)str2;
00074 
00075     unsigned short *short_s1, *short_s2;
00076 
00077     int l1, l2;
00078 
00079     if (n == 0)
00080         return 0;
00081     do {
00082 
00083         if (*s1 == 0)
00084             break;
00085 
00086         l1 = _ismbblead(*s1);
00087         l2 = _ismbblead(*s2);
00088         if ( !l1 &&  !l2  ) {
00089 
00090             if (*s1 != *s2)
00091                 return colldif(*s1, *s2);
00092             else {
00093                 s1 += 1;
00094                 s2 += 1;
00095                 n--;
00096             }
00097         }
00098         else if ( l1 && l2 ){
00099             short_s1 = (unsigned short *)s1;
00100             short_s2 = (unsigned short *)s2;
00101             if ( *short_s1 != *short_s2 )
00102                 return colldif(*short_s1, *short_s2);
00103             else {
00104                 s1 += 2;
00105                 s2 += 2;
00106                 n-=2;
00107 
00108             }
00109         }
00110         else
00111             return colldif(*s1, *s2);
00112     } while (n > 0);
00113     return 0;
00114 }
00115 

Generated on Sun May 27 2012 04:36:29 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.