1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS system libraries 4 * FILE: lib/sdk/crt/mbstring/mbscoll.c 5 * PURPOSE: 6 * PROGRAMER: Ariadne 7 * UPDATE HISTORY: 8 * 12/04/99: Created 9 */ 10 11 #include <mbstring.h> 12 13 int colldif(unsigned short c1, unsigned short c2); 14 15 /* 16 * @implemented 17 */ 18 int _mbscoll(const unsigned char *str1, const unsigned char *str2) 19 { 20 unsigned char *s1 = (unsigned char *)str1; 21 unsigned char *s2 = (unsigned char *)str2; 22 23 unsigned short *short_s1, *short_s2; 24 25 int l1, l2; 26 27 while ( *s1 != 0 ) { 28 29 if (*s1 == 0) 30 break; 31 32 l1 = _ismbblead(*s1); 33 l2 = _ismbblead(*s2); 34 if ( !l1 && !l2 ) { 35 36 if (*s1 != *s2) 37 return colldif(*s1, *s2); 38 else { 39 s1 += 1; 40 s2 += 1; 41 } 42 } 43 else if ( l1 && l2 ){ 44 short_s1 = (unsigned short *)s1; 45 short_s2 = (unsigned short *)s2; 46 if ( *short_s1 != *short_s2 ) 47 return colldif(*short_s1, *short_s2); 48 else { 49 s1 += 2; 50 s2 += 2; 51 52 } 53 } 54 else 55 return colldif(*s1, *s2); 56 } ; 57 return 0; 58 } 59 60 #if 0 61 int _mbsbcoll(const unsigned char *str1, const unsigned char *str2) 62 { 63 unsigned char *s1 = (unsigned char *)str1; 64 unsigned char *s2 = (unsigned char *)str2; 65 66 unsigned short *short_s1, *short_s2; 67 68 int l1, l2; 69 70 71 while ( *s1 != 0 ) { 72 73 74 l1 = _ismbblead(*s1); 75 l2 = _ismbblead(*s2); 76 if ( !l1 && !l2 ) { 77 78 if (*s1 != *s2) 79 return colldif(*s1, *s2); 80 else { 81 s1 += 1; 82 s2 += 1; 83 } 84 } 85 else if ( l1 && l2 ){ 86 short_s1 = (unsigned short *)s1; 87 short_s2 = (unsigned short *)s2; 88 if ( *short_s1 != *short_s2 ) 89 return colldif(*short_s1, *short_s2); 90 else { 91 s1 += 2; 92 s2 += 2; 93 } 94 } 95 else 96 return colldif(*s1, *s2); 97 } ; 98 return 0; 99 } 100 #endif 101