added qse_mbsxword()/qse_wcsxword() and related functions

This commit is contained in:
hyung-hwan 2011-03-31 09:07:48 +00:00
parent 9cf0386f11
commit 48bf4d5a05
8 changed files with 301 additions and 106 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: str.h 421 2011-03-29 15:37:19Z hyunghwan.chung $ * $Id: str.h 422 2011-03-30 15:07:48Z 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.
@ -969,24 +969,50 @@ qse_wchar_t* qse_wcsxnrcasestr (
#endif #endif
/** /**
* The qse_strxword() function finds a whole word in a string. * The qse_mbsxword() function finds a whole word in a string.
*/ */
const qse_char_t* qse_strxword ( const qse_mchar_t* qse_mbsxword (
const qse_char_t* str, const qse_mchar_t* str,
qse_size_t len, qse_size_t len,
const qse_char_t* word const qse_mchar_t* word
); );
/** /**
* The qse_strxcaseword() function finds a whole word in a string * The qse_mbsxcaseword() function finds a whole word in a string
* case-insensitively. * case-insensitively.
*/ */
const qse_char_t* qse_strxcaseword ( const qse_mchar_t* qse_mbsxcaseword (
const qse_char_t* str, const qse_mchar_t* str,
qse_size_t len, qse_size_t len,
const qse_char_t* word const qse_mchar_t* word
); );
/**
* The qse_wcsxword() function finds a whole word in a string.
*/
const qse_wchar_t* qse_wcsxword (
const qse_wchar_t* str,
qse_size_t len,
const qse_wchar_t* word
);
/**
* The qse_wcsxcaseword() function finds a whole word in a string
* case-insensitively.
*/
const qse_wchar_t* qse_wcsxcaseword (
const qse_wchar_t* str,
qse_size_t len,
const qse_wchar_t* word
);
#ifdef QSE_CHAR_IS_MCHAR
# define qse_strxword(str,len,word) qse_mbsxword(str,len,word)
# define qse_strxcaseword(str,len,word) qse_mbsxcaseword(str,len,word)
#else
# define qse_strxword(str,len,word) qse_wcsxword(str,len,word)
# define qse_strxcaseword(str,len,word) qse_wcsxcaseword(str,len,word)
#endif
/** /**
* The qse_mbschr() function finds a chracter in a string. * The qse_mbschr() function finds a chracter in a string.

View File

@ -11,7 +11,7 @@ libqsecmn_la_SOURCES = \
mem.c xma.c fma.c chr.c chr_cnv.c rex.c \ 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_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_pbrk.c str_put.c str_spn.c str_str.c \ str_dyn.c str_fcpy.c str_pbrk.c str_put.c str_spn.c str_str.c \
str_subst.c str_utl.c \ str_subst.c str_utl.c str_word.c \
lda.c oht.c htb.c rbt.c sll.c gdl.c dll.c opt.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 \ tio.c tio_get.c tio_put.c \
fio.c pio.c sio.c \ fio.c pio.c sio.c \

View File

@ -75,10 +75,10 @@ libqsecmn_la_DEPENDENCIES =
am_libqsecmn_la_OBJECTS = mem.lo xma.lo fma.lo chr.lo chr_cnv.lo \ 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 \ 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_pbrk.lo str_put.lo \ str_cpy.lo str_dup.lo str_dyn.lo str_fcpy.lo str_pbrk.lo str_put.lo \
str_spn.lo str_str.lo str_subst.lo str_utl.lo lda.lo oht.lo htb.lo \ str_spn.lo str_str.lo str_subst.lo str_utl.lo str_word.lo lda.lo \
rbt.lo sll.lo gdl.lo dll.lo opt.lo tio.lo tio_get.lo tio_put.lo fio.lo \ oht.lo htb.lo rbt.lo sll.lo gdl.lo dll.lo opt.lo tio.lo tio_get.lo \
pio.lo sio.lo alg_search.lo alg_sort.lo time.lo misc.lo \ tio_put.lo fio.lo pio.lo sio.lo alg_search.lo alg_sort.lo time.lo \
assert.lo main.lo stdio.lo misc.lo assert.lo main.lo stdio.lo
libqsecmn_la_OBJECTS = $(am_libqsecmn_la_OBJECTS) libqsecmn_la_OBJECTS = $(am_libqsecmn_la_OBJECTS)
libqsecmn_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ libqsecmn_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
@ -268,7 +268,7 @@ libqsecmn_la_SOURCES = \
mem.c xma.c fma.c chr.c chr_cnv.c rex.c \ 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_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_pbrk.c str_put.c str_spn.c str_str.c \ str_dyn.c str_fcpy.c str_pbrk.c str_put.c str_spn.c str_str.c \
str_subst.c str_utl.c \ str_subst.c str_utl.c str_word.c \
lda.c oht.c htb.c rbt.c sll.c gdl.c dll.c opt.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 \ tio.c tio_get.c tio_put.c \
fio.c pio.c sio.c \ fio.c pio.c sio.c \
@ -401,6 +401,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_str.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_str.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_subst.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_subst.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_utl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_utl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_word.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tio.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tio_get.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tio_get.Plo@am__quote@

114
qse/lib/cmn/str_word.c Normal file
View File

@ -0,0 +1,114 @@
/*
* $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>
#include <qse/cmn/chr.h>
const qse_mchar_t* qse_mbsxword (
const qse_mchar_t* str, qse_size_t len, const qse_mchar_t* word)
{
/* find a full word in a string */
const qse_mchar_t* ptr = str;
const qse_mchar_t* end = str + len;
const qse_mchar_t* s;
do
{
while (ptr < end && QSE_ISMSPACE(*ptr)) ptr++;
if (ptr >= end) return QSE_NULL;
s = ptr;
while (ptr < end && !QSE_ISMSPACE(*ptr)) ptr++;
if (qse_mbsxcmp (s, ptr-s, word) == 0) return s;
}
while (ptr < end);
return QSE_NULL;
}
const qse_mchar_t* qse_mbsxcaseword (
const qse_mchar_t* str, qse_size_t len, const qse_mchar_t* word)
{
const qse_mchar_t* ptr = str;
const qse_mchar_t* end = str + len;
const qse_mchar_t* s;
do
{
while (ptr < end && QSE_ISMSPACE(*ptr)) ptr++;
if (ptr >= end) return QSE_NULL;
s = ptr;
while (ptr < end && !QSE_ISMSPACE(*ptr)) ptr++;
if (qse_mbsxcasecmp (s, ptr-s, word) == 0) return s;
}
while (ptr < end);
return QSE_NULL;
}
const qse_wchar_t* qse_wcsxword (
const qse_wchar_t* str, qse_size_t len, const qse_wchar_t* word)
{
/* find a full word in a string */
const qse_wchar_t* ptr = str;
const qse_wchar_t* end = str + len;
const qse_wchar_t* s;
do
{
while (ptr < end && QSE_ISWSPACE(*ptr)) ptr++;
if (ptr >= end) return QSE_NULL;
s = ptr;
while (ptr < end && !QSE_ISWSPACE(*ptr)) ptr++;
if (qse_wcsxcmp (s, ptr-s, word) == 0) return s;
}
while (ptr < end);
return QSE_NULL;
}
const qse_wchar_t* qse_wcsxcaseword (
const qse_wchar_t* str, qse_size_t len, const qse_wchar_t* word)
{
const qse_wchar_t* ptr = str;
const qse_wchar_t* end = str + len;
const qse_wchar_t* s;
do
{
while (ptr < end && QSE_ISWSPACE(*ptr)) ptr++;
if (ptr >= end) return QSE_NULL;
s = ptr;
while (ptr < end && !QSE_ISWSPACE(*ptr)) ptr++;
if (qse_wcsxcasecmp (s, ptr-s, word) == 0) return s;
}
while (ptr < end);
return QSE_NULL;
}

View File

@ -42,7 +42,7 @@ WVList
0 0
10 10
WPickList WPickList
46 47
11 11
MItem MItem
3 3
@ -745,8 +745,8 @@ WVList
0 0
167 167
MItem MItem
29 33
..\..\..\..\..\lib\cmn\time.c ..\..\..\..\..\lib\cmn\str_word.c
168 168
WString WString
4 4
@ -763,8 +763,8 @@ WVList
0 0
171 171
MItem MItem
28 29
..\..\..\..\..\lib\cmn\tio.c ..\..\..\..\..\lib\cmn\time.c
172 172
WString WString
4 4
@ -781,8 +781,8 @@ WVList
0 0
175 175
MItem MItem
32 28
..\..\..\..\..\lib\cmn\tio_get.c ..\..\..\..\..\lib\cmn\tio.c
176 176
WString WString
4 4
@ -800,7 +800,7 @@ WVList
179 179
MItem MItem
32 32
..\..\..\..\..\lib\cmn\tio_put.c ..\..\..\..\..\lib\cmn\tio_get.c
180 180
WString WString
4 4
@ -817,8 +817,8 @@ WVList
0 0
183 183
MItem MItem
28 32
..\..\..\..\..\lib\cmn\xma.c ..\..\..\..\..\lib\cmn\tio_put.c
184 184
WString WString
4 4
@ -835,26 +835,26 @@ WVList
0 0
187 187
MItem MItem
3 28
*.h ..\..\..\..\..\lib\cmn\xma.c
188 188
WString WString
3 4
NIL COBJ
189 189
WVList WVList
0 0
190 190
WVList WVList
0 0
-1 11
1 1
1 1
0 0
191 191
MItem MItem
28 3
..\..\..\..\..\lib\cmn\mem.h *.h
192 192
WString WString
3 3
@ -865,14 +865,14 @@ WVList
194 194
WVList WVList
0 0
187 -1
1 1
1 1
0 0
195 195
MItem MItem
32 28
..\..\..\..\..\lib\cmn\syscall.h ..\..\..\..\..\lib\cmn\mem.h
196 196
WString WString
3 3
@ -883,7 +883,25 @@ WVList
198 198
WVList WVList
0 0
187 191
1
1
0
199
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
200
WString
3
NIL
201
WVList
0
202
WVList
0
191
1 1
1 1
0 0

View File

@ -42,7 +42,7 @@ WVList
0 0
10 10
WPickList WPickList
46 47
11 11
MItem MItem
3 3
@ -745,8 +745,8 @@ WVList
0 0
167 167
MItem MItem
29 33
..\..\..\..\..\lib\cmn\time.c ..\..\..\..\..\lib\cmn\str_word.c
168 168
WString WString
4 4
@ -763,8 +763,8 @@ WVList
0 0
171 171
MItem MItem
28 29
..\..\..\..\..\lib\cmn\tio.c ..\..\..\..\..\lib\cmn\time.c
172 172
WString WString
4 4
@ -781,8 +781,8 @@ WVList
0 0
175 175
MItem MItem
32 28
..\..\..\..\..\lib\cmn\tio_get.c ..\..\..\..\..\lib\cmn\tio.c
176 176
WString WString
4 4
@ -800,7 +800,7 @@ WVList
179 179
MItem MItem
32 32
..\..\..\..\..\lib\cmn\tio_put.c ..\..\..\..\..\lib\cmn\tio_get.c
180 180
WString WString
4 4
@ -817,8 +817,8 @@ WVList
0 0
183 183
MItem MItem
28 32
..\..\..\..\..\lib\cmn\xma.c ..\..\..\..\..\lib\cmn\tio_put.c
184 184
WString WString
4 4
@ -835,26 +835,26 @@ WVList
0 0
187 187
MItem MItem
3 28
*.h ..\..\..\..\..\lib\cmn\xma.c
188 188
WString WString
3 4
NIL COBJ
189 189
WVList WVList
0 0
190 190
WVList WVList
0 0
-1 11
1 1
1 1
0 0
191 191
MItem MItem
28 3
..\..\..\..\..\lib\cmn\mem.h *.h
192 192
WString WString
3 3
@ -865,14 +865,14 @@ WVList
194 194
WVList WVList
0 0
187 -1
1 1
1 1
0 0
195 195
MItem MItem
32 28
..\..\..\..\..\lib\cmn\syscall.h ..\..\..\..\..\lib\cmn\mem.h
196 196
WString WString
3 3
@ -883,7 +883,25 @@ WVList
198 198
WVList WVList
0 0
187 191
1
1
0
199
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
200
WString
3
NIL
201
WVList
0
202
WVList
0
191
1 1
1 1
0 0

View File

@ -4,10 +4,10 @@ projectIdent
VpeMain VpeMain
1 1
WRect WRect
0 120
80 186
9320 9320
9120 9693
2 2
MProject MProject
3 3
@ -69,7 +69,7 @@ VComponent
18 18
WRect WRect
290 290
1880 2453
5700 5700
4240 4240
1 1
@ -85,7 +85,7 @@ VComponent
21 21
WRect WRect
90 90
680 1253
5700 5700
4240 4240
1 1
@ -101,7 +101,7 @@ VComponent
24 24
WRect WRect
2100 2100
840 1413
5700 5700
4240 4240
1 1
@ -117,7 +117,7 @@ VComponent
27 27
WRect WRect
590 590
520 1093
5700 5700
4240 4240
1 1
@ -133,23 +133,23 @@ VComponent
30 30
WRect WRect
110 110
-160 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
0 32
5 38
32 32
VComponent VComponent
33 33
WRect WRect
1050 1050
1800 2373
5700 5700
4240 4240
1 1
@ -165,7 +165,7 @@ VComponent
36 36
WRect WRect
2360 2360
720 1293
5700 5700
4240 4240
1 1
@ -181,7 +181,7 @@ VComponent
39 39
WRect WRect
3660 3660
-240 573
5700 5700
4240 4240
1 1
@ -196,26 +196,26 @@ debug/os2/cmd/scm/qsescm.tgt
VComponent VComponent
42 42
WRect WRect
1200 1760
26 1386
5700 5700
4253 4240
0 0
0 0
43 43
WFileName WFileName
30 30
debug/win32/lib/cmn/qsecmn.tgt debug/win32/lib/cmn/qsecmn.tgt
0 38
6 4
44 44
VComponent VComponent
45 45
WRect WRect
240 180
893 1266
5700 5700
4253 4240
0 0
0 0
46 46
@ -228,10 +228,10 @@ debug/win32/lib/scm/qsescm.tgt
VComponent VComponent
48 48
WRect WRect
3060 3270
640 53
5700 5700
4253 4240
0 0
0 0
49 49
@ -240,4 +240,4 @@ WFileName
debug/win32/cmd/scm/qsescm.tgt debug/win32/cmd/scm/qsescm.tgt
0 0
1 1
44 47

View File

@ -42,7 +42,7 @@ WVList
0 0
10 10
WPickList WPickList
46 47
11 11
MItem MItem
3 3
@ -825,8 +825,8 @@ WVList
0 0
187 187
MItem MItem
29 33
..\..\..\..\..\lib\cmn\time.c ..\..\..\..\..\lib\cmn\str_word.c
188 188
WString WString
4 4
@ -843,8 +843,8 @@ WVList
0 0
191 191
MItem MItem
28 29
..\..\..\..\..\lib\cmn\tio.c ..\..\..\..\..\lib\cmn\time.c
192 192
WString WString
4 4
@ -861,8 +861,8 @@ WVList
0 0
195 195
MItem MItem
32 28
..\..\..\..\..\lib\cmn\tio_get.c ..\..\..\..\..\lib\cmn\tio.c
196 196
WString WString
4 4
@ -880,7 +880,7 @@ WVList
199 199
MItem MItem
32 32
..\..\..\..\..\lib\cmn\tio_put.c ..\..\..\..\..\lib\cmn\tio_get.c
200 200
WString WString
4 4
@ -897,8 +897,8 @@ WVList
0 0
203 203
MItem MItem
28 32
..\..\..\..\..\lib\cmn\xma.c ..\..\..\..\..\lib\cmn\tio_put.c
204 204
WString WString
4 4
@ -915,26 +915,26 @@ WVList
0 0
207 207
MItem MItem
3 28
*.h ..\..\..\..\..\lib\cmn\xma.c
208 208
WString WString
3 4
NIL COBJ
209 209
WVList WVList
0 0
210 210
WVList WVList
0 0
-1 11
1 1
1 1
0 0
211 211
MItem MItem
28 3
..\..\..\..\..\lib\cmn\mem.h *.h
212 212
WString WString
3 3
@ -945,14 +945,14 @@ WVList
214 214
WVList WVList
0 0
207 -1
1 1
1 1
0 0
215 215
MItem MItem
32 28
..\..\..\..\..\lib\cmn\syscall.h ..\..\..\..\..\lib\cmn\mem.h
216 216
WString WString
3 3
@ -963,7 +963,25 @@ WVList
218 218
WVList WVList
0 0
207 211
1
1
0
219
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
220
WString
3
NIL
221
WVList
0
222
WVList
0
211
1 1
1 1
0 0