added qse_mbsbeg()/qse_wcsbeg()/qse_mbsend()/qse_wcsend() and related functions

This commit is contained in:
2011-04-12 08:15:30 +00:00
parent 10901ba0df
commit 610059c023
10 changed files with 565 additions and 328 deletions

View File

@ -9,9 +9,10 @@ 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_cat.c str_chr.c str_cnv.c str_cmp.c str_cpy.c str_dup.c \
str_dyn.c str_fcpy.c str_len.c str_pac.c str_pbrk.c str_put.c \
str_spl.c str_spn.c str_str.c str_subst.c str_trm.c str_word.c \
str_beg.c str_cat.c str_chr.c str_cnv.c str_cmp.c str_cpy.c \
str_dup.c str_dyn.c str_end.c str_fcpy.c str_len.c str_pac.c \
str_pbrk.c str_put.c str_spl.c str_spn.c str_str.c str_subst.c \
str_trm.c str_word.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 \
fio.c pio.c sio.c \

View File

@ -73,10 +73,10 @@ 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_cat.lo str_chr.lo str_cnv.lo str_cmp.lo \
str_cpy.lo str_dup.lo str_dyn.lo str_fcpy.lo str_len.lo str_pac.lo \
str_pbrk.lo str_put.lo str_spl.lo str_spn.lo str_str.lo str_subst.lo \
str_trm.lo str_word.lo lda.lo oht.lo htb.lo rbt.lo sll.lo \
rex.lo str_beg.lo str_cat.lo str_chr.lo str_cnv.lo str_cmp.lo \
str_cpy.lo str_dup.lo str_dyn.lo str_end.lo str_fcpy.lo str_len.lo \
str_pac.lo str_pbrk.lo str_put.lo str_spl.lo str_spn.lo str_str.lo \
str_subst.lo str_trm.lo str_word.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
@ -267,9 +267,10 @@ 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_cat.c str_chr.c str_cnv.c str_cmp.c str_cpy.c str_dup.c \
str_dyn.c str_fcpy.c str_len.c str_pac.c str_pbrk.c str_put.c \
str_spl.c str_spn.c str_str.c str_subst.c str_trm.c str_word.c \
str_beg.c str_cat.c str_chr.c str_cnv.c str_cmp.c str_cpy.c \
str_dup.c str_dyn.c str_end.c str_fcpy.c str_len.c str_pac.c \
str_pbrk.c str_put.c str_spl.c str_spn.c str_str.c str_subst.c \
str_trm.c str_word.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 \
fio.c pio.c sio.c \
@ -387,7 +388,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sio.Plo@am__quote@
@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_beg.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_cat.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@
@ -395,6 +396,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_cpy.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_dup.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_dyn.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_end.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_fcpy.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_len.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_pac.Plo@am__quote@

View File

@ -1,124 +0,0 @@
/*
* $Id: str_bas.c 425 2011-04-03 14:57:23Z hyunghwan.chung $
*
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>
#include "mem.h"
qse_char_t* qse_strbeg (const qse_char_t* str, const qse_char_t* sub)
{
while (*sub != QSE_T('\0'))
{
if (*str != *sub) return QSE_NULL;
str++; sub++;
}
/* returns the pointer to the next character of the match */
return (qse_char_t*)str;
}
qse_char_t* qse_strxbeg (
const qse_char_t* str, qse_size_t len, const qse_char_t* sub)
{
const qse_char_t* end = str + len;
while (*sub != QSE_T('\0'))
{
if (str >= end || *str != *sub) return QSE_NULL;
str++; sub++;
}
/* returns the pointer to the next character of the match */
return (qse_char_t*)str;
}
qse_char_t* qse_strnbeg (
const qse_char_t* str, const qse_char_t* sub, qse_size_t len)
{
const qse_char_t* end = sub + len;
while (sub < end)
{
if (*str == QSE_T('\0') || *str != *sub) return QSE_NULL;
str++; sub++;
}
/* returns the pointer to the next character of the match */
return (qse_char_t*)str;
}
qse_char_t* qse_strxnbeg (
const qse_char_t* str, qse_size_t len1,
const qse_char_t* sub, qse_size_t len2)
{
const qse_char_t* end1, * end2;
if (len2 > len1) return QSE_NULL;
end1 = str + len1;
end2 = sub + len2;
while (sub < end2)
{
if (str >= end1 || *str != *sub) return QSE_NULL;
str++; sub++;
}
/* returns the pointer to the next character of the match */
return (qse_char_t*)str;
}
qse_char_t* qse_strend (const qse_char_t* str, const qse_char_t* sub)
{
return qse_strxnend (str, qse_strlen(str), sub, qse_strlen(sub));
}
qse_char_t* qse_strxend (
const qse_char_t* str, qse_size_t len, const qse_char_t* sub)
{
return qse_strxnend (str, len, sub, qse_strlen(sub));
}
qse_char_t* qse_strnend (
const qse_char_t* str, const qse_char_t* sub, qse_size_t len)
{
return qse_strxnend (str, qse_strlen(str), sub, len);
}
qse_char_t* qse_strxnend (
const qse_char_t* str, qse_size_t len1,
const qse_char_t* sub, qse_size_t len2)
{
const qse_char_t* end1, * end2;
if (len2 > len1) return QSE_NULL;
end1 = str + len1;
end2 = sub + len2;
while (end2 > sub)
{
if (end1 <= str) return QSE_NULL;
if (*(--end1) != *(--end2)) return QSE_NULL;
}
/* returns the pointer to the match start */
return (qse_char_t*)end1;
}

148
qse/lib/cmn/str_beg.c Normal file
View File

@ -0,0 +1,148 @@
/*
* $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_mbsbeg (const qse_mchar_t* str, const qse_mchar_t* sub)
{
while (*sub != QSE_MT('\0'))
{
if (*str != *sub) return QSE_NULL;
str++; sub++;
}
/* returns the pointer to the next character of the match */
return (qse_mchar_t*)str;
}
qse_mchar_t* qse_mbsxbeg (
const qse_mchar_t* str, qse_size_t len, const qse_mchar_t* sub)
{
const qse_mchar_t* end = str + len;
while (*sub != QSE_MT('\0'))
{
if (str >= end || *str != *sub) return QSE_NULL;
str++; sub++;
}
/* returns the pointer to the next character of the match */
return (qse_mchar_t*)str;
}
qse_mchar_t* qse_mbsnbeg (
const qse_mchar_t* str, const qse_mchar_t* sub, qse_size_t len)
{
const qse_mchar_t* end = sub + len;
while (sub < end)
{
if (*str == QSE_MT('\0') || *str != *sub) return QSE_NULL;
str++; sub++;
}
/* returns the pointer to the next character of the match */
return (qse_mchar_t*)str;
}
qse_mchar_t* qse_mbsxnbeg (
const qse_mchar_t* str, qse_size_t len1,
const qse_mchar_t* sub, qse_size_t len2)
{
const qse_mchar_t* end1, * end2;
if (len2 > len1) return QSE_NULL;
end1 = str + len1;
end2 = sub + len2;
while (sub < end2)
{
if (str >= end1 || *str != *sub) return QSE_NULL;
str++; sub++;
}
/* returns the pointer to the next character of the match */
return (qse_mchar_t*)str;
}
qse_wchar_t* qse_wcsbeg (const qse_wchar_t* str, const qse_wchar_t* sub)
{
while (*sub != QSE_WT('\0'))
{
if (*str != *sub) return QSE_NULL;
str++; sub++;
}
/* returns the pointer to the next character of the match */
return (qse_wchar_t*)str;
}
qse_wchar_t* qse_wcsxbeg (
const qse_wchar_t* str, qse_size_t len, const qse_wchar_t* sub)
{
const qse_wchar_t* end = str + len;
while (*sub != QSE_WT('\0'))
{
if (str >= end || *str != *sub) return QSE_NULL;
str++; sub++;
}
/* returns the pointer to the next character of the match */
return (qse_wchar_t*)str;
}
qse_wchar_t* qse_wcsnbeg (
const qse_wchar_t* str, const qse_wchar_t* sub, qse_size_t len)
{
const qse_wchar_t* end = sub + len;
while (sub < end)
{
if (*str == QSE_WT('\0') || *str != *sub) return QSE_NULL;
str++; sub++;
}
/* returns the pointer to the next character of the match */
return (qse_wchar_t*)str;
}
qse_wchar_t* qse_wcsxnbeg (
const qse_wchar_t* str, qse_size_t len1,
const qse_wchar_t* sub, qse_size_t len2)
{
const qse_wchar_t* end1, * end2;
if (len2 > len1) return QSE_NULL;
end1 = str + len1;
end2 = sub + len2;
while (sub < end2)
{
if (str >= end1 || *str != *sub) return QSE_NULL;
str++; sub++;
}
/* returns the pointer to the next character of the match */
return (qse_wchar_t*)str;
}

97
qse/lib/cmn/str_end.c Normal file
View File

@ -0,0 +1,97 @@
/*
* $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_mbsend (const qse_mchar_t* str, const qse_mchar_t* sub)
{
return qse_mbsxnend (str, qse_mbslen(str), sub, qse_mbslen(sub));
}
qse_mchar_t* qse_mbsxend (
const qse_mchar_t* str, qse_size_t len, const qse_mchar_t* sub)
{
return qse_mbsxnend (str, len, sub, qse_mbslen(sub));
}
qse_mchar_t* qse_mbsnend (
const qse_mchar_t* str, const qse_mchar_t* sub, qse_size_t len)
{
return qse_mbsxnend (str, qse_mbslen(str), sub, len);
}
qse_mchar_t* qse_mbsxnend (
const qse_mchar_t* str, qse_size_t len1,
const qse_mchar_t* sub, qse_size_t len2)
{
const qse_mchar_t* end1, * end2;
if (len2 > len1) return QSE_NULL;
end1 = str + len1;
end2 = sub + len2;
while (end2 > sub)
{
if (end1 <= str) return QSE_NULL;
if (*(--end1) != *(--end2)) return QSE_NULL;
}
/* returns the pointer to the match start */
return (qse_mchar_t*)end1;
}
qse_wchar_t* qse_wcsend (const qse_wchar_t* str, const qse_wchar_t* sub)
{
return qse_wcsxnend (str, qse_wcslen(str), sub, qse_wcslen(sub));
}
qse_wchar_t* qse_wcsxend (
const qse_wchar_t* str, qse_size_t len, const qse_wchar_t* sub)
{
return qse_wcsxnend (str, len, sub, qse_wcslen(sub));
}
qse_wchar_t* qse_wcsnend (
const qse_wchar_t* str, const qse_wchar_t* sub, qse_size_t len)
{
return qse_wcsxnend (str, qse_wcslen(str), sub, len);
}
qse_wchar_t* qse_wcsxnend (
const qse_wchar_t* str, qse_size_t len1,
const qse_wchar_t* sub, qse_size_t len2)
{
const qse_wchar_t* end1, * end2;
if (len2 > len1) return QSE_NULL;
end1 = str + len1;
end2 = sub + len2;
while (end2 > sub)
{
if (end1 <= str) return QSE_NULL;
if (*(--end1) != *(--end2)) return QSE_NULL;
}
/* returns the pointer to the match start */
return (qse_wchar_t*)end1;
}