added qse_mbsbytes()/qse_wcsbytes()

This commit is contained in:
hyung-hwan 2011-04-04 08:57:23 +00:00
parent 2f4a4000cd
commit ee52b08a0c
7 changed files with 248 additions and 157 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: str.h 423 2011-03-31 04:15:24Z hyunghwan.chung $ * $Id: str.h 425 2011-04-03 14:57:23Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -169,20 +169,29 @@ qse_size_t qse_wcslen (
const qse_wchar_t* wcs const qse_wchar_t* wcs
); );
#ifdef QSE_CHAR_IS_MCHAR
# define qse_strlen(str) qse_mbslen(str)
#else
# define qse_strlen(str) qse_wcslen(str)
#endif
/** /**
* The qse_strbytes() function returns the number of bytes a null-terminated * The qse_mbsbytes() function returns the number of bytes a null-terminated
* string is holding excluding a terminating null. * string is holding excluding a terminating null.
*/ */
qse_size_t qse_strbytes ( qse_size_t qse_strbytes (
const qse_char_t* str const qse_mchar_t* str
); );
/**
* The qse_wcsbytes() function returns the number of bytes a null-terminated
* string is holding excluding a terminating null.
*/
qse_size_t qse_wcsbytes (
const qse_wchar_t* str
);
#ifdef QSE_CHAR_IS_MCHAR
# define qse_strlen(str) qse_mbslen(str)
# define qse_strbytes(str) qse_mbsbytes(str)
#else
# define qse_strlen(str) qse_wcslen(str)
# define qse_strbytes(str) qse_wcsbytes(str)
#endif
qse_size_t qse_mbscpy ( qse_size_t qse_mbscpy (
qse_mchar_t* buf, qse_mchar_t* buf,

View File

@ -1,5 +1,5 @@
/* /*
* $Id: str_bas.c 423 2011-03-31 04:15:24Z hyunghwan.chung $ * $Id: str_bas.c 425 2011-04-03 14:57:23Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -22,27 +22,6 @@
#include <qse/cmn/chr.h> #include <qse/cmn/chr.h>
#include "mem.h" #include "mem.h"
qse_size_t qse_mbslen (const qse_mchar_t* mbs)
{
const qse_mchar_t* p = mbs;
while (*p != QSE_MT('\0')) p++;
return p - mbs;
}
qse_size_t qse_wcslen (const qse_wchar_t* wcs)
{
const qse_wchar_t* p = wcs;
while (*p != QSE_WT('\0')) p++;
return p - wcs;
}
qse_size_t qse_strbytes (const qse_char_t* str)
{
const qse_char_t* p = str;
while (*p != QSE_T('\0')) p++;
return (p - str) * QSE_SIZEOF(qse_char_t);
}
qse_char_t* qse_strbeg (const qse_char_t* str, const qse_char_t* sub) qse_char_t* qse_strbeg (const qse_char_t* str, const qse_char_t* sub)
{ {
while (*sub != QSE_T('\0')) while (*sub != QSE_T('\0'))

49
qse/lib/cmn/str_len.c Normal file
View File

@ -0,0 +1,49 @@
/*
* $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_mbslen (const qse_mchar_t* mbs)
{
const qse_mchar_t* p = mbs;
while (*p != QSE_MT('\0')) p++;
return p - mbs;
}
qse_size_t qse_wcslen (const qse_wchar_t* wcs)
{
const qse_wchar_t* p = wcs;
while (*p != QSE_WT('\0')) p++;
return p - wcs;
}
qse_size_t qse_mbsbytes (const qse_mchar_t* str)
{
const qse_mchar_t* p = str;
while (*p != QSE_MT('\0')) p++;
return (p - str) * QSE_SIZEOF(qse_mchar_t);
}
qse_size_t qse_wcsbytes (const qse_wchar_t* str)
{
const qse_wchar_t* p = str;
while (*p != QSE_WT('\0')) p++;
return (p - str) * QSE_SIZEOF(qse_wchar_t);
}

View File

@ -42,7 +42,7 @@ WVList
0 0
10 10
WPickList WPickList
47 48
11 11
MItem MItem
3 3
@ -637,8 +637,8 @@ WVList
0 0
143 143
MItem MItem
33 32
..\..\..\..\..\lib\cmn\str_pbrk.c ..\..\..\..\..\lib\cmn\str_len.c
144 144
WString WString
4 4
@ -655,8 +655,8 @@ WVList
0 0
147 147
MItem MItem
32 33
..\..\..\..\..\lib\cmn\str_put.c ..\..\..\..\..\lib\cmn\str_pbrk.c
148 148
WString WString
4 4
@ -674,7 +674,7 @@ WVList
151 151
MItem MItem
32 32
..\..\..\..\..\lib\cmn\str_spn.c ..\..\..\..\..\lib\cmn\str_put.c
152 152
WString WString
4 4
@ -692,7 +692,7 @@ WVList
155 155
MItem MItem
32 32
..\..\..\..\..\lib\cmn\str_str.c ..\..\..\..\..\lib\cmn\str_spn.c
156 156
WString WString
4 4
@ -709,8 +709,8 @@ WVList
0 0
159 159
MItem MItem
34 32
..\..\..\..\..\lib\cmn\str_subst.c ..\..\..\..\..\lib\cmn\str_str.c
160 160
WString WString
4 4
@ -727,8 +727,8 @@ WVList
0 0
163 163
MItem MItem
32 34
..\..\..\..\..\lib\cmn\str_utl.c ..\..\..\..\..\lib\cmn\str_subst.c
164 164
WString WString
4 4
@ -745,8 +745,8 @@ WVList
0 0
167 167
MItem MItem
33 32
..\..\..\..\..\lib\cmn\str_word.c ..\..\..\..\..\lib\cmn\str_utl.c
168 168
WString WString
4 4
@ -763,8 +763,8 @@ WVList
0 0
171 171
MItem MItem
29 33
..\..\..\..\..\lib\cmn\time.c ..\..\..\..\..\lib\cmn\str_word.c
172 172
WString WString
4 4
@ -781,8 +781,8 @@ WVList
0 0
175 175
MItem MItem
28 29
..\..\..\..\..\lib\cmn\tio.c ..\..\..\..\..\lib\cmn\time.c
176 176
WString WString
4 4
@ -799,8 +799,8 @@ WVList
0 0
179 179
MItem MItem
32 28
..\..\..\..\..\lib\cmn\tio_get.c ..\..\..\..\..\lib\cmn\tio.c
180 180
WString WString
4 4
@ -818,7 +818,7 @@ WVList
183 183
MItem MItem
32 32
..\..\..\..\..\lib\cmn\tio_put.c ..\..\..\..\..\lib\cmn\tio_get.c
184 184
WString WString
4 4
@ -835,8 +835,8 @@ WVList
0 0
187 187
MItem MItem
28 32
..\..\..\..\..\lib\cmn\xma.c ..\..\..\..\..\lib\cmn\tio_put.c
188 188
WString WString
4 4
@ -853,26 +853,26 @@ WVList
0 0
191 191
MItem MItem
3 28
*.h ..\..\..\..\..\lib\cmn\xma.c
192 192
WString WString
3 4
NIL COBJ
193 193
WVList WVList
0 0
194 194
WVList WVList
0 0
-1 11
1 1
1 1
0 0
195 195
MItem MItem
28 3
..\..\..\..\..\lib\cmn\mem.h *.h
196 196
WString WString
3 3
@ -883,14 +883,14 @@ WVList
198 198
WVList WVList
0 0
191 -1
1 1
1 1
0 0
199 199
MItem MItem
32 28
..\..\..\..\..\lib\cmn\syscall.h ..\..\..\..\..\lib\cmn\mem.h
200 200
WString WString
3 3
@ -901,7 +901,25 @@ WVList
202 202
WVList WVList
0 0
191 195
1
1
0
203
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
204
WString
3
NIL
205
WVList
0
206
WVList
0
195
1 1
1 1
0 0

View File

@ -42,7 +42,7 @@ WVList
0 0
10 10
WPickList WPickList
47 48
11 11
MItem MItem
3 3
@ -637,8 +637,8 @@ WVList
0 0
143 143
MItem MItem
33 32
..\..\..\..\..\lib\cmn\str_pbrk.c ..\..\..\..\..\lib\cmn\str_len.c
144 144
WString WString
4 4
@ -655,8 +655,8 @@ WVList
0 0
147 147
MItem MItem
32 33
..\..\..\..\..\lib\cmn\str_put.c ..\..\..\..\..\lib\cmn\str_pbrk.c
148 148
WString WString
4 4
@ -674,7 +674,7 @@ WVList
151 151
MItem MItem
32 32
..\..\..\..\..\lib\cmn\str_spn.c ..\..\..\..\..\lib\cmn\str_put.c
152 152
WString WString
4 4
@ -692,7 +692,7 @@ WVList
155 155
MItem MItem
32 32
..\..\..\..\..\lib\cmn\str_str.c ..\..\..\..\..\lib\cmn\str_spn.c
156 156
WString WString
4 4
@ -709,8 +709,8 @@ WVList
0 0
159 159
MItem MItem
34 32
..\..\..\..\..\lib\cmn\str_subst.c ..\..\..\..\..\lib\cmn\str_str.c
160 160
WString WString
4 4
@ -727,8 +727,8 @@ WVList
0 0
163 163
MItem MItem
32 34
..\..\..\..\..\lib\cmn\str_utl.c ..\..\..\..\..\lib\cmn\str_subst.c
164 164
WString WString
4 4
@ -745,8 +745,8 @@ WVList
0 0
167 167
MItem MItem
33 32
..\..\..\..\..\lib\cmn\str_word.c ..\..\..\..\..\lib\cmn\str_utl.c
168 168
WString WString
4 4
@ -763,8 +763,8 @@ WVList
0 0
171 171
MItem MItem
29 33
..\..\..\..\..\lib\cmn\time.c ..\..\..\..\..\lib\cmn\str_word.c
172 172
WString WString
4 4
@ -781,8 +781,8 @@ WVList
0 0
175 175
MItem MItem
28 29
..\..\..\..\..\lib\cmn\tio.c ..\..\..\..\..\lib\cmn\time.c
176 176
WString WString
4 4
@ -799,8 +799,8 @@ WVList
0 0
179 179
MItem MItem
32 28
..\..\..\..\..\lib\cmn\tio_get.c ..\..\..\..\..\lib\cmn\tio.c
180 180
WString WString
4 4
@ -818,7 +818,7 @@ WVList
183 183
MItem MItem
32 32
..\..\..\..\..\lib\cmn\tio_put.c ..\..\..\..\..\lib\cmn\tio_get.c
184 184
WString WString
4 4
@ -835,8 +835,8 @@ WVList
0 0
187 187
MItem MItem
28 32
..\..\..\..\..\lib\cmn\xma.c ..\..\..\..\..\lib\cmn\tio_put.c
188 188
WString WString
4 4
@ -853,26 +853,26 @@ WVList
0 0
191 191
MItem MItem
3 28
*.h ..\..\..\..\..\lib\cmn\xma.c
192 192
WString WString
3 4
NIL COBJ
193 193
WVList WVList
0 0
194 194
WVList WVList
0 0
-1 11
1 1
1 1
0 0
195 195
MItem MItem
28 3
..\..\..\..\..\lib\cmn\mem.h *.h
196 196
WString WString
3 3
@ -883,14 +883,14 @@ WVList
198 198
WVList WVList
0 0
191 -1
1 1
1 1
0 0
199 199
MItem MItem
32 28
..\..\..\..\..\lib\cmn\syscall.h ..\..\..\..\..\lib\cmn\mem.h
200 200
WString WString
3 3
@ -901,7 +901,25 @@ WVList
202 202
WVList WVList
0 0
191 195
1
1
0
203
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
204
WString
3
NIL
205
WVList
0
206
WVList
0
195
1 1
1 1
0 0

View File

@ -136,14 +136,14 @@ WRect
0 0
5700 5700
4240 4240
1 0
0 0
31 31
WFileName WFileName
28 28
debug/os2/lib/cmn/qsecmn.tgt debug/os2/lib/cmn/qsecmn.tgt
20 31
23 32
32 32
VComponent VComponent
33 33
@ -197,7 +197,7 @@ VComponent
42 42
WRect WRect
980 980
1093 1080
5700 5700
4240 4240
0 0
@ -207,13 +207,13 @@ WFileName
30 30
debug/win32/lib/cmn/qsecmn.tgt debug/win32/lib/cmn/qsecmn.tgt
18 18
24 22
44 44
VComponent VComponent
45 45
WRect WRect
200 200
1253 1240
5700 5700
4240 4240
1 1
@ -240,4 +240,4 @@ WFileName
debug/win32/cmd/scm/qsescm.tgt debug/win32/cmd/scm/qsescm.tgt
0 0
1 1
41 29

View File

@ -42,7 +42,7 @@ WVList
0 0
10 10
WPickList WPickList
47 48
11 11
MItem MItem
3 3
@ -701,8 +701,8 @@ WVList
0 0
159 159
MItem MItem
33 32
..\..\..\..\..\lib\cmn\str_pbrk.c ..\..\..\..\..\lib\cmn\str_len.c
160 160
WString WString
4 4
@ -719,8 +719,8 @@ WVList
0 0
163 163
MItem MItem
32 33
..\..\..\..\..\lib\cmn\str_put.c ..\..\..\..\..\lib\cmn\str_pbrk.c
164 164
WString WString
4 4
@ -738,7 +738,7 @@ WVList
167 167
MItem MItem
32 32
..\..\..\..\..\lib\cmn\str_spn.c ..\..\..\..\..\lib\cmn\str_put.c
168 168
WString WString
4 4
@ -756,7 +756,7 @@ WVList
171 171
MItem MItem
32 32
..\..\..\..\..\lib\cmn\str_str.c ..\..\..\..\..\lib\cmn\str_spn.c
172 172
WString WString
4 4
@ -773,8 +773,8 @@ WVList
0 0
175 175
MItem MItem
34 32
..\..\..\..\..\lib\cmn\str_subst.c ..\..\..\..\..\lib\cmn\str_str.c
176 176
WString WString
4 4
@ -791,48 +791,48 @@ WVList
0 0
179 179
MItem MItem
32 34
..\..\..\..\..\lib\cmn\str_utl.c ..\..\..\..\..\lib\cmn\str_subst.c
180 180
WString WString
4 4
COBJ COBJ
181 181
WVList WVList
1
182
MVState
183
WString
3
WCC
184
WString
25
o?2??Include directories:
1
185
WString
54
"$(%watcom)/h;$(%watcom)/h/os2;..\..\..\..\..\include"
0 0
186 182
WVList WVList
0 0
11 11
1 1
1 1
0 0
187 183
MItem MItem
33 32
..\..\..\..\..\lib\cmn\str_word.c ..\..\..\..\..\lib\cmn\str_utl.c
188 184
WString WString
4 4
COBJ COBJ
189 185
WVList WVList
1
186
MVState
187
WString
3
WCC
188
WString
25
o?2??Include directories:
1
189
WString
54
"$(%watcom)/h;$(%watcom)/h/os2;..\..\..\..\..\include"
0 0
190 190
WVList WVList
@ -843,8 +843,8 @@ WVList
0 0
191 191
MItem MItem
29 33
..\..\..\..\..\lib\cmn\time.c ..\..\..\..\..\lib\cmn\str_word.c
192 192
WString WString
4 4
@ -861,8 +861,8 @@ WVList
0 0
195 195
MItem MItem
28 29
..\..\..\..\..\lib\cmn\tio.c ..\..\..\..\..\lib\cmn\time.c
196 196
WString WString
4 4
@ -879,8 +879,8 @@ WVList
0 0
199 199
MItem MItem
32 28
..\..\..\..\..\lib\cmn\tio_get.c ..\..\..\..\..\lib\cmn\tio.c
200 200
WString WString
4 4
@ -898,7 +898,7 @@ WVList
203 203
MItem MItem
32 32
..\..\..\..\..\lib\cmn\tio_put.c ..\..\..\..\..\lib\cmn\tio_get.c
204 204
WString WString
4 4
@ -915,8 +915,8 @@ WVList
0 0
207 207
MItem MItem
28 32
..\..\..\..\..\lib\cmn\xma.c ..\..\..\..\..\lib\cmn\tio_put.c
208 208
WString WString
4 4
@ -933,26 +933,26 @@ WVList
0 0
211 211
MItem MItem
3 28
*.h ..\..\..\..\..\lib\cmn\xma.c
212 212
WString WString
3 4
NIL COBJ
213 213
WVList WVList
0 0
214 214
WVList WVList
0 0
-1 11
1 1
1 1
0 0
215 215
MItem MItem
28 3
..\..\..\..\..\lib\cmn\mem.h *.h
216 216
WString WString
3 3
@ -963,14 +963,14 @@ WVList
218 218
WVList WVList
0 0
211 -1
1 1
1 1
0 0
219 219
MItem MItem
32 28
..\..\..\..\..\lib\cmn\syscall.h ..\..\..\..\..\lib\cmn\mem.h
220 220
WString WString
3 3
@ -981,7 +981,25 @@ WVList
222 222
WVList WVList
0 0
211 215
1
1
0
223
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
224
WString
3
NIL
225
WVList
0
226
WVList
0
215
1 1
1 1
0 0