added qse_mbsword()/qse_wcsword()/qse_mbscaseword()/qse_wcscaseword()

This commit is contained in:
hyung-hwan 2011-03-31 22:15:24 +00:00
parent 48bf4d5a05
commit 96da678f14
5 changed files with 160 additions and 83 deletions

View File

@ -246,6 +246,10 @@ pio1 (QSE_T("ls -laF"), QSE_PIO_READOUT|QSE_PIO_WRITEIN|/*QSE_PIO_SHELL|*/QSE_PI
qse_printf (QSE_T("%s\n"), qse_strrcasestr (QSE_T("fbFBFBFBxyz"), QSE_T("fb"))); qse_printf (QSE_T("%s\n"), qse_strrcasestr (QSE_T("fbFBFBFBxyz"), QSE_T("fb")));
qse_printf (QSE_T("%s\n"), qse_strcasestr (QSE_T("fbFBFBFBxyz"), QSE_T("fb"))); qse_printf (QSE_T("%s\n"), qse_strcasestr (QSE_T("fbFBFBFBxyz"), QSE_T("fb")));
qse_printf (QSE_T("%s\n"), qse_strword (QSE_T("ilove lov LOVE love"), QSE_T("love")));
qse_printf (QSE_T("%s\n"), qse_strcaseword (QSE_T("ilove lov LOVE love"), QSE_T("love")));
qse_printf (QSE_T("%s\n"), qse_strxword (QSE_T("ilove love you"), 14, QSE_T("love")));
} }
{ {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: str.h 422 2011-03-30 15:07:48Z hyunghwan.chung $ * $Id: str.h 423 2011-03-31 04:15:24Z 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.
@ -968,6 +968,16 @@ qse_wchar_t* qse_wcsxnrcasestr (
# define qse_strxnrcasestr(str,strsz,sub,subsz) qse_wcsxnrcasestr(str,strsz,sub,subsz) # define qse_strxnrcasestr(str,strsz,sub,subsz) qse_wcsxnrcasestr(str,strsz,sub,subsz)
#endif #endif
const qse_mchar_t* qse_mbsword (
const qse_mchar_t* str,
const qse_mchar_t* word
);
const qse_wchar_t* qse_wcsword (
const qse_wchar_t* str,
const qse_wchar_t* word
);
/** /**
* The qse_mbsxword() function finds a whole word in a string. * The qse_mbsxword() function finds a whole word in a string.
*/ */
@ -977,16 +987,6 @@ const qse_mchar_t* qse_mbsxword (
const qse_mchar_t* word const qse_mchar_t* word
); );
/**
* The qse_mbsxcaseword() function finds a whole word in a string
* case-insensitively.
*/
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. * The qse_wcsxword() function finds a whole word in a string.
*/ */
@ -996,6 +996,26 @@ const qse_wchar_t* qse_wcsxword (
const qse_wchar_t* word const qse_wchar_t* word
); );
const qse_mchar_t* qse_mbscaseword (
const qse_mchar_t* str,
const qse_mchar_t* word
);
const qse_wchar_t* qse_wcscaseword (
const qse_wchar_t* str,
const qse_wchar_t* word
);
/**
* The qse_mbsxcaseword() function finds a whole word in a string
* case-insensitively.
*/
const qse_mchar_t* qse_mbsxcaseword (
const qse_mchar_t* str,
qse_size_t len,
const qse_mchar_t* word
);
/** /**
* The qse_wcsxcaseword() function finds a whole word in a string * The qse_wcsxcaseword() function finds a whole word in a string
* case-insensitively. * case-insensitively.
@ -1007,10 +1027,14 @@ const qse_wchar_t* qse_wcsxcaseword (
); );
#ifdef QSE_CHAR_IS_MCHAR #ifdef QSE_CHAR_IS_MCHAR
# define qse_strword(str,word) qse_mbsword(str,word)
# define qse_strxword(str,len,word) qse_mbsxword(str,len,word) # define qse_strxword(str,len,word) qse_mbsxword(str,len,word)
# define qse_strcaseword(str,word) qse_mbscaseword(str,word)
# define qse_strxcaseword(str,len,word) qse_mbsxcaseword(str,len,word) # define qse_strxcaseword(str,len,word) qse_mbsxcaseword(str,len,word)
#else #else
# define qse_strword(str,word) qse_wcsword(str,word)
# define qse_strxword(str,len,word) qse_wcsxword(str,len,word) # define qse_strxword(str,len,word) qse_wcsxword(str,len,word)
# define qse_strcaseword(str,word) qse_wcscaseword(str,word)
# define qse_strxcaseword(str,len,word) qse_wcsxcaseword(str,len,word) # define qse_strxcaseword(str,len,word) qse_wcsxcaseword(str,len,word)
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
* $Id: str_bas.c 421 2011-03-29 15:37:19Z hyunghwan.chung $ * $Id: str_bas.c 423 2011-03-31 04:15:24Z 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.
@ -43,53 +43,6 @@ qse_size_t qse_strbytes (const qse_char_t* str)
return (p - str) * QSE_SIZEOF(qse_char_t); return (p - str) * QSE_SIZEOF(qse_char_t);
} }
const qse_char_t* qse_strxword (
const qse_char_t* str, qse_size_t len, const qse_char_t* word)
{
/* find a full word in a string */
const qse_char_t* ptr = str;
const qse_char_t* end = str + len;
const qse_char_t* s;
do
{
while (ptr < end && QSE_ISSPACE(*ptr)) ptr++;
if (ptr >= end) return QSE_NULL;
s = ptr;
while (ptr < end && !QSE_ISSPACE(*ptr)) ptr++;
if (qse_strxcmp (s, ptr-s, word) == 0) return s;
}
while (ptr < end);
return QSE_NULL;
}
const qse_char_t* qse_strxcaseword (
const qse_char_t* str, qse_size_t len, const qse_char_t* word)
{
const qse_char_t* ptr = str;
const qse_char_t* end = str + len;
const qse_char_t* s;
do
{
while (ptr < end && QSE_ISSPACE(*ptr)) ptr++;
if (ptr >= end) return QSE_NULL;
s = ptr;
while (ptr < end && !QSE_ISSPACE(*ptr)) ptr++;
if (qse_strxcasecmp (s, ptr-s, word) == 0) return s;
}
while (ptr < end);
return QSE_NULL;
}
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'))

View File

@ -21,6 +21,30 @@
#include <qse/cmn/str.h> #include <qse/cmn/str.h>
#include <qse/cmn/chr.h> #include <qse/cmn/chr.h>
const qse_mchar_t* qse_mbsword (
const qse_mchar_t* str, const qse_mchar_t* word)
{
/* find a full word in a string */
const qse_mchar_t* ptr = str;
do
{
const qse_mchar_t* s;
while (QSE_ISMSPACE(*ptr)) ptr++;
if (*ptr == QSE_MT('\0')) return QSE_NULL;
s = ptr;
while (*ptr != QSE_MT('\0') && !QSE_ISMSPACE(*ptr)) ptr++;
if (qse_mbsxcmp (s, ptr-s, word) == 0) return s;
}
while (*ptr != QSE_MT('\0'));
return QSE_NULL;
}
const qse_mchar_t* qse_mbsxword ( const qse_mchar_t* qse_mbsxword (
const qse_mchar_t* str, qse_size_t len, const qse_mchar_t* word) const qse_mchar_t* str, qse_size_t len, const qse_mchar_t* word)
{ {
@ -45,6 +69,30 @@ const qse_mchar_t* qse_mbsxword (
return QSE_NULL; return QSE_NULL;
} }
const qse_mchar_t* qse_mbscaseword (
const qse_mchar_t* str, const qse_mchar_t* word)
{
/* find a full word in a string */
const qse_mchar_t* ptr = str;
do
{
const qse_mchar_t* s;
while (QSE_ISMSPACE(*ptr)) ptr++;
if (*ptr == QSE_MT('\0')) return QSE_NULL;
s = ptr;
while (*ptr != QSE_MT('\0') && !QSE_ISMSPACE(*ptr)) ptr++;
if (qse_mbsxcasecmp (s, ptr-s, word) == 0) return s;
}
while (*ptr != QSE_MT('\0'));
return QSE_NULL;
}
const qse_mchar_t* qse_mbsxcaseword ( const qse_mchar_t* qse_mbsxcaseword (
const qse_mchar_t* str, qse_size_t len, const qse_mchar_t* word) const qse_mchar_t* str, qse_size_t len, const qse_mchar_t* word)
{ {
@ -67,6 +115,30 @@ const qse_mchar_t* qse_mbsxcaseword (
return QSE_NULL; return QSE_NULL;
} }
const qse_wchar_t* qse_wcsword (
const qse_wchar_t* str, const qse_wchar_t* word)
{
/* find a full word in a string */
const qse_wchar_t* ptr = str;
do
{
const qse_wchar_t* s;
while (QSE_ISWSPACE(*ptr)) ptr++;
if (*ptr == QSE_WT('\0')) return QSE_NULL;
s = ptr;
while (*ptr != QSE_WT('\0') && !QSE_ISWSPACE(*ptr)) ptr++;
if (qse_wcsxcmp (s, ptr-s, word) == 0) return s;
}
while (*ptr != QSE_WT('\0'));
return QSE_NULL;
}
const qse_wchar_t* qse_wcsxword ( const qse_wchar_t* qse_wcsxword (
const qse_wchar_t* str, qse_size_t len, const qse_wchar_t* word) const qse_wchar_t* str, qse_size_t len, const qse_wchar_t* word)
{ {
@ -91,6 +163,30 @@ const qse_wchar_t* qse_wcsxword (
return QSE_NULL; return QSE_NULL;
} }
const qse_wchar_t* qse_wcscaseword (
const qse_wchar_t* str, const qse_wchar_t* word)
{
/* find a full word in a string */
const qse_wchar_t* ptr = str;
do
{
const qse_wchar_t* s;
while (QSE_ISWSPACE(*ptr)) ptr++;
if (*ptr == QSE_WT('\0')) return QSE_NULL;
s = ptr;
while (*ptr != QSE_WT('\0') && !QSE_ISWSPACE(*ptr)) ptr++;
if (qse_wcsxcasecmp (s, ptr-s, word) == 0) return s;
}
while (*ptr != QSE_WT('\0'));
return QSE_NULL;
}
const qse_wchar_t* qse_wcsxcaseword ( const qse_wchar_t* qse_wcsxcaseword (
const qse_wchar_t* str, qse_size_t len, const qse_wchar_t* word) const qse_wchar_t* str, qse_size_t len, const qse_wchar_t* word)
{ {

View File

@ -4,10 +4,10 @@ projectIdent
VpeMain VpeMain
1 1
WRect WRect
120 0
186 80
9320 9320
9693 9680
2 2
MProject MProject
3 3
@ -68,8 +68,8 @@ WVList
VComponent VComponent
18 18
WRect WRect
290 840
2453 3160
5700 5700
4240 4240
1 1
@ -85,7 +85,7 @@ VComponent
21 21
WRect WRect
90 90
1253 1240
5700 5700
4240 4240
1 1
@ -101,7 +101,7 @@ VComponent
24 24
WRect WRect
2100 2100
1413 1400
5700 5700
4240 4240
1 1
@ -117,7 +117,7 @@ VComponent
27 27
WRect WRect
590 590
1093 1080
5700 5700
4240 4240
1 1
@ -132,24 +132,24 @@ release/os2/lib/scm/qsescm.tgt
VComponent VComponent
30 30
WRect WRect
110 100
0 0
5700 5700
4240 4240
0 1
0 0
31 31
WFileName WFileName
28 28
debug/os2/lib/cmn/qsecmn.tgt debug/os2/lib/cmn/qsecmn.tgt
32 20
38 23
32 32
VComponent VComponent
33 33
WRect WRect
1050 1050
2373 2360
5700 5700
4240 4240
1 1
@ -165,7 +165,7 @@ VComponent
36 36
WRect WRect
2360 2360
1293 1280
5700 5700
4240 4240
1 1
@ -180,8 +180,8 @@ debug/os2/lib/scm/qsescm.tgt
VComponent VComponent
39 39
WRect WRect
3660 2020
573 1693
5700 5700
4240 4240
1 1
@ -197,26 +197,26 @@ VComponent
42 42
WRect WRect
1760 1760
1386 1360
5700 5700
4240 4240
0 1
0 0
43 43
WFileName WFileName
30 30
debug/win32/lib/cmn/qsecmn.tgt debug/win32/lib/cmn/qsecmn.tgt
38 38
4 38
44 44
VComponent VComponent
45 45
WRect WRect
180 180
1266 1240
5700 5700
4240 4240
0 1
0 0
46 46
WFileName WFileName
@ -229,10 +229,10 @@ VComponent
48 48
WRect WRect
3270 3270
53 40
5700 5700
4240 4240
0 1
0 0
49 49
WFileName WFileName
@ -240,4 +240,4 @@ WFileName
debug/win32/cmd/scm/qsescm.tgt debug/win32/cmd/scm/qsescm.tgt
0 0
1 1
47 32