added qse_mbsset()/qse_wcsset()/qse_mbsdel()/qse_wcsdel() and related functions
This commit is contained in:
@ -10,9 +10,9 @@ libqsecmn_la_SOURCES = \
|
||||
syscall.h mem.h \
|
||||
mem.c xma.c fma.c chr.c chr_cnv.c rex.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_rev.c str_rot.c str_spl.c str_spn.c str_str.c \
|
||||
str_subst.c str_tok.c str_trm.c str_word.c \
|
||||
str_del.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_rev.c str_rot.c str_set.c str_spl.c \
|
||||
str_spn.c str_str.c str_subst.c str_tok.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 \
|
||||
|
@ -74,12 +74,12 @@ LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
libqsecmn_la_DEPENDENCIES =
|
||||
am_libqsecmn_la_OBJECTS = mem.lo xma.lo fma.lo chr.lo chr_cnv.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_rev.lo str_rot.lo str_spl.lo \
|
||||
str_spn.lo str_str.lo str_subst.lo str_tok.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
|
||||
str_cpy.lo str_del.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_rev.lo str_rot.lo \
|
||||
str_set.lo str_spl.lo str_spn.lo str_str.lo str_subst.lo str_tok.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
|
||||
libqsecmn_la_OBJECTS = $(am_libqsecmn_la_OBJECTS)
|
||||
libqsecmn_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
@ -268,9 +268,9 @@ libqsecmn_la_SOURCES = \
|
||||
syscall.h mem.h \
|
||||
mem.c xma.c fma.c chr.c chr_cnv.c rex.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_rev.c str_rot.c str_spl.c str_spn.c str_str.c \
|
||||
str_subst.c str_tok.c str_trm.c str_word.c \
|
||||
str_del.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_rev.c str_rot.c str_set.c str_spl.c \
|
||||
str_spn.c str_str.c str_subst.c str_tok.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 \
|
||||
@ -394,6 +394,7 @@ distclean-compile:
|
||||
@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_del.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@
|
||||
@ -404,6 +405,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_put.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_rev.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_rot.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_set.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_spl.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_spn.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_str.Plo@am__quote@
|
||||
|
81
qse/lib/cmn/str_del.c
Normal file
81
qse/lib/cmn/str_del.c
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* $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_size_t qse_mbsdel (qse_mchar_t* str, qse_size_t pos, qse_size_t n)
|
||||
{
|
||||
qse_mchar_t* p = str, * q = str;
|
||||
qse_size_t idx = 0;
|
||||
|
||||
while (*p != QSE_MT('\0'))
|
||||
{
|
||||
if (idx < pos || idx >= pos + n) *q++ = *p;
|
||||
idx++; p++;
|
||||
}
|
||||
|
||||
*q = QSE_MT('\0');
|
||||
return q - str;
|
||||
}
|
||||
|
||||
qse_size_t qse_mbsxdel (
|
||||
qse_mchar_t* str, qse_size_t len, qse_size_t pos, qse_size_t n)
|
||||
{
|
||||
qse_mchar_t* p = str, * q = str, * end = str + len;
|
||||
qse_size_t idx = 0;
|
||||
|
||||
while (p < end)
|
||||
{
|
||||
if (idx < pos || idx >= pos + n) *q++ = *p;
|
||||
idx++; p++;
|
||||
}
|
||||
|
||||
return q - str;
|
||||
}
|
||||
|
||||
qse_size_t qse_wcsdel (qse_wchar_t* str, qse_size_t pos, qse_size_t n)
|
||||
{
|
||||
qse_wchar_t* p = str, * q = str;
|
||||
qse_size_t idx = 0;
|
||||
|
||||
while (*p != QSE_WT('\0'))
|
||||
{
|
||||
if (idx < pos || idx >= pos + n) *q++ = *p;
|
||||
idx++; p++;
|
||||
}
|
||||
|
||||
*q = QSE_WT('\0');
|
||||
return q - str;
|
||||
}
|
||||
|
||||
qse_size_t qse_wcsxdel (
|
||||
qse_wchar_t* str, qse_size_t len, qse_size_t pos, qse_size_t n)
|
||||
{
|
||||
qse_wchar_t* p = str, * q = str, * end = str + len;
|
||||
qse_size_t idx = 0;
|
||||
|
||||
while (p < end)
|
||||
{
|
||||
if (idx < pos || idx >= pos + n) *q++ = *p;
|
||||
idx++; p++;
|
||||
}
|
||||
|
||||
return q - str;
|
||||
}
|
68
qse/lib/cmn/str_set.c
Normal file
68
qse/lib/cmn/str_set.c
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* $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_size_t qse_mbsset (qse_mchar_t* buf, qse_mchar_t c, qse_size_t n)
|
||||
{
|
||||
qse_size_t len = n;
|
||||
buf[n] = QSE_MT('\0');
|
||||
while (n > 0) buf[--n] = c;
|
||||
return len;
|
||||
}
|
||||
|
||||
qse_size_t qse_mbsxset (
|
||||
qse_mchar_t* buf, qse_size_t bsz, qse_mchar_t c, qse_size_t n)
|
||||
{
|
||||
qse_size_t len;
|
||||
|
||||
if (bsz <= 0) return 0;
|
||||
|
||||
if (n >= bsz) n = bsz - 1;
|
||||
len = n;
|
||||
|
||||
buf[n] = QSE_MT('\0');
|
||||
while (n > 0) buf[--n] = c;
|
||||
return len;
|
||||
}
|
||||
|
||||
qse_size_t qse_wcsset (qse_wchar_t* buf, qse_wchar_t c, qse_size_t n)
|
||||
{
|
||||
qse_size_t len = n;
|
||||
buf[n] = QSE_WT('\0');
|
||||
while (n > 0) buf[--n] = c;
|
||||
return len;
|
||||
}
|
||||
|
||||
qse_size_t qse_wcsxset (
|
||||
qse_wchar_t* buf, qse_size_t bsz, qse_wchar_t c, qse_size_t n)
|
||||
{
|
||||
qse_size_t len;
|
||||
|
||||
if (bsz <= 0) return 0;
|
||||
|
||||
if (n >= bsz) n = bsz - 1;
|
||||
len = n;
|
||||
|
||||
buf[n] = QSE_WT('\0');
|
||||
while (n > 0) buf[--n] = c;
|
||||
return len;
|
||||
}
|
Reference in New Issue
Block a user