added qse_mbscat()/qse_wcscat() and related functions

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

View File

@ -1,5 +1,5 @@
/*
* $Id: str.h 417 2011-03-27 14:32:37Z hyunghwan.chung $
* $Id: str.h 419 2011-03-28 16:07:37Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -508,19 +508,79 @@ qse_size_t qse_wcsxsubst (
# define qse_strxsubst(buf,bsz,fmt,subst,ctx) qse_wcsxsubst(buf,bsz,fmt,subst,ctx)
#endif
qse_size_t qse_strxcat (
qse_char_t* buf,
qse_size_t bsz,
const qse_char_t* str
qse_size_t qse_mbscat (
qse_mchar_t* buf,
const qse_mchar_t* str
);
qse_size_t qse_strxncat (
qse_char_t* buf,
qse_size_t bsz,
const qse_char_t* str,
qse_size_t qse_mbsncat (
qse_mchar_t* buf,
const qse_mchar_t* str,
qse_size_t len
);
qse_size_t qse_mbscatn (
qse_mchar_t* buf,
const qse_mchar_t* str,
qse_size_t n
);
qse_size_t qse_mbsxcat (
qse_mchar_t* buf,
qse_size_t bsz,
const qse_mchar_t* str
);
qse_size_t qse_mbsxncat (
qse_mchar_t* buf,
qse_size_t bsz,
const qse_mchar_t* str,
qse_size_t len
);
qse_size_t qse_wcscat (
qse_wchar_t* buf,
const qse_wchar_t* str
);
qse_size_t qse_wcsncat (
qse_wchar_t* buf,
const qse_wchar_t* str,
qse_size_t len
);
qse_size_t qse_wcscatn (
qse_wchar_t* buf,
const qse_wchar_t* str,
qse_size_t n
);
qse_size_t qse_wcsxcat (
qse_wchar_t* buf,
qse_size_t bsz,
const qse_wchar_t* str
);
qse_size_t qse_wcsxncat (
qse_wchar_t* buf,
qse_size_t bsz,
const qse_wchar_t* str,
qse_size_t len
);
#ifdef QSE_CHAR_IS_MCHAR
# define qse_strcat(buf,str) qse_mbscat(buf,str)
# define qse_strncat(buf,str,len) qse_mbsncat(buf,str,len)
# define qse_strcatn(buf,str,n) qse_mbscatn(buf,str,n)
# define qse_strxcat(buf,bsz,str) qse_mbsxcat(buf,bsz,str);
# define qse_strxncat(buf,bsz,str,len) qse_mbsxncat(buf,bsz,str,len)
#else
# define qse_strcat(buf,str) qse_wcscat(buf,str)
# define qse_strncat(buf,str,len) qse_wcsncat(buf,str,len)
# define qse_strcatn(buf,str,n) qse_wcscatn(buf,str,n)
# define qse_strxcat(buf,bsz,str) qse_wcsxcat(buf,bsz,str);
# define qse_strxncat(buf,bsz,str,len) qse_wcsxncat(buf,bsz,str,len)
#endif
int qse_mbscmp (
const qse_mchar_t* s1,

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,7 +24,6 @@
#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)
@ -32,9 +31,7 @@
# 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)
@ -43,7 +40,6 @@
# 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;
}

View File

@ -42,7 +42,7 @@ WVList
0
10
WPickList
43
44
11
MItem
3
@ -494,7 +494,7 @@ WVList
111
MItem
32
..\..\..\..\..\lib\cmn\str_chr.c
..\..\..\..\..\lib\cmn\str_cat.c
112
WString
4
@ -512,7 +512,7 @@ WVList
115
MItem
32
..\..\..\..\..\lib\cmn\str_cmp.c
..\..\..\..\..\lib\cmn\str_chr.c
116
WString
4
@ -530,7 +530,7 @@ WVList
119
MItem
32
..\..\..\..\..\lib\cmn\str_cnv.c
..\..\..\..\..\lib\cmn\str_cmp.c
120
WString
4
@ -548,7 +548,7 @@ WVList
123
MItem
32
..\..\..\..\..\lib\cmn\str_cpy.c
..\..\..\..\..\lib\cmn\str_cnv.c
124
WString
4
@ -566,7 +566,7 @@ WVList
127
MItem
32
..\..\..\..\..\lib\cmn\str_dyn.c
..\..\..\..\..\lib\cmn\str_cpy.c
128
WString
4
@ -583,8 +583,8 @@ WVList
0
131
MItem
33
..\..\..\..\..\lib\cmn\str_fcpy.c
32
..\..\..\..\..\lib\cmn\str_dyn.c
132
WString
4
@ -602,7 +602,7 @@ WVList
135
MItem
33
..\..\..\..\..\lib\cmn\str_pbrk.c
..\..\..\..\..\lib\cmn\str_fcpy.c
136
WString
4
@ -619,8 +619,8 @@ WVList
0
139
MItem
32
..\..\..\..\..\lib\cmn\str_put.c
33
..\..\..\..\..\lib\cmn\str_pbrk.c
140
WString
4
@ -638,7 +638,7 @@ WVList
143
MItem
32
..\..\..\..\..\lib\cmn\str_spn.c
..\..\..\..\..\lib\cmn\str_put.c
144
WString
4
@ -655,8 +655,8 @@ WVList
0
147
MItem
34
..\..\..\..\..\lib\cmn\str_subst.c
32
..\..\..\..\..\lib\cmn\str_spn.c
148
WString
4
@ -673,8 +673,8 @@ WVList
0
151
MItem
32
..\..\..\..\..\lib\cmn\str_utl.c
34
..\..\..\..\..\lib\cmn\str_subst.c
152
WString
4
@ -691,8 +691,8 @@ WVList
0
155
MItem
29
..\..\..\..\..\lib\cmn\time.c
32
..\..\..\..\..\lib\cmn\str_utl.c
156
WString
4
@ -709,8 +709,8 @@ WVList
0
159
MItem
28
..\..\..\..\..\lib\cmn\tio.c
29
..\..\..\..\..\lib\cmn\time.c
160
WString
4
@ -727,8 +727,8 @@ WVList
0
163
MItem
32
..\..\..\..\..\lib\cmn\tio_get.c
28
..\..\..\..\..\lib\cmn\tio.c
164
WString
4
@ -746,7 +746,7 @@ WVList
167
MItem
32
..\..\..\..\..\lib\cmn\tio_put.c
..\..\..\..\..\lib\cmn\tio_get.c
168
WString
4
@ -763,8 +763,8 @@ WVList
0
171
MItem
28
..\..\..\..\..\lib\cmn\xma.c
32
..\..\..\..\..\lib\cmn\tio_put.c
172
WString
4
@ -781,26 +781,26 @@ WVList
0
175
MItem
3
*.h
28
..\..\..\..\..\lib\cmn\xma.c
176
WString
3
NIL
4
COBJ
177
WVList
0
178
WVList
0
-1
11
1
1
0
179
MItem
28
..\..\..\..\..\lib\cmn\mem.h
3
*.h
180
WString
3
@ -811,14 +811,14 @@ WVList
182
WVList
0
175
-1
1
1
0
183
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
28
..\..\..\..\..\lib\cmn\mem.h
184
WString
3
@ -829,7 +829,25 @@ WVList
186
WVList
0
175
179
1
1
0
187
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
188
WString
3
NIL
189
WVList
0
190
WVList
0
179
1
1
0

View File

@ -67,7 +67,7 @@ WFileName
30
release/os2/lib/cmn/qsecmn.tgt
22
23
29
17
VComponent
18
@ -130,8 +130,8 @@ WRect
WFileName
28
debug/os2/lib/cmn/qsecmn.tgt
27
35
24
24
29
VComponent
30
@ -153,7 +153,7 @@ VComponent
33
WRect
3280
1346
1333
5700
4240
0
@ -180,4 +180,4 @@ WFileName
debug/os2/cmd/scm/qsescm.tgt
0
1
35
26

View File

@ -42,7 +42,7 @@ WVList
0
10
WPickList
43
44
11
MItem
3
@ -558,7 +558,7 @@ WVList
127
MItem
32
..\..\..\..\..\lib\cmn\str_chr.c
..\..\..\..\..\lib\cmn\str_cat.c
128
WString
4
@ -576,7 +576,7 @@ WVList
131
MItem
32
..\..\..\..\..\lib\cmn\str_cmp.c
..\..\..\..\..\lib\cmn\str_chr.c
132
WString
4
@ -594,7 +594,7 @@ WVList
135
MItem
32
..\..\..\..\..\lib\cmn\str_cnv.c
..\..\..\..\..\lib\cmn\str_cmp.c
136
WString
4
@ -612,7 +612,7 @@ WVList
139
MItem
32
..\..\..\..\..\lib\cmn\str_cpy.c
..\..\..\..\..\lib\cmn\str_cnv.c
140
WString
4
@ -630,7 +630,7 @@ WVList
143
MItem
32
..\..\..\..\..\lib\cmn\str_dyn.c
..\..\..\..\..\lib\cmn\str_cpy.c
144
WString
4
@ -647,8 +647,8 @@ WVList
0
147
MItem
33
..\..\..\..\..\lib\cmn\str_fcpy.c
32
..\..\..\..\..\lib\cmn\str_dyn.c
148
WString
4
@ -666,7 +666,7 @@ WVList
151
MItem
33
..\..\..\..\..\lib\cmn\str_pbrk.c
..\..\..\..\..\lib\cmn\str_fcpy.c
152
WString
4
@ -683,8 +683,8 @@ WVList
0
155
MItem
32
..\..\..\..\..\lib\cmn\str_put.c
33
..\..\..\..\..\lib\cmn\str_pbrk.c
156
WString
4
@ -702,7 +702,7 @@ WVList
159
MItem
32
..\..\..\..\..\lib\cmn\str_spn.c
..\..\..\..\..\lib\cmn\str_put.c
160
WString
4
@ -719,8 +719,8 @@ WVList
0
163
MItem
34
..\..\..\..\..\lib\cmn\str_subst.c
32
..\..\..\..\..\lib\cmn\str_spn.c
164
WString
4
@ -737,48 +737,48 @@ WVList
0
167
MItem
32
..\..\..\..\..\lib\cmn\str_utl.c
34
..\..\..\..\..\lib\cmn\str_subst.c
168
WString
4
COBJ
169
WVList
1
170
MVState
171
WString
3
WCC
172
WString
25
o?2??Include directories:
1
173
WString
54
"$(%watcom)/h;$(%watcom)/h/os2;..\..\..\..\..\include"
0
174
170
WVList
0
11
1
1
0
175
171
MItem
29
..\..\..\..\..\lib\cmn\time.c
176
32
..\..\..\..\..\lib\cmn\str_utl.c
172
WString
4
COBJ
177
173
WVList
1
174
MVState
175
WString
3
WCC
176
WString
25
o?2??Include directories:
1
177
WString
54
"$(%watcom)/h;$(%watcom)/h/os2;..\..\..\..\..\include"
0
178
WVList
@ -789,8 +789,8 @@ WVList
0
179
MItem
28
..\..\..\..\..\lib\cmn\tio.c
29
..\..\..\..\..\lib\cmn\time.c
180
WString
4
@ -807,8 +807,8 @@ WVList
0
183
MItem
32
..\..\..\..\..\lib\cmn\tio_get.c
28
..\..\..\..\..\lib\cmn\tio.c
184
WString
4
@ -826,7 +826,7 @@ WVList
187
MItem
32
..\..\..\..\..\lib\cmn\tio_put.c
..\..\..\..\..\lib\cmn\tio_get.c
188
WString
4
@ -843,8 +843,8 @@ WVList
0
191
MItem
28
..\..\..\..\..\lib\cmn\xma.c
32
..\..\..\..\..\lib\cmn\tio_put.c
192
WString
4
@ -861,26 +861,26 @@ WVList
0
195
MItem
3
*.h
28
..\..\..\..\..\lib\cmn\xma.c
196
WString
3
NIL
4
COBJ
197
WVList
0
198
WVList
0
-1
11
1
1
0
199
MItem
28
..\..\..\..\..\lib\cmn\mem.h
3
*.h
200
WString
3
@ -891,14 +891,14 @@ WVList
202
WVList
0
195
-1
1
1
0
203
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
28
..\..\..\..\..\lib\cmn\mem.h
204
WString
3
@ -909,7 +909,25 @@ WVList
206
WVList
0
195
199
1
1
0
207
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
208
WString
3
NIL
209
WVList
0
210
WVList
0
199
1
1
0