added qse_mbscat()/qse_wcscat() and related functions

This commit is contained in:
2011-03-29 10:07:37 +00:00
parent a0ed88add5
commit 22a3eee756
9 changed files with 408 additions and 180 deletions

View File

@ -9,8 +9,8 @@ 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_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_subst.c str_utl.c \
str_bas.c str_cat.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_subst.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 \
fio.c pio.c sio.c \

View File

@ -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_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 \
rex.lo str_bas.lo str_cat.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_subst.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 \
@ -266,8 +266,8 @@ 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_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_subst.c str_utl.c \
str_bas.c str_cat.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_subst.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 \
fio.c pio.c sio.c \
@ -386,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_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@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_cnv.Plo@am__quote@

View File

@ -1,5 +1,5 @@
/*
* $Id: mem.h 291 2009-09-21 13:28:18Z hyunghwan.chung $
* $Id: mem.h 419 2011-03-28 16:07:37Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -24,26 +24,22 @@
#include <qse/cmn/mem.h>
#ifdef MINIMIZE_PLATFORM_DEPENDENCY
#define QSE_MEMCPY(dst,src,len) qse_memcpy(dst,src,len)
#define QSE_MEMCMP(p1,p2,len) qse_memcmp(p1,p2,len)
#define QSE_MEMSET(dst,val,len) qse_memset(dst,val,len)
#define QSE_MEMBYTE(s,val,len) qse_membyte(s,val,len)
#define QSE_MEMRBYTE(s,val,len) qse_memrbyte(s,val,len)
#define QSE_MEMMEM(hs,hl,nd,nl) qse_memmem(hs,hl,nd,nl)
#define QSE_MEMRMEM(hs,hl,nd,nl) qse_memrmem(hs,hl,nd,nl)
# define QSE_MEMCPY(dst,src,len) qse_memcpy(dst,src,len)
# define QSE_MEMCMP(p1,p2,len) qse_memcmp(p1,p2,len)
# define QSE_MEMSET(dst,val,len) qse_memset(dst,val,len)
# define QSE_MEMBYTE(s,val,len) qse_membyte(s,val,len)
# define QSE_MEMRBYTE(s,val,len) qse_memrbyte(s,val,len)
# define QSE_MEMMEM(hs,hl,nd,nl) qse_memmem(hs,hl,nd,nl)
# define QSE_MEMRMEM(hs,hl,nd,nl) qse_memrmem(hs,hl,nd,nl)
#else
#include <string.h>
#define QSE_MEMCPY(dst,src,len) memcpy(dst,src,len)
#define QSE_MEMCMP(p1,p2,len) memcmp(p1,p2,len)
#define QSE_MEMSET(dst,val,len) memset(dst,val,len)
#define QSE_MEMBYTE(s,val,len) memchr(s,val,len)
#define QSE_MEMRBYTE(s,val,len) memrchr(s,val,len)
#define QSE_MEMMEM(hs,hl,nd,nl) memmem(hs,hl,nd,nl)
#define QSE_MEMRMEM(hs,hl,nd,nl) memrmem(hs,hl,nd,nl)
# include <string.h>
# define QSE_MEMCPY(dst,src,len) memcpy(dst,src,len)
# define QSE_MEMCMP(p1,p2,len) memcmp(p1,p2,len)
# define QSE_MEMSET(dst,val,len) memset(dst,val,len)
# define QSE_MEMBYTE(s,val,len) memchr(s,val,len)
# define QSE_MEMRBYTE(s,val,len) memrchr(s,val,len)
# define QSE_MEMMEM(hs,hl,nd,nl) memmem(hs,hl,nd,nl)
# define QSE_MEMRMEM(hs,hl,nd,nl) memrmem(hs,hl,nd,nl)
#endif
#define QSE_MALLOC(mmgr,size) QSE_MMGR_ALLOC(mmgr,size)

View File

@ -1,5 +1,5 @@
/*
* $Id: str_bas.c 417 2011-03-27 14:32:37Z hyunghwan.chung $
* $Id: str_bas.c 419 2011-03-28 16:07:37Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -43,52 +43,6 @@ qse_size_t qse_strbytes (const qse_char_t* str)
return (p - str) * QSE_SIZEOF(qse_char_t);
}
qse_size_t qse_strxcat (qse_char_t* buf, qse_size_t bsz, const qse_char_t* str)
{
qse_char_t* p, * p2;
qse_size_t blen;
blen = qse_strlen(buf);
if (blen >= bsz) return blen; /* something wrong */
p = buf + blen;
p2 = buf + bsz - 1;
while (p < p2)
{
if (*str == QSE_T('\0')) break;
*p++ = *str++;
}
if (bsz > 0) *p = QSE_T('\0');
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)
{
qse_char_t* p, * p2;
const qse_char_t* end;
qse_size_t blen;
blen = qse_strlen(buf);
if (blen >= bsz) return blen; /* something wrong */
p = buf + blen;
p2 = buf + bsz - 1;
end = str + len;
while (p < p2)
{
if (str >= end) break;
*p++ = *str++;
}
if (bsz > 0) *p = QSE_T('\0');
return p - buf;
}
qse_char_t* qse_strdup (const qse_char_t* str, qse_mmgr_t* mmgr)
{
qse_char_t* tmp;

181
qse/lib/cmn/str_cat.c Normal file
View File

@ -0,0 +1,181 @@
/*
* $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_mbscat (qse_mchar_t* buf, const qse_mchar_t* str)
{
qse_mchar_t* org = buf;
buf += qse_mbslen(buf);
while ((*buf++ = *str++) != QSE_MT('\0'));
return buf - org - 1;
}
qse_size_t qse_mbsncat (qse_mchar_t* buf, const qse_mchar_t* str, qse_size_t len)
{
qse_size_t x;
const qse_mchar_t* end = str + len;
x = qse_mbslen(buf); buf += x;
while (str < end) *buf++ = *str++;
*buf = QSE_MT('\0');
return len + x;
}
qse_size_t qse_mbscatn (qse_mchar_t* buf, const qse_mchar_t* str, qse_size_t n)
{
qse_size_t x;
qse_mchar_t* org = buf;
const qse_mchar_t* end = str + n;
x = qse_mbslen(buf); buf += x;
while (str < end)
{
if ((*buf++ = *str++) == QSE_MT('\0')) return buf - org - 1;
}
return n + x;
}
qse_size_t qse_mbsxcat (qse_mchar_t* buf, qse_size_t bsz, const qse_mchar_t* str)
{
qse_mchar_t* p, * p2;
qse_size_t blen;
blen = qse_mbslen(buf);
if (blen >= bsz) return blen; /* something wrong */
p = buf + blen;
p2 = buf + bsz - 1;
while (p < p2)
{
if (*str == QSE_MT('\0')) break;
*p++ = *str++;
}
if (bsz > 0) *p = QSE_MT('\0');
return p - buf;
}
qse_size_t qse_mbsxncat (
qse_mchar_t* buf, qse_size_t bsz, const qse_mchar_t* str, qse_size_t len)
{
qse_mchar_t* p, * p2;
const qse_mchar_t* end;
qse_size_t blen;
blen = qse_mbslen(buf);
if (blen >= bsz) return blen; /* something wrong */
p = buf + blen;
p2 = buf + bsz - 1;
end = str + len;
while (p < p2)
{
if (str >= end) break;
*p++ = *str++;
}
if (bsz > 0) *p = QSE_MT('\0');
return p - buf;
}
qse_size_t qse_wcscat (qse_wchar_t* buf, const qse_wchar_t* str)
{
qse_wchar_t* org = buf;
buf += qse_wcslen(buf);
while ((*buf++ = *str++) != QSE_WT('\0'));
return buf - org - 1;
}
qse_size_t qse_wcsncat (qse_wchar_t* buf, const qse_wchar_t* str, qse_size_t len)
{
qse_size_t x;
const qse_wchar_t* end = str + len;
x = qse_wcslen(buf); buf += x;
while (str < end) *buf++ = *str++;
*buf = QSE_WT('\0');
return len + x;
}
qse_size_t qse_wcscatn (qse_wchar_t* buf, const qse_wchar_t* str, qse_size_t n)
{
qse_size_t x;
qse_wchar_t* org = buf;
const qse_wchar_t* end = str + n;
x = qse_wcslen(buf); buf += x;
while (str < end)
{
if ((*buf++ = *str++) == QSE_WT('\0')) return buf - org - 1;
}
return n + x;
}
qse_size_t qse_wcsxcat (qse_wchar_t* buf, qse_size_t bsz, const qse_wchar_t* str)
{
qse_wchar_t* p, * p2;
qse_size_t blen;
blen = qse_wcslen(buf);
if (blen >= bsz) return blen; /* something wrong */
p = buf + blen;
p2 = buf + bsz - 1;
while (p < p2)
{
if (*str == QSE_WT('\0')) break;
*p++ = *str++;
}
if (bsz > 0) *p = QSE_WT('\0');
return p - buf;
}
qse_size_t qse_wcsxncat (
qse_wchar_t* buf, qse_size_t bsz, const qse_wchar_t* str, qse_size_t len)
{
qse_wchar_t* p, * p2;
const qse_wchar_t* end;
qse_size_t blen;
blen = qse_wcslen(buf);
if (blen >= bsz) return blen; /* something wrong */
p = buf + blen;
p2 = buf + bsz - 1;
end = str + len;
while (p < p2)
{
if (str >= end) break;
*p++ = *str++;
}
if (bsz > 0) *p = QSE_WT('\0');
return p - buf;
}