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

mbsncmp.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/mbsncmp.c
00005  * PURPOSE:     Compares two strings to a maximum of n bytes or characters
00006  * PROGRAMER:   Ariadne
00007  * UPDATE HISTORY:
00008  *              12/04/99: Created
00009  */
00010 
00011 #include <mbstring.h>
00012 
00013 /*
00014  * @implemented
00015  */
00016 int _mbsncmp(const unsigned char *str1, const unsigned char *str2, size_t n)
00017 {
00018     unsigned char *s1 = (unsigned char *)str1;
00019     unsigned char *s2 = (unsigned char *)str2;
00020 
00021     unsigned short *short_s1, *short_s2;
00022 
00023     int l1, l2;
00024 
00025     if (n == 0)
00026         return 0;
00027     do {
00028 
00029         if (*s1 == 0)
00030             break;
00031 
00032         l1 = _ismbblead(*s1);
00033         l2 = _ismbblead(*s2);
00034         if ( !l1 &&  !l2  ) {
00035 
00036             if (*s1 != *s2)
00037                 return *s1 - *s2;
00038             else {
00039                 s1 += 1;
00040                 s2 += 1;
00041                 n--;
00042             }
00043         }
00044         else if ( l1 && l2 ){
00045             short_s1 = (unsigned short *)s1;
00046             short_s2 = (unsigned short *)s2;
00047             if ( *short_s1 != *short_s2 )
00048                 return *short_s1 - *short_s2;
00049             else {
00050                 s1 += 2;
00051                 s2 += 2;
00052                 n--;
00053 
00054             }
00055         }
00056         else
00057             return *s1 - *s2;
00058     } while (n > 0);
00059     return 0;
00060 }
00061 
00062 /*
00063  * @implemented
00064  */
00065 int _mbsnbcmp(const unsigned char *str1, const unsigned char *str2, size_t n)
00066 {
00067     unsigned char *s1 = (unsigned char *)str1;
00068     unsigned char *s2 = (unsigned char *)str2;
00069 
00070     unsigned short *short_s1, *short_s2;
00071 
00072     int l1, l2;
00073 
00074     if (n == 0)
00075         return 0;
00076     do {
00077 
00078         if (*s1 == 0)
00079             break;
00080 
00081         l1 = _ismbblead(*s1);
00082         l2 = _ismbblead(*s2);
00083         if ( !l1 &&  !l2  ) {
00084 
00085             if (*s1 != *s2)
00086                 return *s1 - *s2;
00087             else {
00088                 s1 += 1;
00089                 s2 += 1;
00090                 n--;
00091             }
00092         }
00093         else if ( l1 && l2 ){
00094             short_s1 = (unsigned short *)s1;
00095             short_s2 = (unsigned short *)s2;
00096             if ( *short_s1 != *short_s2 )
00097                 return *short_s1 - *short_s2;
00098             else {
00099                 s1 += 2;
00100                 s2 += 2;
00101                 n-=2;
00102 
00103             }
00104         }
00105         else
00106             return *s1 - *s2;
00107     } while (n > 0);
00108     return 0;
00109 }

Generated on Sat May 26 2012 04:35:28 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.