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.
This file is part of QSE.
@ -969,24 +969,50 @@ qse_wchar_t* qse_wcsxnrcasestr (
#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_char_t* str,
qse_size_t len,
const qse_char_t* word
const qse_mchar_t* qse_mbsxword (
const qse_mchar_t* str,
qse_size_t len,
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.
*/
const qse_char_t* qse_strxcaseword (
const qse_char_t* str,
qse_size_t len,
const qse_char_t* word
const qse_mchar_t* qse_mbsxcaseword (
const qse_mchar_t* str,
qse_size_t len,
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.

View File

@ -11,7 +11,7 @@ libqsecmn_la_SOURCES = \
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_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 \
tio.c tio_get.c tio_put.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 \
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_spn.lo str_str.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 \
assert.lo main.lo stdio.lo
str_spn.lo str_str.lo str_subst.lo str_utl.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,7 +268,7 @@ libqsecmn_la_SOURCES = \
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_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 \
tio.c tio_get.c tio_put.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_subst.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)/tio.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
10
WPickList
46
47
11
MItem
3
@ -745,8 +745,8 @@ WVList
0
167
MItem
29
..\..\..\..\..\lib\cmn\time.c
33
..\..\..\..\..\lib\cmn\str_word.c
168
WString
4
@ -763,8 +763,8 @@ WVList
0
171
MItem
28
..\..\..\..\..\lib\cmn\tio.c
29
..\..\..\..\..\lib\cmn\time.c
172
WString
4
@ -781,8 +781,8 @@ WVList
0
175
MItem
32
..\..\..\..\..\lib\cmn\tio_get.c
28
..\..\..\..\..\lib\cmn\tio.c
176
WString
4
@ -800,7 +800,7 @@ WVList
179
MItem
32
..\..\..\..\..\lib\cmn\tio_put.c
..\..\..\..\..\lib\cmn\tio_get.c
180
WString
4
@ -817,8 +817,8 @@ WVList
0
183
MItem
28
..\..\..\..\..\lib\cmn\xma.c
32
..\..\..\..\..\lib\cmn\tio_put.c
184
WString
4
@ -835,26 +835,26 @@ WVList
0
187
MItem
3
*.h
28
..\..\..\..\..\lib\cmn\xma.c
188
WString
3
NIL
4
COBJ
189
WVList
0
190
WVList
0
-1
11
1
1
0
191
MItem
28
..\..\..\..\..\lib\cmn\mem.h
3
*.h
192
WString
3
@ -865,14 +865,14 @@ WVList
194
WVList
0
187
-1
1
1
0
195
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
28
..\..\..\..\..\lib\cmn\mem.h
196
WString
3
@ -883,7 +883,25 @@ WVList
198
WVList
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
0

View File

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

View File

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

View File

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