windows-nt/Source/XPSP1/NT/base/crts/crtw32/mbstring/mbsicoll.c

81 lines
2.1 KiB
C
Raw Permalink Normal View History

2020-09-26 03:20:57 -05:00
/***
*mbsicoll.c - Collate MBCS strings, ignoring case
*
* Copyright (c) 1994-2001, Microsoft Corporation. All rights reserved.
*
*Purpose:
* Collate MBCS strings, ignoring case
*
*Revision History:
* 05-12-94 CFW Module created from mbs*cmp.c
* 06-03-94 CFW Allow non-_INTL.
* 09-06-94 CFW Allow non-_WIN32!.
* 12-21-94 CFW Remove fcntrlcomp NT 3.1 hack.
* 09-26-97 BWT Fix POSIX
* 04-07-98 GJF Implemented multithread support based on threadmbcinfo
* structs
* 05-17-99 PML Remove all Macintosh support.
*
*******************************************************************************/
#ifdef _MBCS
#include <awint.h>
#include <mtdll.h>
#include <cruntime.h>
#include <internal.h>
#include <mbdata.h>
#include <mbctype.h>
#include <mbstring.h>
/***
* _mbsicoll - Collate MBCS strings, ignoring case
*
*Purpose:
* Collates two strings for lexical order. Strings
* are collated on a character basis, not a byte basis.
*
*Entry:
* char *s1, *s2 = strings to collate
*
*Exit:
* returns <0 if s1 < s2
* returns 0 if s1 == s2
* returns >0 if s1 > s2
*
*Exceptions:
*
*******************************************************************************/
int __cdecl _mbsicoll(
const unsigned char *s1,
const unsigned char *s2
)
{
#if defined(_POSIX_)
return _mbsicmp(s1, s2);
#else
int ret;
#ifdef _MT
pthreadmbcinfo ptmbci = _getptd()->ptmbcinfo;
if ( ptmbci != __ptmbcinfo )
ptmbci = __updatetmbcinfo();
if ( 0 == (ret = __crtCompareStringA( ptmbci->mblcid, NORM_IGNORECASE,
s1, -1, s2, -1,
ptmbci->mbcodepage )) )
#else
if ( 0 == (ret = __crtCompareStringA( __mblcid, NORM_IGNORECASE,
s1, -1, s2, -1,
__mbcodepage )) )
#endif
return _NLSCMPERROR;
return ret - 2;
#endif /* _POSIX_ */
}
#endif /* _MBCS */