1 //---------------------------------------------------------------------------
7 //---------------------------------------------------------------------------
8 #pragma package(smart_init)
10 // pos
\82©
\82ç
\92P
\8cê
\82ð
\90Ø
\82è
\8fo
\82·
11 // pos
\82Ístr
\82©
\82ç
\82Ì
\83I
\83t
\83Z
\83b
\83g
12 // start,end
\82Ístr
\82©
\82ç
\82Ì
\83I
\83t
\83Z
\83b
\83g
\82ð
\95Ô
\82·
13 // prevstart
\82Í
\81Astart
\82Ì
\82P
\82Â
\91O
\82Ì
\92P
\8cê
\81A
\96³
\82¢
\8fê
\8d\87\82Ístart
\82Æ
\93¯
\82¶
\92l
14 // fLongest
\82ªTRUE
\82Ì
\8fê
\8d\87\82Í
\81A
\8dÅ
\8d\8210
\8cê
\82Ü
\82Åget
\82·
\82é(.)
\82ð
\8fI
\82í
\82è
\82Æ
\82Ý
\82È
\82·
15 // about :
\82¢
\82¢
\89Á
\8c¸
\82È
\82Æ
\82±
\82ë
\82ð
\83N
\83\8a\83b
\83N
\82µ
\82Ä
\82à
\92P
\8cê
\82³
\82¦
\82 \82ê
\82Î
\95K
\82¸get
\82·
\82é
16 // alnum :
\89p
\90\94\8e\9a\88È
\8aO
\82Í
\96³
\8e\8b
18 BOOL GetWord( const tchar *str, int pos, int &start, int &end, int &prevstart, bool fLongest, int wordcount, bool about, bool alnum )
21 if ( !IsWordChar( *(str+pos) ) )
23 // while ( *(str+pos) == ' ' || *(str+pos) == '\t' ){
27 //
\89ü
\8ds
\82Ì
\8fê
\8d\87\82Í
\96³
\82µ
28 if ( str[pos] == '\r' || str[pos] == '\n' ){
32 // pos
\82ª
\95¶
\8e\9a\97ñ
\82Ì
\8fI
\92[
\81A
\82 \82é
\82¢
\82Í
\95¶
\8e\9a\97ñ
\82Ì
\8fI
\92[
\82©
\82ç
\82P
\82Â
\91O
\82Ì
\89ü
\8ds
\82Å
\82 \82é
\8fê
\8d\87\82Í
\82¾
\82ß //
33 if ( !str[pos] || (!str[pos+1] && ((tuchar)str[pos] < ' ')) )
36 const tchar *orgp = str;
37 const tchar *p = orgp;
39 //
\92P
\8cê
\82Ì
\90æ
\93ª
\82ð
\92T
\82· //
40 const tchar *wordtop = NULL;
43 //
\89p
\90\94\8e\9a\82Ì
\82Ý
44 if ( isalphanum(*p) ){
45 //
\92P
\8cê
\82Ì
\8en
\82Ü
\82è
51 //
\95¶
\8e\9a\8eí
\82ð
\8bæ
\95Ê
\82µ
\82È
\82¢
52 if ( IsWordChar( *p ) )
62 const tchar *wordtail = NULL;
63 const tchar *wordprev = NULL;
65 // pos
\82É
\82 \82é
\92P
\8cê
\82Ìstart
\82Æend
\82ð
\8b\81\82ß
\82é
67 if ( !IsWordChar( *p ) || (alnum && !isalphanum(*p)) ){
68 //
\94ñ
\92P
\8cê
\95¶
\8e\9a
69 if ( orgp + pos < p ){
70 //
\92P
\8cê
\82Ì
\8fI
\82í
\82è
75 if ( _ismbblead(*p) ){
76 //
\93ú
\96{
\8cê
\82Ì
\8fê
\8d\87\82Í
\81A
\92P
\8f\83\82È
\94ñ
\92P
\8cê
\95¶
\8e\9a\82Æ
\82Í
\82Ý
\82È
\82³
\82¸
\81A
77 //
\8dÅ
\8f\89\82©
\82çscan
\82ð
\82â
\82è
\92¼
\82·
98 // wordtop
\82ªpos
\82æ
\82è
\8cã
\82ë
99 if ( (unsigned)wordtop - (about ? 3 : 0) > (unsigned)(orgp + pos) ){
100 //
\92P
\8cê
\82Ì
\8bæ
\90Ø
\82è
\82¾
\82Á
\82½
\81A
\92P
\8cê
\82Ì
\8dÅ
\8f\89\82ªpos
\82æ
\82è
\8cã
\82ë
\82É
\82 \82Á
\82½
101 // about = true
\82Ì
\8fê
\8d\87\82Í
\81A
\82R
\95¶
\8e\9a\95ª
\82Ù
\82Ç
\82¢
\82¢
\82©
\82°
\82ñ
\8d·
\82ð
\91«
\82µ
\82Ä
\82¨
\82
106 // int wordcount = 10; // 10
\8cê
\82Ü
\82Å
107 while ( *p && *p != '.' ){
108 if ( !IsWordChar( *p ) || (alnum && !isalphanum(*p)) ){
110 if ( --wordcount == 0 )
128 start = STR_DIFF( wordtop, orgp );
129 end = STR_DIFF( wordtail, orgp );
133 prevstart = STR_DIFF( wordprev, orgp );
140 bool mbGetWord( const tchar *str, int pos, int &start, int &end, bool fLongest, int wordcount )
143 const tchar *sp = str + pos;
145 if ( !mbIsWordChar( c ) )
148 const tchar *orgp = str;
149 const tchar *p = orgp;
150 const tchar *wordtop = p;
151 const tchar *wordtail = NULL;
156 if ( (tuchar)c == 0x00 )
158 if ( !mbIsWordChar( c ) ){
159 if ( orgp + pos < sp ){
172 if ( wordtop > orgp + pos ){
173 //
\92P
\8cê
\82Ì
\8bæ
\90Ø
\82è
\82¾
\82Á
\82½
178 // int wordcount = 10; // 10
\8cê
\82Ü
\82Å
182 if ( (tuchar)c == 0x00 )
186 if ( !mbIsWordChar( c ) ){
188 if ( --wordcount == 0 )
201 start = STR_DIFF( wordtop, orgp );
202 end = STR_DIFF( wordtail, orgp );
205 bool mbIsWordChar( unsigned short c )
208 //
\94¼
\8ap
\95¶
\8e\9a
209 if ( isalphanum( c ) || c == '-' || c == '\'' ||
210 (c >= 0x86 && c <= 0xBF ) )
215 //
\91S
\8ap
\95¶
\8e\9a
217 //
\89p
\90\94\8e\9a\81A
\83J
\83^
\83J
\83i
\81A
\82Ð
\82ç
\82ª
\82È
\81A
\83M
\83\8a\83V
\83\83\81A
\83\8d\83V
\83A
218 (c >= 0x824f && c <= 0x8491) ||
221 //
\83A
\83|
\83X
\83g
\83\8d\83t
\83B
222 (c == CODE_APOSTROPHE)
229 //
\89p
\90\94\8e\9a\82Ì
\94»
\95Ê
230 int isalphanum( tuchar c )
232 if ( c >= _t('A') && c <= _t('Z') ){
235 if ( c >= _t('a') && c <= _t('z') ){
238 if ( c >= _t('0') && c <= _t('9') ){