コード例 #1
0
ファイル: mbsspn.c プロジェクト: chunhualiu/OpenNT
unsigned char * __cdecl _mbsspnp(
    const unsigned char *string,
    const unsigned char *charset
    )

#endif

{
        unsigned char *p, *q;

#ifndef _RETURN_PTR
        if (0 == __mbcodepage)
            return strspn(string, charset);
#else
        if (0 == __mbcodepage)
        {
            size_t retval;
            retval = strspn(string, charset);
            return (unsigned char *)(*(string + retval) ? string + retval : NULL);
        }
#endif
        _mlock(_MB_CP_LOCK);

	/* loop through the string to be inspected */
        for (q = (char *)string; *q; q++) {

		/* loop through the charset */
                for (p = (char *)charset; *p; p++) {

			if (_ISLEADBYTE(*p)) {
				if (((*p == *q) && (p[1] == q[1])) || p[1] == '\0')
					break;
				p++;
			}

			else
				if (*p == *q)
					break;
                }

		if (*p == '\0') 	/* end of charset? */
			break;		/* yes, no match on this char */

		if (_ISLEADBYTE(*q))
                        if (*++q == '\0')
                                break;
        }

        _munlock(_MB_CP_LOCK);

#ifndef _RETURN_PTR
	return((size_t) (q - string));		/* index */
#else
	return((*q) ? q : NULL);	/* pointer */
#endif


}
コード例 #2
0
int __cdecl _mbsnbcmp(
        const unsigned char *s1,
        const unsigned char *s2,
        size_t n
        )
{
        unsigned short c1, c2;

        if (n==0)
                return(0);

        if ( _ISNOTMBCP )
            return strncmp(s1, s2, n);

        _mlock(_MB_CP_LOCK);

        while (n--) {

                c1 = *s1++;
                if (_ISLEADBYTE(c1)) {
                        if (n==0)
                {
                    c1 = 0; /* 'naked' lead - end of string */
                    c2 = _ISLEADBYTE(*s2) ? 0 : *s2;
                    goto test;
                }
                        c1 = ( (*s1 == '\0') ? 0 : ((c1<<8) | *s1++) );
                }

                c2 = *s2++;
                if (_ISLEADBYTE(c2)) {
                        if (n==0)
                {
                    c2 = 0; /* 'naked' lead - end of string */
                    goto test;
                }
                --n;
                        c2 = ( (*s2 == '\0') ? 0 : ((c2<<8) | *s2++) );
                }
test:
                if (c1 != c2)
            {
                _munlock(_MB_CP_LOCK);
                        return( (c1 > c2) ? 1 : -1);
            }

                if (c1 == 0)
            {
                _munlock(_MB_CP_LOCK);
                        return(0);
            }
        }

        _munlock(_MB_CP_LOCK);
        return(0);
}
コード例 #3
0
ファイル: mbsdec.c プロジェクト: chunhualiu/OpenNT
unsigned char * __cdecl _mbsdec(
    const unsigned char *string,
    const unsigned char *current
    )
{
	const unsigned char *temp;

	if (string >= current)
		return(NULL);

        if (0 == __mbcodepage)
            return (unsigned char *)--current;

        _mlock(_MB_CP_LOCK);

	temp = current - 1;

/*
 *  If (current-1) returns true from _ISLEADBTYE, it is a trail byte, because
 *  it is not a legal single byte MBCS character.  Therefore, is so, return
 *  (current-2) because it is the trailbyte's lead.
 */

	if (_ISLEADBYTE(*temp))
        {
            _munlock(_MB_CP_LOCK);
		return (unsigned char *)(temp - 1);
        }

/*
 *  It is unknown whether (current - 1) is a single byte character or a
 *  trail.  Now decrement temp until
 *	a)  The beginning of the string is reached, or
 *	b)  A non-lead byte (either single or trail) is found.
 *  The difference between (current-1) and temp is the number of non-single
 *  byte characters preceding (current-1).  There are two cases for this:
 *	a)  (current - temp) is odd, and
 *	b)  (current - temp) is even.
 *  If odd, then there are an odd number of "lead bytes" preceding the
 *  single/trail byte (current - 1), indicating that it is a trail byte.
 *  If even, then there are an even number of "lead bytes" preceding the
 *  single/trail byte (current - 1), indicating a single byte character.
 */

	while ((string <= --temp) && (_ISLEADBYTE(*temp)))
		;

        _munlock(_MB_CP_LOCK);
	return (unsigned char *)(current - 1 - ((current - temp) & 0x01) );

}
コード例 #4
0
ファイル: ismbstr.c プロジェクト: chunhualiu/OpenNT
int __cdecl _ismbstrail(
    const unsigned char *string,
    const unsigned char *current
    )
{
        if (0 == __mbcodepage)
            return 0;

        _mlock(_MB_CP_LOCK);

	while (string <= current && *string) {
		if (_ISLEADBYTE((*string))) {
			if (++string == current)	/* check trail byte */
                {
                    _munlock(_MB_CP_LOCK);
				return -1;
                }
			if (!(*string))
                {
                    _munlock(_MB_CP_LOCK);
				return 0;
                }
		}
		++string;
	}

        _munlock(_MB_CP_LOCK);
	return 0;
}
コード例 #5
0
int __cdecl _ismbslead(
        const unsigned char *string,
        const unsigned char *current
        )
{
        if ( _ISNOTMBCP )
            return 0;

        _mlock(_MB_CP_LOCK);

        while (string <= current && *string) {
                if (_ISLEADBYTE((*string))) {
                        if (string++ == current)        /* check lead byte */
                {
                    _munlock(_MB_CP_LOCK);
                                return -1;
                }
                        if (!(*string))
                {
                    _munlock(_MB_CP_LOCK);
                                return 0;
                }
                }
                ++string;
        }

        _munlock(_MB_CP_LOCK);
        return 0;
}
コード例 #6
0
ファイル: mbsrchr.c プロジェクト: demonMOE-s/win32CRT
unsigned char * __cdecl _mbsrchr(
    const unsigned char *str,
    unsigned int c
)
{
    char *r = NULL;
    unsigned int cc;

    if (0 == __mbcodepage)
        return strrchr(str, c);

    _mlock(_MB_CP_LOCK);

    do {
        cc = *str;
        if (_ISLEADBYTE(cc)) {
            if(*++str) {
                if (c == ((cc<<8)|*str))
                    r = (char *)str - 1;
            }
            else if(!r)
                /* return pointer to '\0' */
                r = (char *)str;
        }
        else if (c == cc)
            r = (char *)str;
    }
    while (*str++);

    _munlock(_MB_CP_LOCK);
    return(r);
}
コード例 #7
0
ファイル: mbsnbcat.c プロジェクト: chunhualiu/OpenNT
unsigned char * __cdecl _mbsnbcat(
    unsigned char *dst,
    const unsigned char *src,
    size_t cnt
    )
{
	unsigned char *start;

	if (!cnt)
		return(dst);

        if (0 == __mbcodepage)
            return strncat(dst, src, cnt);

        _mlock(_MB_CP_LOCK);

	start = dst;
	while (*dst++)
                ;
	--dst;		// dst now points to end of dst string


	/* if last char in string is a lead byte, back up pointer */

        if (_MBSBTYPE(start, (int) ((dst - start) - 1)) == _MBC_LEAD)
		--dst;

	/* copy over the characters */

	while (cnt--) {

		if (_ISLEADBYTE(*src)) {
			*dst++ = *src++;
			if (!cnt--) {	/* write nul if cnt exhausted */
				dst[-1] = '\0';
				break;
			}
			if ((*dst++ = *src++)=='\0') { /* or if no trail byte */
				dst[-2] = '\0';
                                break;
                        }
                }

		else if ((*dst++ = *src++) == '\0')
                        break;

        }

	/* enter final nul, if necessary */

	if (_MBSBTYPE(start, (int) ((dst - start) - 1)) == _MBC_LEAD)
	    dst[-1] = '\0';
	else
	    *dst = '\0';


        _munlock(_MB_CP_LOCK);
	return(start);
}
コード例 #8
0
unsigned char * __cdecl _mbslwr(
    unsigned char *string
    )
{
        unsigned char *cp;

        _mlock(_MB_CP_LOCK);

        for (cp=string; *cp; cp++)
        {
            if (_ISLEADBYTE(*cp))
            {

#if defined (_WIN32)

                int retval;
                unsigned char ret[4];

                if ((retval = __crtLCMapStringA(__mblcid,
                                                LCMAP_LOWERCASE,
                                                cp,
                                                2,
                                                ret,
                                                2,
                                                __mbcodepage,
                                                TRUE)) == 0)
                {
                    _munlock(_MB_CP_LOCK);
                    return NULL;
                }

                *cp = ret[0];

                if (retval > 1)
                    *(++cp) = ret[1];

#else  /* defined (_WIN32) */

                int mbval = ((*cp) << 8) + *(cp+1);

                cp++;
                if (     mbval >= _MBUPPERLOW1
                    &&   mbval <= _MBUPPERHIGH1 )
                    *cp += _MBCASEDIFF1;

                else if (mbval >= _MBUPPERLOW2
                    &&   mbval <= _MBUPPERHIGH2 )
                    *cp += _MBCASEDIFF2;
#endif  /* defined (_WIN32) */

            }
            else
                /* single byte, macro version */
                *cp = (unsigned char) _mbbtolower(*cp);
        }

        _munlock(_MB_CP_LOCK);
        return string ;
}
コード例 #9
0
int __cdecl _mbsncmp(
        const unsigned char *s1,
        const unsigned char *s2,
        size_t n
        )
{
        unsigned short c1, c2;

        if (n==0)
            return(0);

        if ( _ISNOTMBCP )
            return strncmp(s1, s2, n);

        _mlock(_MB_CP_LOCK);

        while (n--) {

            c1 = *s1++;
            if (_ISLEADBYTE(c1))
                c1 = ( (*s1 == '\0') ? 0 : ((c1<<8) | *s1++) );

            c2 = *s2++;
            if (_ISLEADBYTE(c2))
                c2 = ( (*s2 == '\0') ? 0 : ((c2<<8) | *s2++) );

            if (c1 != c2)
            {
                _munlock(_MB_CP_LOCK);
                return( (c1 > c2) ? 1 : -1);
            }

            if (c1 == 0)
            {
                _munlock(_MB_CP_LOCK);
                return(0);
            }
        }

        _munlock(_MB_CP_LOCK);
        return(0);
}
コード例 #10
0
void __cdecl _mbccpy(
    unsigned char *dst,
    const unsigned char *src
    )
{
        *dst = *src;
        if (_ISLEADBYTE(*src))
                {
                *++dst = *++src;
                }
}
コード例 #11
0
ファイル: MBSNEXTC.C プロジェクト: ngphloc/agmagic
unsigned int __cdecl _mbsnextc(
    const unsigned char *s
    )
{
        unsigned int  next = 0;

        if (_ISLEADBYTE(*s))
            next = ((unsigned int) *s++) << 8;

        next += (unsigned int) *s;

        return(next);
}
コード例 #12
0
ファイル: mbscmp.c プロジェクト: chunhualiu/OpenNT
int __cdecl _mbscmp(
    const unsigned char *s1,
    const unsigned char *s2
    )
{
        unsigned short c1, c2;

        if (0 == __mbcodepage)
            return strcmp(s1, s2);

        _mlock(_MB_CP_LOCK);

        for (;;) {

            c1 = *s1++;
            if (_ISLEADBYTE(c1))
                c1 = ( (*s1 == '\0') ? 0 : ((c1<<8) | *s1++) );

            c2 = *s2++;
            if (_ISLEADBYTE(c2))
                c2 = ( (*s2 == '\0') ? 0 : ((c2<<8) | *s2++) );

            if (c1 != c2)
            {
                _munlock(_MB_CP_LOCK);
                return (c1 > c2) ? 1 : -1;
            }

            if (c1 == 0)
            {
                _munlock(_MB_CP_LOCK);
                return 0;
            }

	}

}
コード例 #13
0
ファイル: mbsnccnt.c プロジェクト: chunhualiu/OpenNT
size_t __cdecl _mbsnccnt(
    const unsigned char *string,
    size_t bcnt
    )
{
	unsigned int n;

        _mlock(_MB_CP_LOCK);

	for (n = 0; (bcnt-- && *string); n++, string++) {

		if (_ISLEADBYTE(*string)) {
			if ( (!bcnt--) || (*++string == '\0'))
                                break;
                }
        }

        _munlock(_MB_CP_LOCK);
        return(n);
}
コード例 #14
0
ファイル: mbsrev.c プロジェクト: chunhualiu/OpenNT
unsigned char * __cdecl _mbsrev(
    unsigned char *string
    )
{

	unsigned char *start = string;
	unsigned char *left  = string;
	unsigned char c;

        if (0 == __mbcodepage)
            return _strrev(string);

        _mlock(_MB_CP_LOCK);

	/* first go through and reverse the bytes in MBCS chars */
        while ( *string ) {

		if ( _ISLEADBYTE(*string++) ) {
                        if ( *string ) {
                                c = *string;
                                *string = *(string - 1);
                                *(string - 1) = c;
                                string++;
                        }
                        else /* second byte is EOS */
                                break;
                }
        }

	/* now reverse the whole string */
        string--;
        while ( left < string ) {
                c = *left;
                *left++ = *string;
                *string-- = c;
        }

        _munlock(_MB_CP_LOCK);
        return ( start );
}
コード例 #15
0
ファイル: mbsnbcnt.c プロジェクト: chunhualiu/OpenNT
size_t __cdecl _mbsnbcnt(
    const unsigned char *string,
    size_t ccnt
    )
{
        unsigned char *p;

        _mlock(_MB_CP_LOCK);

	for (p = (char *)string; (ccnt-- && *p); p++) {

		if (_ISLEADBYTE(*p)) {
                        if (*++p == '\0') {
                                --p;
                                break;
                        }
                }
        }

        _munlock(_MB_CP_LOCK);
	return ((size_t) ((char *)p - (char *)string));
}
コード例 #16
0
ファイル: mbsncpy.c プロジェクト: chunhualiu/OpenNT
unsigned char * __cdecl _mbsncpy(
    unsigned char *dst,
    const unsigned char *src,
    size_t cnt
    )
{

	unsigned char *start = dst;

        if (0 == __mbcodepage)
            return strncpy(dst, src, cnt);

        _mlock(_MB_CP_LOCK);

	while (cnt) {

		cnt--;
		if (_ISLEADBYTE(*src)) {
			*dst++ = *src++;
			if ((*dst++ = *src++) == '\0') {
				dst[-2] = '\0';
				break;
                        }
                }

		else
			if ((*dst++ = *src++) == '\0')
				break;

	}

	/* pad with nulls as needed */

	while (cnt--)
		*dst++ = '\0';

        _munlock(_MB_CP_LOCK);
	return start;
}
コード例 #17
0
ファイル: splitpat.c プロジェクト: axxapp/winxgui
STDMETHODIMP_(void) SplitPath (
        const _TSCHAR *path,
        _TSCHAR *drive,
        _TSCHAR *dir,
        _TSCHAR *fname,
        _TSCHAR *ext
        )
{
        register _TSCHAR *p;
        _TSCHAR *last_slash = NULL, *dot = NULL;
        unsigned len;

        /* we assume that the path argument has the following form, where any
         * or all of the components may be missing.
         *
         *  <drive><dir><fname><ext>
         *
         * and each of the components has the following expected form(s)
         *
         *  drive:
         *  0 to _MAX_DRIVE-1 characters, the last of which, if any, is a
         *  ':'
         *  dir:
         *  0 to _MAX_DIR-1 characters in the form of an absolute path
         *  (leading '/' or '\') or relative path, the last of which, if
         *  any, must be a '/' or '\'.  E.g -
         *  absolute path:
         *      \top\next\last\     ; or
         *      /top/next/last/
         *  relative path:
         *      top\next\last\  ; or
         *      top/next/last/
         *  Mixed use of '/' and '\' within a path is also tolerated
         *  fname:
         *  0 to _MAX_FNAME-1 characters not including the '.' character
         *  ext:
         *  0 to _MAX_EXT-1 characters where, if any, the first must be a
         *  '.'
         *
         */

        /* extract drive letter and :, if any */

        if ((_tcslen(path) >= (_MAX_DRIVE - 2)) && (*(path + _MAX_DRIVE - 2) == _T(':'))) {
            if (drive) {
                _tcsncpy(drive, path, _MAX_DRIVE - 1);
                *(drive + _MAX_DRIVE-1) = _T('\0');
            }
            path += _MAX_DRIVE - 1;
        }
        else if (drive) {
            *drive = _T('\0');
        }

        /* extract path string, if any.  Path now points to the first character
         * of the path, if any, or the filename or extension, if no path was
         * specified.  Scan ahead for the last occurence, if any, of a '/' or
         * '\' path separator character.  If none is found, there is no path.
         * We will also note the last '.' character found, if any, to aid in
         * handling the extension.
         */

        for (last_slash = NULL, p = (_TSCHAR *)path; *p; p++) {
#ifdef _MBCS
            if (_ISLEADBYTE (*p))
                p++;
            else {
#endif  /* _MBCS */
            if (*p == _T('/') || *p == _T('\\'))
                /* point to one beyond for later copy */
                last_slash = p + 1;
            else if (*p == _T('.'))
                dot = p;
#ifdef _MBCS
            }
#endif  /* _MBCS */
        }

        if (last_slash) {

            /* found a path - copy up through last_slash or max. characters
             * allowed, whichever is smaller
             */

            if (dir) {
                len = __min(((char *)last_slash - (char *)path) / sizeof(_TSCHAR),
                    (_MAX_DIR - 1));
                _tcsncpy(dir, path, len);
                *(dir + len) = _T('\0');
            }
            path = last_slash;
        }
        else if (dir) {

            /* no path found */

            *dir = _T('\0');
        }

        /* extract file name and extension, if any.  Path now points to the
         * first character of the file name, if any, or the extension if no
         * file name was given.  Dot points to the '.' beginning the extension,
         * if any.
         */

        if (dot && (dot >= path)) {
            /* found the marker for an extension - copy the file name up to
             * the '.'.
             */
            if (fname) {
                len = __min(((char *)dot - (char *)path) / sizeof(_TSCHAR),
                    (_MAX_FNAME - 1));
                _tcsncpy(fname, path, len);
                *(fname + len) = _T('\0');
            }
            /* now we can get the extension - remember that p still points
             * to the terminating nul character of path.
             */
            if (ext) {
                len = __min(((char *)p - (char *)dot) / sizeof(_TSCHAR),
                    (_MAX_EXT - 1));
                _tcsncpy(ext, dot, len);
                *(ext + len) = _T('\0');
            }
        }
        else {
            /* found no extension, give empty extension and copy rest of
             * string into fname.
             */
            if (fname) {
                len = __min(((char *)p - (char *)path) / sizeof(_TSCHAR),
                    (_MAX_FNAME - 1));
                _tcsncpy(fname, path, len);
                *(fname + len) = _T('\0');
            }
            if (ext) {
                *ext = _T('\0');
            }
        }
}
コード例 #18
0
ファイル: MBSNBICM.C プロジェクト: ngphloc/agmagic
int __cdecl _mbsnbicmp(
        const unsigned char *s1,
        const unsigned char *s2,
        size_t n
        )
{
        unsigned short c1, c2;

        if (n==0)
                return(0);

        if ( _ISNOTMBCP )
            return _strnicmp(s1, s2, n);

        _mlock(_MB_CP_LOCK);

        while (n--) {

                c1 = *s1++;
                if (_ISLEADBYTE(c1)) {
                        if (n==0)
                {
                    c1 = 0; /* 'naked' lead - end of string */
                    c2 = _ISLEADBYTE(*s2) ? 0 : *s2;
                    goto test;
                }
                        if (*s1 == '\0')
                                c1 = 0;
                        else {
                                c1 = ((c1<<8) | *s1++);

                    if ( ((c1 >= _MBUPPERLOW1) && (c1 <= _MBUPPERHIGH1)) )
                        c1 += _MBCASEDIFF1;

                    else if ( ((c1 >= _MBUPPERLOW2) && (c1 <= _MBUPPERHIGH2)) )
                        c1 += _MBCASEDIFF2;
                        }
                }
                else
                c1 = _mbbtolower(c1);

                c2 = *s2++;
                if (_ISLEADBYTE(c2)) {
                        if (n==0)
                {
                    c2 = 0; /* 'naked' lead - end of string */
                    goto test;
                }
                n--;
                        if (*s2 == '\0')
                                c2 = 0;
                        else {
                                c2 = ((c2<<8) | *s2++);

                    if ( ((c2 >= _MBUPPERLOW1) && (c2 <= _MBUPPERHIGH1)) )
                        c2 += _MBCASEDIFF1;

                    else if ( ((c2 >= _MBUPPERLOW2) && (c2 <= _MBUPPERHIGH2)) )
                        c2 += _MBCASEDIFF2;
                        }
                }
                else
                c2 = _mbbtolower(c2);

test:
            if (c1 != c2)
            {
                _munlock(_MB_CP_LOCK);
                        return( (c1 > c2) ? 1 : -1);
            }

            if (c1 == 0)
            {
                _munlock(_MB_CP_LOCK);
                        return(0);
            }
        }

        _munlock(_MB_CP_LOCK);
        return(0);
}
コード例 #19
0
ファイル: MBSICMP.C プロジェクト: ngphloc/agmagic
int __cdecl _mbsicmp (const unsigned char *s1, const unsigned char *s2)
{
        unsigned short c1, c2;
#if defined (_WIN32)
        int    retval;
        unsigned char szResult[4];
#endif  /* defined (_WIN32) */

        if ( _ISNOTMBCP )
            return _stricmp(s1, s2);

        _mlock(_MB_CP_LOCK);

        for (;;)
        {
            c1 = *s1++;
            if (_ISLEADBYTE(c1))
            {
                if (*s1 == '\0')
                    c1 = 0;
                else
                {
#if defined (_WIN32)
                    retval = __crtLCMapStringA(__mblcid, LCMAP_UPPERCASE,
                                               s1 - 1, 2, szResult, 2,
                                               __mbcodepage, TRUE);
                    if (retval == 1)
                        c1 = szResult[0];
                    else if (retval == 2)
                        c1 = (szResult[0] << 8) + szResult[1];
                    else
                    {
                        _munlock(_MB_CP_LOCK);
                        return _NLSCMPERROR;
                    }
                    s1++;
#else  /* defined (_WIN32) */
                    c1 = ((c1 << 8) | *s1++);
                    if (c1 >= _MBUPPERLOW1 && c1 <= _MBUPPERHIGH1)
                        c1 += _MBCASEDIFF1;
                    else if (c1 >= _MBUPPERLOW2 && c1 <= _MBUPPERHIGH2)
                        c1 += _MBCASEDIFF2;
#endif  /* defined (_WIN32) */
                }
            }
            else
                c1 = _mbbtolower(c1);

            c2 = *s2++;
            if (_ISLEADBYTE(c2))
            {
                if (*s2 == '\0')
                    c2 = 0;
                else
                {
#if defined (_WIN32)
                    retval = __crtLCMapStringA(__mblcid, LCMAP_UPPERCASE,
                                               s2 - 1, 2, szResult, 2,
                                               __mbcodepage, TRUE);
                    if (retval == 1)
                        c2 = szResult[0];
                    else if (retval == 2)
                        c2 = (szResult[0] << 8) + szResult[1];
                    else
                    {
                        _munlock(_MB_CP_LOCK);
                        return _NLSCMPERROR;
                    }
                    s2++;
#else  /* defined (_WIN32) */
                    c2 = ((c2 << 8) | *s2++);
                    if (c2 >= _MBUPPERLOW1 && c2 <= _MBUPPERHIGH1)
                        c2 += _MBCASEDIFF1;
                    else if (c2 >= _MBUPPERLOW2 && c2 <= _MBUPPERHIGH2)
                        c2 += _MBCASEDIFF2;
#endif  /* defined (_WIN32) */
                }
            }
            else
                c2 = _mbbtolower(c2);

            if (c1 != c2)
            {
                _munlock(_MB_CP_LOCK);
                return( (c1 > c2) ? 1 : -1 );
            }

            if (c1 == 0)
            {
                _munlock(_MB_CP_LOCK);
                return(0);
            }
        }
}
コード例 #20
0
ファイル: mbsicmp.c プロジェクト: chunhualiu/OpenNT
int __cdecl _mbsicmp(
    const unsigned char *s1,
    const unsigned char *s2
    )
{
	unsigned short c1, c2;

        if (0 == __mbcodepage)
            return _stricmp(s1, s2);

        _mlock(_MB_CP_LOCK);

        for (;;) {

            c1 = *s1++;
            if (_ISLEADBYTE(c1)) {
                if (*s1 == '\0')
                    c1 = 0;
                else {
                    c1 = ((c1<<8) | *s1++);

                    if ( ((c1 >= _MBUPPERLOW1) && (c1 <= _MBUPPERHIGH1)) )
                        c1 += _MBCASEDIFF1;

                    else if ( ((c1 >= _MBUPPERLOW2) && (c1 <= _MBUPPERHIGH2)) )
                        c1 += _MBCASEDIFF2;
			}
		}
		else
                c1 = _mbbtolower(c1);

            c2 = *s2++;
            if (_ISLEADBYTE(c2)) {
                if (*s2 == '\0')
                    c2 = 0;
                else {
				c2 = ((c2<<8) | *s2++);

                    if ( ((c2 >= _MBUPPERLOW1) && (c2 <= _MBUPPERHIGH1)) )
                        c2 += _MBCASEDIFF1;

                    else if ( ((c2 >= _MBUPPERLOW2) && (c2 <= _MBUPPERHIGH2)) )
                        c2 += _MBCASEDIFF2;
                }
            }
		else
                c2 = _mbbtolower(c2);

            if (c1 != c2)
            {
                _munlock(_MB_CP_LOCK);
                return( (c1 > c2) ? 1 : -1 );
            }

            if (c1 == 0)
            {
                _munlock(_MB_CP_LOCK);
                return(0);
            }

        }
}