diff --git a/qse/cmd/scm/scm.c b/qse/cmd/scm/scm.c index 5eab1aaf..b98dd650 100644 --- a/qse/cmd/scm/scm.c +++ b/qse/cmd/scm/scm.c @@ -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_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"))); } { diff --git a/qse/include/qse/cmn/str.h b/qse/include/qse/cmn/str.h index 66cbb684..b348d725 100644 --- a/qse/include/qse/cmn/str.h +++ b/qse/include/qse/cmn/str.h @@ -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. 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) #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. */ @@ -977,16 +987,6 @@ const qse_mchar_t* qse_mbsxword ( 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. */ @@ -996,6 +996,26 @@ const qse_wchar_t* qse_wcsxword ( 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 * case-insensitively. @@ -1007,10 +1027,14 @@ const qse_wchar_t* qse_wcsxcaseword ( ); #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_strcaseword(str,word) qse_mbscaseword(str,word) # define qse_strxcaseword(str,len,word) qse_mbsxcaseword(str,len,word) #else +# define qse_strword(str,word) qse_wcsword(str,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) #endif diff --git a/qse/lib/cmn/str_bas.c b/qse/lib/cmn/str_bas.c index fa049dfc..bfeff827 100644 --- a/qse/lib/cmn/str_bas.c +++ b/qse/lib/cmn/str_bas.c @@ -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. 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); } -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) { while (*sub != QSE_T('\0')) diff --git a/qse/lib/cmn/str_word.c b/qse/lib/cmn/str_word.c index 6fa97863..1abcb210 100644 --- a/qse/lib/cmn/str_word.c +++ b/qse/lib/cmn/str_word.c @@ -21,6 +21,30 @@ #include #include +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* str, qse_size_t len, const qse_mchar_t* word) { @@ -45,6 +69,30 @@ const qse_mchar_t* qse_mbsxword ( 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* str, qse_size_t len, const qse_mchar_t* word) { @@ -67,6 +115,30 @@ const qse_mchar_t* qse_mbsxcaseword ( 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* str, qse_size_t len, const qse_wchar_t* word) { @@ -91,6 +163,30 @@ const qse_wchar_t* qse_wcsxword ( 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* str, qse_size_t len, const qse_wchar_t* word) { diff --git a/qse/watcom/qse.wpj b/qse/watcom/qse.wpj index 9da75466..ecb40cad 100755 --- a/qse/watcom/qse.wpj +++ b/qse/watcom/qse.wpj @@ -4,10 +4,10 @@ projectIdent VpeMain 1 WRect -120 -186 +0 +80 9320 -9693 +9680 2 MProject 3 @@ -68,8 +68,8 @@ WVList VComponent 18 WRect -290 -2453 +840 +3160 5700 4240 1 @@ -85,7 +85,7 @@ VComponent 21 WRect 90 -1253 +1240 5700 4240 1 @@ -101,7 +101,7 @@ VComponent 24 WRect 2100 -1413 +1400 5700 4240 1 @@ -117,7 +117,7 @@ VComponent 27 WRect 590 -1093 +1080 5700 4240 1 @@ -132,24 +132,24 @@ release/os2/lib/scm/qsescm.tgt VComponent 30 WRect -110 +100 0 5700 4240 -0 +1 0 31 WFileName 28 debug/os2/lib/cmn/qsecmn.tgt -32 -38 +20 +23 32 VComponent 33 WRect 1050 -2373 +2360 5700 4240 1 @@ -165,7 +165,7 @@ VComponent 36 WRect 2360 -1293 +1280 5700 4240 1 @@ -180,8 +180,8 @@ debug/os2/lib/scm/qsescm.tgt VComponent 39 WRect -3660 -573 +2020 +1693 5700 4240 1 @@ -197,26 +197,26 @@ VComponent 42 WRect 1760 -1386 +1360 5700 4240 -0 +1 0 43 WFileName 30 debug/win32/lib/cmn/qsecmn.tgt 38 -4 +38 44 VComponent 45 WRect 180 -1266 +1240 5700 4240 -0 +1 0 46 WFileName @@ -229,10 +229,10 @@ VComponent 48 WRect 3270 -53 +40 5700 4240 -0 +1 0 49 WFileName @@ -240,4 +240,4 @@ WFileName debug/win32/cmd/scm/qsescm.tgt 0 1 -47 +32