added qse_mbsxchr()/qse_wcsxchar() and related functions
This commit is contained in:
parent
0b552210e8
commit
2470066357
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: str.h 415 2011-03-25 16:02:04Z hyunghwan.chung $
|
||||
* $Id: str.h 416 2011-03-27 05:04:24Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -723,34 +723,58 @@ qse_wchar_t* qse_wcschr (
|
||||
qse_wcint_t c
|
||||
);
|
||||
|
||||
qse_mchar_t* qse_mbsxchr (
|
||||
const qse_mchar_t* str,
|
||||
qse_size_t len,
|
||||
qse_mcint_t c
|
||||
);
|
||||
|
||||
qse_wchar_t* qse_wcsxchr (
|
||||
const qse_wchar_t* str,
|
||||
qse_size_t len,
|
||||
qse_wcint_t c
|
||||
);
|
||||
|
||||
qse_wchar_t* qse_wcsrchr (
|
||||
const qse_wchar_t* str,
|
||||
qse_wcint_t c
|
||||
);
|
||||
|
||||
qse_mchar_t* qse_mbsrchr (
|
||||
const qse_mchar_t* str,
|
||||
qse_mcint_t c
|
||||
);
|
||||
|
||||
qse_mchar_t* qse_mbsxrchr (
|
||||
const qse_mchar_t* str,
|
||||
qse_size_t len,
|
||||
qse_mcint_t c
|
||||
);
|
||||
|
||||
qse_wchar_t* qse_wcsxrchr (
|
||||
const qse_wchar_t* str,
|
||||
qse_size_t len,
|
||||
qse_wcint_t c
|
||||
);
|
||||
|
||||
#ifdef QSE_CHAR_IS_MCHAR
|
||||
# define qse_strchr(str,c) qse_mbschr(str,c)
|
||||
# define qse_strchr(str,c) qse_mbschr(str,c)
|
||||
# define qse_strxchr(str,len,c) qse_mbsxchr(str,len,c)
|
||||
# define qse_strrchr(str,c) qse_mbsrchr(str,c)
|
||||
# define qse_strxrchr(str,len,c) qse_mbsxrchr(str,len,c)
|
||||
#else
|
||||
# define qse_strchr(str,c) qse_wcschr(str,c)
|
||||
# define qse_strchr(str,c) qse_wcschr(str,c)
|
||||
# define qse_strxchr(str,len,c) qse_wcsxchr(str,len,c)
|
||||
# define qse_strrchr(str,c) qse_wcsrchr(str,c)
|
||||
# define qse_strxrrchr(str,len,c) qse_wcsxrchr(str,len,c)
|
||||
#endif
|
||||
|
||||
qse_char_t* qse_strxchr (
|
||||
const qse_char_t* str,
|
||||
qse_size_t len,
|
||||
qse_cint_t c
|
||||
);
|
||||
|
||||
qse_char_t* qse_strrchr (
|
||||
const qse_char_t* str,
|
||||
qse_cint_t c
|
||||
);
|
||||
|
||||
qse_char_t* qse_strxrchr (
|
||||
const qse_char_t* str,
|
||||
qse_size_t len,
|
||||
qse_cint_t c
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_strxword() function finds a whole word in a string.
|
||||
*/
|
||||
const qse_char_t* qse_strxword (
|
||||
const qse_char_t* str,
|
||||
const qse_char_t* str,
|
||||
qse_size_t len,
|
||||
const qse_char_t* word
|
||||
);
|
||||
@ -760,7 +784,7 @@ const qse_char_t* qse_strxword (
|
||||
* case-insensitively.
|
||||
*/
|
||||
const qse_char_t* qse_strxcaseword (
|
||||
const qse_char_t* str,
|
||||
const qse_char_t* str,
|
||||
qse_size_t len,
|
||||
const qse_char_t* word
|
||||
);
|
||||
|
@ -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_cmp.c str_cpy.c str_dyn.c str_fcpy.c \
|
||||
str_bas.c str_chr.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,11 +73,12 @@ 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_cmp.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
|
||||
rex.lo str_bas.lo str_chr.lo str_cnv.lo str_cmp.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
|
||||
libqsecmn_la_OBJECTS = $(am_libqsecmn_la_OBJECTS)
|
||||
libqsecmn_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
@ -265,7 +266,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_cmp.c str_cpy.c str_dyn.c str_fcpy.c \
|
||||
str_bas.c str_chr.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 \
|
||||
@ -385,6 +386,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_chr.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@
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: str_bas.c 413 2011-03-25 04:36:43Z hyunghwan.chung $
|
||||
* $Id: str_bas.c 416 2011-03-27 05:04:24Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -401,65 +401,6 @@ qse_char_t* qse_strxnrstr (
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
qse_mchar_t* qse_mbschr (const qse_mchar_t* str, qse_mcint_t c)
|
||||
{
|
||||
while (*str != QSE_MT('\0'))
|
||||
{
|
||||
if (*str == c) return (qse_mchar_t*)str;
|
||||
str++;
|
||||
}
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
qse_wchar_t* qse_wcschr (const qse_wchar_t* str, qse_wcint_t c)
|
||||
{
|
||||
while (*str != QSE_WT('\0'))
|
||||
{
|
||||
if (*str == c) return (qse_wchar_t*)str;
|
||||
str++;
|
||||
}
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
qse_char_t* qse_strxchr (const qse_char_t* str, qse_size_t len, qse_cint_t c)
|
||||
{
|
||||
const qse_char_t* end = str + len;
|
||||
|
||||
while (str < end)
|
||||
{
|
||||
if (*str == c) return (qse_char_t*)str;
|
||||
str++;
|
||||
}
|
||||
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
qse_char_t* qse_strrchr (const qse_char_t* str, qse_cint_t c)
|
||||
{
|
||||
const qse_char_t* end = str;
|
||||
|
||||
while (*end != QSE_T('\0')) end++;
|
||||
|
||||
while (end > str)
|
||||
{
|
||||
if (*--end == c) return (qse_char_t*)end;
|
||||
}
|
||||
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
qse_char_t* qse_strxrchr (const qse_char_t* str, qse_size_t len, qse_cint_t c)
|
||||
{
|
||||
const qse_char_t* end = str + len;
|
||||
|
||||
while (end > str)
|
||||
{
|
||||
if (*--end == c) return (qse_char_t*)end;
|
||||
}
|
||||
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
const qse_char_t* qse_strxword (
|
||||
const qse_char_t* str, qse_size_t len, const qse_char_t* word)
|
||||
{
|
||||
|
121
qse/lib/cmn/str_chr.c
Normal file
121
qse/lib/cmn/str_chr.c
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* $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>
|
||||
|
||||
qse_mchar_t* qse_mbschr (const qse_mchar_t* str, qse_mcint_t c)
|
||||
{
|
||||
while (*str != QSE_MT('\0'))
|
||||
{
|
||||
if (*str == c) return (qse_mchar_t*)str;
|
||||
str++;
|
||||
}
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
qse_mchar_t* qse_mbsxchr (const qse_mchar_t* str, qse_size_t len, qse_mcint_t c)
|
||||
{
|
||||
const qse_mchar_t* end = str + len;
|
||||
|
||||
while (str < end)
|
||||
{
|
||||
if (*str == c) return (qse_mchar_t*)str;
|
||||
str++;
|
||||
}
|
||||
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
qse_mchar_t* qse_mbsrchr (const qse_mchar_t* str, qse_mcint_t c)
|
||||
{
|
||||
const qse_mchar_t* end = str;
|
||||
|
||||
while (*end != QSE_MT('\0')) end++;
|
||||
|
||||
while (end > str)
|
||||
{
|
||||
if (*--end == c) return (qse_mchar_t*)end;
|
||||
}
|
||||
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
qse_mchar_t* qse_mbsxrchr (const qse_mchar_t* str, qse_size_t len, qse_mcint_t c)
|
||||
{
|
||||
const qse_mchar_t* end = str + len;
|
||||
|
||||
while (end > str)
|
||||
{
|
||||
if (*--end == c) return (qse_mchar_t*)end;
|
||||
}
|
||||
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
qse_wchar_t* qse_wcschr (const qse_wchar_t* str, qse_wcint_t c)
|
||||
{
|
||||
while (*str != QSE_WT('\0'))
|
||||
{
|
||||
if (*str == c) return (qse_wchar_t*)str;
|
||||
str++;
|
||||
}
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
qse_wchar_t* qse_wcsxchr (const qse_wchar_t* str, qse_size_t len, qse_wcint_t c)
|
||||
{
|
||||
const qse_wchar_t* end = str + len;
|
||||
|
||||
while (str < end)
|
||||
{
|
||||
if (*str == c) return (qse_wchar_t*)str;
|
||||
str++;
|
||||
}
|
||||
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
qse_wchar_t* qse_wcsrchr (const qse_wchar_t* str, qse_wcint_t c)
|
||||
{
|
||||
const qse_wchar_t* end = str;
|
||||
|
||||
while (*end != QSE_MT('\0')) end++;
|
||||
|
||||
while (end > str)
|
||||
{
|
||||
if (*--end == c) return (qse_wchar_t*)end;
|
||||
}
|
||||
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
qse_wchar_t* qse_wcsxrchr (const qse_wchar_t* str, qse_size_t len, qse_wcint_t c)
|
||||
{
|
||||
const qse_wchar_t* end = str + len;
|
||||
|
||||
while (end > str)
|
||||
{
|
||||
if (*--end == c) return (qse_wchar_t*)end;
|
||||
}
|
||||
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user