2007-03-14 20:24:57 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
2015-09-19 13:50:57 +00:00
|
|
|
* FILE: lib/sdk/crt/mbstring/mbsncoll.c
|
2007-03-14 20:24:57 +00:00
|
|
|
* PURPOSE:
|
|
|
|
* PROGRAMER: Ariadne
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* 12/04/99: Created
|
|
|
|
*/
|
|
|
|
#include <mbstring.h>
|
|
|
|
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
|
|
|
|
int colldif(unsigned short c1, unsigned short c2)
|
|
|
|
{
|
|
|
|
return c1 - c2;
|
|
|
|
}
|
2007-03-14 20:24:57 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
int _mbsncoll(const unsigned char *str1, const unsigned char *str2, size_t n)
|
|
|
|
{
|
|
|
|
unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
|
|
|
unsigned short *short_s1, *short_s2;
|
|
|
|
|
|
|
|
int l1, l2;
|
|
|
|
|
|
|
|
if (n == 0)
|
|
|
|
return 0;
|
|
|
|
do {
|
|
|
|
|
|
|
|
if (*s1 == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
l1 = _ismbblead(*s1);
|
|
|
|
l2 = _ismbblead(*s2);
|
|
|
|
if ( !l1 && !l2 ) {
|
|
|
|
|
|
|
|
if (*s1 != *s2)
|
|
|
|
return colldif(*s1, *s2);
|
|
|
|
else {
|
|
|
|
s1 += 1;
|
|
|
|
s2 += 1;
|
|
|
|
n--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( l1 && l2 ){
|
|
|
|
short_s1 = (unsigned short *)s1;
|
|
|
|
short_s2 = (unsigned short *)s2;
|
|
|
|
if ( *short_s1 != *short_s2 )
|
|
|
|
return colldif(*short_s1, *short_s2);
|
|
|
|
else {
|
|
|
|
s1 += 2;
|
|
|
|
s2 += 2;
|
|
|
|
n--;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return colldif(*s1, *s2);
|
|
|
|
} while (n > 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
int _mbsnbcoll(const unsigned char *str1, const unsigned char *str2, size_t n)
|
|
|
|
{
|
|
|
|
unsigned char *s1 = (unsigned char *)str1;
|
|
|
|
unsigned char *s2 = (unsigned char *)str2;
|
|
|
|
|
|
|
|
unsigned short *short_s1, *short_s2;
|
|
|
|
|
|
|
|
int l1, l2;
|
|
|
|
|
|
|
|
if (n == 0)
|
|
|
|
return 0;
|
|
|
|
do {
|
|
|
|
|
|
|
|
if (*s1 == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
l1 = _ismbblead(*s1);
|
|
|
|
l2 = _ismbblead(*s2);
|
|
|
|
if ( !l1 && !l2 ) {
|
|
|
|
|
|
|
|
if (*s1 != *s2)
|
|
|
|
return colldif(*s1, *s2);
|
|
|
|
else {
|
|
|
|
s1 += 1;
|
|
|
|
s2 += 1;
|
|
|
|
n--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( l1 && l2 ){
|
|
|
|
short_s1 = (unsigned short *)s1;
|
|
|
|
short_s2 = (unsigned short *)s2;
|
|
|
|
if ( *short_s1 != *short_s2 )
|
|
|
|
return colldif(*short_s1, *short_s2);
|
|
|
|
else {
|
|
|
|
s1 += 2;
|
|
|
|
s2 += 2;
|
|
|
|
n-=2;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return colldif(*s1, *s2);
|
|
|
|
} while (n > 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|