added qse_mbscmp()/qse_wcscmp() and related functions while doing similar things for character class handling
This commit is contained in:
@ -9,7 +9,7 @@ lib_LTLIBRARIES = libqsecmn.la
|
||||
libqsecmn_la_SOURCES = \
|
||||
syscall.h mem.h \
|
||||
mem.c xma.c fma.c chr.c chr_cnv.c rex.c \
|
||||
str_bas.c str_cnv.c str_cpy.c str_dyn.c str_fcpy.c \
|
||||
str_bas.c str_cnv.c str_cmp.c str_cpy.c str_dyn.c str_fcpy.c \
|
||||
str_pbrk.c str_put.c str_spn.c str_utl.c \
|
||||
lda.c oht.c htb.c rbt.c sll.c gdl.c dll.c opt.c \
|
||||
tio.c tio_get.c tio_put.c \
|
||||
|
@ -73,8 +73,8 @@ am__installdirs = "$(DESTDIR)$(libdir)"
|
||||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
libqsecmn_la_DEPENDENCIES =
|
||||
am_libqsecmn_la_OBJECTS = mem.lo xma.lo fma.lo chr.lo chr_cnv.lo \
|
||||
rex.lo str_bas.lo str_cnv.lo str_cpy.lo str_dyn.lo str_fcpy.lo \
|
||||
str_pbrk.lo str_put.lo str_spn.lo str_utl.lo lda.lo oht.lo \
|
||||
rex.lo str_bas.lo str_cmp.lo str_cnv.lo str_cpy.lo str_dyn.lo
|
||||
str_fcpy.lo str_pbrk.lo str_put.lo str_spn.lo str_utl.lo lda.lo oht.lo \
|
||||
htb.lo rbt.lo sll.lo gdl.lo dll.lo opt.lo tio.lo tio_get.lo \
|
||||
tio_put.lo fio.lo pio.lo sio.lo alg_search.lo alg_sort.lo \
|
||||
time.lo misc.lo assert.lo main.lo stdio.lo
|
||||
@ -265,7 +265,7 @@ lib_LTLIBRARIES = libqsecmn.la $(am__append_1)
|
||||
libqsecmn_la_SOURCES = \
|
||||
syscall.h mem.h \
|
||||
mem.c xma.c fma.c chr.c chr_cnv.c rex.c \
|
||||
str_bas.c str_cnv.c str_cpy.c str_dyn.c str_fcpy.c \
|
||||
str_bas.c str_cmp.c str_cnv.c str_cpy.c str_dyn.c str_fcpy.c \
|
||||
str_pbrk.c str_put.c str_spn.c str_utl.c \
|
||||
lda.c oht.c htb.c rbt.c sll.c gdl.c dll.c opt.c \
|
||||
tio.c tio_get.c tio_put.c \
|
||||
@ -385,6 +385,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sll.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdio.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_bas.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_cmp.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_cnv.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_cpy.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_dyn.Plo@am__quote@
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: chr.c 287 2009-09-15 10:01:02Z hyunghwan.chung $
|
||||
* $Id: chr.c 413 2011-03-25 04:36:43Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -20,47 +20,46 @@
|
||||
|
||||
#include <qse/cmn/chr.h>
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
|
||||
#include <ctype.h>
|
||||
#include <wctype.h>
|
||||
|
||||
static qse_bool_t is_upper (qse_cint_t c) { return isupper(c); }
|
||||
static qse_bool_t is_lower (qse_cint_t c) { return islower(c); }
|
||||
static qse_bool_t is_alpha (qse_cint_t c) { return isalpha(c); }
|
||||
static qse_bool_t is_digit (qse_cint_t c) { return isdigit(c); }
|
||||
static qse_bool_t is_xdigit (qse_cint_t c) { return isxdigit(c); }
|
||||
static qse_bool_t is_alnum (qse_cint_t c) { return isalnum(c); }
|
||||
static qse_bool_t is_space (qse_cint_t c) { return isspace(c); }
|
||||
static qse_bool_t is_print (qse_cint_t c) { return isprint(c); }
|
||||
static qse_bool_t is_graph (qse_cint_t c) { return isgraph(c); }
|
||||
static qse_bool_t is_cntrl (qse_cint_t c) { return iscntrl(c); }
|
||||
static qse_bool_t is_punct (qse_cint_t c) { return ispunct(c); }
|
||||
static qse_bool_t is_mupper (qse_mcint_t c) { return isupper(c); }
|
||||
static qse_bool_t is_mlower (qse_mcint_t c) { return islower(c); }
|
||||
static qse_bool_t is_malpha (qse_mcint_t c) { return isalpha(c); }
|
||||
static qse_bool_t is_mdigit (qse_mcint_t c) { return isdigit(c); }
|
||||
static qse_bool_t is_mxdigit (qse_mcint_t c) { return isxdigit(c); }
|
||||
static qse_bool_t is_malnum (qse_mcint_t c) { return isalnum(c); }
|
||||
static qse_bool_t is_mspace (qse_mcint_t c) { return isspace(c); }
|
||||
static qse_bool_t is_mprint (qse_mcint_t c) { return isprint(c); }
|
||||
static qse_bool_t is_mgraph (qse_mcint_t c) { return isgraph(c); }
|
||||
static qse_bool_t is_mcntrl (qse_mcint_t c) { return iscntrl(c); }
|
||||
static qse_bool_t is_mpunct (qse_mcint_t c) { return ispunct(c); }
|
||||
|
||||
qse_bool_t qse_ccls_is (qse_cint_t c, qse_ccls_id_t type)
|
||||
qse_bool_t qse_mccls_is (qse_mcint_t c, qse_mccls_id_t type)
|
||||
{
|
||||
/* TODO: use GetStringTypeW/A for WIN32 to implement these */
|
||||
|
||||
static qse_bool_t (*f[]) (qse_cint_t) =
|
||||
static qse_bool_t (*f[]) (qse_mcint_t) =
|
||||
{
|
||||
is_upper,
|
||||
is_lower,
|
||||
is_alpha,
|
||||
is_digit,
|
||||
is_xdigit,
|
||||
is_alnum,
|
||||
is_space,
|
||||
is_print,
|
||||
is_graph,
|
||||
is_cntrl,
|
||||
is_punct
|
||||
is_mupper,
|
||||
is_mlower,
|
||||
is_malpha,
|
||||
is_mdigit,
|
||||
is_mxdigit,
|
||||
is_malnum,
|
||||
is_mspace,
|
||||
is_mprint,
|
||||
is_mgraph,
|
||||
is_mcntrl,
|
||||
is_mpunct
|
||||
};
|
||||
|
||||
QSE_ASSERTX (type >= QSE_CCLS_UPPER && type <= QSE_CCLS_PUNCT,
|
||||
"The character type should be one of qse_ccls_id_t values");
|
||||
"The character type should be one of qse_mccls_id_t values");
|
||||
return f[type] (c);
|
||||
}
|
||||
|
||||
qse_cint_t qse_ccls_to (qse_cint_t c, qse_ccls_id_t type)
|
||||
qse_mcint_t qse_mccls_to (qse_mcint_t c, qse_mccls_id_t type)
|
||||
{
|
||||
QSE_ASSERTX (type >= QSE_CCLS_UPPER && type <= QSE_CCLS_LOWER,
|
||||
"The character type should be one of QSE_CCLS_UPPER and QSE_CCLS_LOWER");
|
||||
@ -70,11 +69,7 @@ qse_cint_t qse_ccls_to (qse_cint_t c, qse_ccls_id_t type)
|
||||
return c;
|
||||
}
|
||||
|
||||
#elif defined(QSE_CHAR_IS_WCHAR)
|
||||
|
||||
#include <wctype.h>
|
||||
|
||||
qse_bool_t qse_ccls_is (qse_cint_t c, qse_ccls_id_t type)
|
||||
qse_bool_t qse_wccls_is (qse_wcint_t c, qse_wccls_id_t type)
|
||||
{
|
||||
static const char* name[] =
|
||||
{
|
||||
@ -107,13 +102,13 @@ qse_bool_t qse_ccls_is (qse_cint_t c, qse_ccls_id_t type)
|
||||
};
|
||||
|
||||
QSE_ASSERTX (type >= QSE_CCLS_UPPER && type <= QSE_CCLS_PUNCT,
|
||||
"The character type should be one of qse_ccls_id_t values");
|
||||
"The character type should be one of qse_wccls_id_t values");
|
||||
|
||||
if (desc[type] == (wctype_t)0) desc[type] = wctype(name[type]);
|
||||
return iswctype (c, desc[type]);
|
||||
}
|
||||
|
||||
qse_cint_t qse_ccls_to (qse_cint_t c, qse_ccls_id_t type)
|
||||
qse_wcint_t qse_wccls_to (qse_wcint_t c, qse_wccls_id_t type)
|
||||
{
|
||||
#ifdef HAVE_WCTRANS
|
||||
static const char* name[] =
|
||||
@ -133,7 +128,6 @@ qse_cint_t qse_ccls_to (qse_cint_t c, qse_ccls_id_t type)
|
||||
|
||||
if (desc[type] == (wctrans_t)0) desc[type] = wctrans(name[type]);
|
||||
return towctrans (c, desc[type]);
|
||||
|
||||
#else
|
||||
QSE_ASSERTX (type >= QSE_CCLS_UPPER && type <= QSE_CCLS_LOWER,
|
||||
"The type should be one of QSE_CCLS_UPPER and QSE_CCLS_LOWER");
|
||||
@ -141,8 +135,3 @@ qse_cint_t qse_ccls_to (qse_cint_t c, qse_ccls_id_t type)
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
#error unsupported character type
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: fio.c 404 2011-03-20 14:16:54Z hyunghwan.chung $
|
||||
* $Id: fio.c 413 2011-03-25 04:36:43Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -156,7 +156,7 @@ qse_fio_t* qse_fio_init (
|
||||
}
|
||||
if (handle == INVALID_HANDLE_VALUE) return QSE_NULL;
|
||||
|
||||
/* some special check
|
||||
/* some special check */
|
||||
if (GetFileType(handle) == FILE_TYPE_UNKNOWN)
|
||||
{
|
||||
CloseHandle (handle);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: sio.c 402 2011-03-18 15:07:21Z hyunghwan.chung $
|
||||
* $Id: sio.c 413 2011-03-25 04:36:43Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -37,16 +37,17 @@ static qse_sio_t __sio_in =
|
||||
|
||||
/* fio */
|
||||
{
|
||||
QSE_NULL,
|
||||
0,
|
||||
QSE_NULL, /* mmgr */
|
||||
0, /* errnum */
|
||||
#if defined(_WIN32)
|
||||
(HANDLE)STD_INPUT_HANDLE,
|
||||
(HANDLE)STD_INPUT_HANDLE, /* handle */
|
||||
#elif defined(__OS2__)
|
||||
(HFILE)0,
|
||||
(HFILE)0, /* handle */
|
||||
#else
|
||||
0,
|
||||
0, /* handle */
|
||||
#endif
|
||||
QSE_NULL
|
||||
0, /* flags */
|
||||
QSE_NULL /* tio */
|
||||
},
|
||||
|
||||
/* tio */
|
||||
@ -84,6 +85,7 @@ static qse_sio_t __sio_out =
|
||||
#else
|
||||
1,
|
||||
#endif
|
||||
0,
|
||||
QSE_NULL
|
||||
},
|
||||
|
||||
@ -122,6 +124,7 @@ static qse_sio_t __sio_err =
|
||||
#else
|
||||
2,
|
||||
#endif
|
||||
0,
|
||||
QSE_NULL
|
||||
},
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: str_bas.c 411 2011-03-24 14:20:55Z hyunghwan.chung $
|
||||
* $Id: str_bas.c 413 2011-03-25 04:36:43Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -126,7 +126,6 @@ qse_size_t qse_strxcat (qse_char_t* buf, qse_size_t bsz, const qse_char_t* str)
|
||||
return p - buf;
|
||||
}
|
||||
|
||||
|
||||
qse_size_t qse_strxncat (
|
||||
qse_char_t* buf, qse_size_t bsz, const qse_char_t* str, qse_size_t len)
|
||||
{
|
||||
@ -152,101 +151,6 @@ qse_size_t qse_strxncat (
|
||||
return p - buf;
|
||||
}
|
||||
|
||||
int qse_strcmp (const qse_char_t* s1, const qse_char_t* s2)
|
||||
{
|
||||
while (*s1 == *s2)
|
||||
{
|
||||
if (*s1 == QSE_T('\0')) return 0;
|
||||
s1++, s2++;
|
||||
}
|
||||
|
||||
return (*s1 > *s2)? 1: -1;
|
||||
}
|
||||
|
||||
int qse_strxcmp (const qse_char_t* s1, qse_size_t len, const qse_char_t* s2)
|
||||
{
|
||||
const qse_char_t* end = s1 + len;
|
||||
while (s1 < end && *s2 != QSE_T('\0') && *s1 == *s2) s1++, s2++;
|
||||
if (s1 == end && *s2 == QSE_T('\0')) return 0;
|
||||
if (*s1 == *s2) return (s1 < end)? 1: -1;
|
||||
return (*s1 > *s2)? 1: -1;
|
||||
}
|
||||
|
||||
int qse_strxncmp (
|
||||
const qse_char_t* s1, qse_size_t len1,
|
||||
const qse_char_t* s2, qse_size_t len2)
|
||||
{
|
||||
qse_char_t c1, c2;
|
||||
const qse_char_t* end1 = s1 + len1;
|
||||
const qse_char_t* end2 = s2 + len2;
|
||||
|
||||
while (s1 < end1)
|
||||
{
|
||||
c1 = *s1;
|
||||
if (s2 < end2)
|
||||
{
|
||||
c2 = *s2;
|
||||
if (c1 > c2) return 1;
|
||||
if (c1 < c2) return -1;
|
||||
}
|
||||
else return 1;
|
||||
s1++; s2++;
|
||||
}
|
||||
|
||||
return (s2 < end2)? -1: 0;
|
||||
}
|
||||
|
||||
int qse_strcasecmp (const qse_char_t* s1, const qse_char_t* s2)
|
||||
{
|
||||
while (QSE_TOUPPER(*s1) == QSE_TOUPPER(*s2))
|
||||
{
|
||||
if (*s1 == QSE_C('\0')) return 0;
|
||||
s1++, s2++;
|
||||
}
|
||||
|
||||
return (QSE_TOUPPER(*s1) > QSE_TOUPPER(*s2))? 1: -1;
|
||||
}
|
||||
|
||||
int qse_strxcasecmp (const qse_char_t* s1, qse_size_t len, const qse_char_t* s2)
|
||||
{
|
||||
qse_char_t c1, c2;
|
||||
const qse_char_t* end = s1 + len;
|
||||
|
||||
c1 = QSE_TOUPPER(*s1); c2 = QSE_TOUPPER(*s2);
|
||||
while (s1 < end && c2 != QSE_T('\0') && c1 == c2)
|
||||
{
|
||||
s1++; s2++;
|
||||
c1 = QSE_TOUPPER(*s1); c2 = QSE_TOUPPER(*s2);
|
||||
}
|
||||
if (s1 == end && c2 == QSE_T('\0')) return 0;
|
||||
if (c1 == c2) return (s1 < end)? 1: -1;
|
||||
return (c1 > c2)? 1: -1;
|
||||
}
|
||||
|
||||
int qse_strxncasecmp (
|
||||
const qse_char_t* s1, qse_size_t len1,
|
||||
const qse_char_t* s2, qse_size_t len2)
|
||||
{
|
||||
qse_char_t c1, c2;
|
||||
const qse_char_t* end1 = s1 + len1;
|
||||
const qse_char_t* end2 = s2 + len2;
|
||||
|
||||
while (s1 < end1)
|
||||
{
|
||||
c1 = QSE_TOUPPER (*s1);
|
||||
if (s2 < end2)
|
||||
{
|
||||
c2 = QSE_TOUPPER (*s2);
|
||||
if (c1 > c2) return 1;
|
||||
if (c1 < c2) return -1;
|
||||
}
|
||||
else return 1;
|
||||
s1++; s2++;
|
||||
}
|
||||
|
||||
return (s2 < end2)? -1: 0;
|
||||
}
|
||||
|
||||
qse_char_t* qse_strdup (const qse_char_t* str, qse_mmgr_t* mmgr)
|
||||
{
|
||||
qse_char_t* tmp;
|
||||
|
212
qse/lib/cmn/str_cmp.c
Normal file
212
qse/lib/cmn/str_cmp.c
Normal file
@ -0,0 +1,212 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
|
||||
QSE is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
QSE is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/cmn/chr.h>
|
||||
|
||||
int qse_mbscmp (const qse_mchar_t* s1, const qse_mchar_t* s2)
|
||||
{
|
||||
while (*s1 == *s2)
|
||||
{
|
||||
if (*s1 == QSE_MT('\0')) return 0;
|
||||
s1++, s2++;
|
||||
}
|
||||
|
||||
return (*s1 > *s2)? 1: -1;
|
||||
}
|
||||
|
||||
int qse_mbsxcmp (const qse_mchar_t* s1, qse_size_t ln, const qse_mchar_t* s2)
|
||||
{
|
||||
const qse_mchar_t* end = s1 + ln;
|
||||
while (s1 < end && *s2 != QSE_MT('\0') && *s1 == *s2) s1++, s2++;
|
||||
if (s1 == end && *s2 == QSE_MT('\0')) return 0;
|
||||
if (*s1 == *s2) return (s1 < end)? 1: -1;
|
||||
return (*s1 > *s2)? 1: -1;
|
||||
}
|
||||
|
||||
int qse_mbsxncmp (
|
||||
const qse_mchar_t* s1, qse_size_t ln1,
|
||||
const qse_mchar_t* s2, qse_size_t ln2)
|
||||
{
|
||||
qse_mchar_t c1, c2;
|
||||
const qse_mchar_t* end1 = s1 + ln1;
|
||||
const qse_mchar_t* end2 = s2 + ln2;
|
||||
|
||||
while (s1 < end1)
|
||||
{
|
||||
c1 = *s1;
|
||||
if (s2 < end2)
|
||||
{
|
||||
c2 = *s2;
|
||||
if (c1 > c2) return 1;
|
||||
if (c1 < c2) return -1;
|
||||
}
|
||||
else return 1;
|
||||
s1++; s2++;
|
||||
}
|
||||
|
||||
return (s2 < end2)? -1: 0;
|
||||
}
|
||||
|
||||
int qse_mbscasecmp (const qse_mchar_t* s1, const qse_mchar_t* s2)
|
||||
{
|
||||
while (QSE_TOMUPPER(*s1) == QSE_TOMUPPER(*s2))
|
||||
{
|
||||
if (*s1 == QSE_C('\0')) return 0;
|
||||
s1++, s2++;
|
||||
}
|
||||
|
||||
return (QSE_TOMUPPER(*s1) > QSE_TOMUPPER(*s2))? 1: -1;
|
||||
}
|
||||
|
||||
int qse_mbsxcasecmp (const qse_mchar_t* s1, qse_size_t ln, const qse_mchar_t* s2)
|
||||
{
|
||||
qse_mchar_t c1, c2;
|
||||
const qse_mchar_t* end = s1 + ln;
|
||||
|
||||
c1 = QSE_TOMUPPER(*s1); c2 = QSE_TOMUPPER(*s2);
|
||||
while (s1 < end && c2 != QSE_MT('\0') && c1 == c2)
|
||||
{
|
||||
s1++; s2++;
|
||||
c1 = QSE_TOMUPPER(*s1); c2 = QSE_TOMUPPER(*s2);
|
||||
}
|
||||
if (s1 == end && c2 == QSE_MT('\0')) return 0;
|
||||
if (c1 == c2) return (s1 < end)? 1: -1;
|
||||
return (c1 > c2)? 1: -1;
|
||||
}
|
||||
|
||||
int qse_mbsxncasecmp (
|
||||
const qse_mchar_t* s1, qse_size_t ln1,
|
||||
const qse_mchar_t* s2, qse_size_t ln2)
|
||||
{
|
||||
qse_mchar_t c1, c2;
|
||||
const qse_mchar_t* end1 = s1 + ln1;
|
||||
const qse_mchar_t* end2 = s2 + ln2;
|
||||
|
||||
while (s1 < end1)
|
||||
{
|
||||
c1 = QSE_TOMUPPER (*s1);
|
||||
if (s2 < end2)
|
||||
{
|
||||
c2 = QSE_TOMUPPER (*s2);
|
||||
if (c1 > c2) return 1;
|
||||
if (c1 < c2) return -1;
|
||||
}
|
||||
else return 1;
|
||||
s1++; s2++;
|
||||
}
|
||||
|
||||
return (s2 < end2)? -1: 0;
|
||||
}
|
||||
|
||||
int qse_wcscmp (const qse_wchar_t* s1, const qse_wchar_t* s2)
|
||||
{
|
||||
while (*s1 == *s2)
|
||||
{
|
||||
if (*s1 == QSE_WT('\0')) return 0;
|
||||
s1++, s2++;
|
||||
}
|
||||
|
||||
return (*s1 > *s2)? 1: -1;
|
||||
}
|
||||
|
||||
int qse_wcsxcmp (const qse_wchar_t* s1, qse_size_t ln, const qse_wchar_t* s2)
|
||||
{
|
||||
const qse_wchar_t* end = s1 + ln;
|
||||
while (s1 < end && *s2 != QSE_WT('\0') && *s1 == *s2) s1++, s2++;
|
||||
if (s1 == end && *s2 == QSE_WT('\0')) return 0;
|
||||
if (*s1 == *s2) return (s1 < end)? 1: -1;
|
||||
return (*s1 > *s2)? 1: -1;
|
||||
}
|
||||
|
||||
int qse_wcsxncmp (
|
||||
const qse_wchar_t* s1, qse_size_t ln1,
|
||||
const qse_wchar_t* s2, qse_size_t ln2)
|
||||
{
|
||||
qse_wchar_t c1, c2;
|
||||
const qse_wchar_t* end1 = s1 + ln1;
|
||||
const qse_wchar_t* end2 = s2 + ln2;
|
||||
|
||||
while (s1 < end1)
|
||||
{
|
||||
c1 = *s1;
|
||||
if (s2 < end2)
|
||||
{
|
||||
c2 = *s2;
|
||||
if (c1 > c2) return 1;
|
||||
if (c1 < c2) return -1;
|
||||
}
|
||||
else return 1;
|
||||
s1++; s2++;
|
||||
}
|
||||
|
||||
return (s2 < end2)? -1: 0;
|
||||
}
|
||||
|
||||
int qse_wcscasecmp (const qse_wchar_t* s1, const qse_wchar_t* s2)
|
||||
{
|
||||
while (QSE_TOWUPPER(*s1) == QSE_TOWUPPER(*s2))
|
||||
{
|
||||
if (*s1 == QSE_C('\0')) return 0;
|
||||
s1++, s2++;
|
||||
}
|
||||
|
||||
return (QSE_TOWUPPER(*s1) > QSE_TOWUPPER(*s2))? 1: -1;
|
||||
}
|
||||
|
||||
int qse_wcsxcasecmp (const qse_wchar_t* s1, qse_size_t ln, const qse_wchar_t* s2)
|
||||
{
|
||||
qse_wchar_t c1, c2;
|
||||
const qse_wchar_t* end = s1 + ln;
|
||||
|
||||
c1 = QSE_TOWUPPER(*s1); c2 = QSE_TOWUPPER(*s2);
|
||||
while (s1 < end && c2 != QSE_WT('\0') && c1 == c2)
|
||||
{
|
||||
s1++; s2++;
|
||||
c1 = QSE_TOWUPPER(*s1); c2 = QSE_TOWUPPER(*s2);
|
||||
}
|
||||
if (s1 == end && c2 == QSE_WT('\0')) return 0;
|
||||
if (c1 == c2) return (s1 < end)? 1: -1;
|
||||
return (c1 > c2)? 1: -1;
|
||||
}
|
||||
|
||||
int qse_wcsxncasecmp (
|
||||
const qse_wchar_t* s1, qse_size_t ln1,
|
||||
const qse_wchar_t* s2, qse_size_t ln2)
|
||||
{
|
||||
qse_wchar_t c1, c2;
|
||||
const qse_wchar_t* end1 = s1 + ln1;
|
||||
const qse_wchar_t* end2 = s2 + ln2;
|
||||
|
||||
while (s1 < end1)
|
||||
{
|
||||
c1 = QSE_TOWUPPER (*s1);
|
||||
if (s2 < end2)
|
||||
{
|
||||
c2 = QSE_TOWUPPER (*s2);
|
||||
if (c1 > c2) return 1;
|
||||
if (c1 < c2) return -1;
|
||||
}
|
||||
else return 1;
|
||||
s1++; s2++;
|
||||
}
|
||||
|
||||
return (s2 < end2)? -1: 0;
|
||||
}
|
Reference in New Issue
Block a user