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
17 // numPrev : N
\8cê
\91O
\82Ì
\92P
\8cê
\82ð
\8fE
\82¤
19 bool GetWord( const tchar *str, int pos, int &start, int &end, int &prevstart, bool fLongest, int wordcount, bool about, bool alnum, int numPrev )
22 if ( !IsWordChar( *(str+pos) ) )
24 // while ( *(str+pos) == ' ' || *(str+pos) == '\t' ){
28 //
\89ü
\8ds
\82Ì
\8fê
\8d\87\82Í
\96³
\82µ
29 if ( str[pos] == '\r' || str[pos] == '\n' ){
33 // 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ß //
34 if ( !str[pos] || (!str[pos+1] && ((tuchar)str[pos] < ' ')) )
37 const tchar *orgp = str;
38 const tchar *p = orgp;
40 //
\92P
\8cê
\82Ì
\90æ
\93ª
\82ð
\92T
\82· //
41 const tchar *wordtop = NULL;
44 //
\89p
\90\94\8e\9a\82Ì
\82Ý
45 if ( isalphanum(*p) ){
46 //
\92P
\8cê
\82Ì
\8en
\82Ü
\82è
52 //
\95¶
\8e\9a\8eí
\82ð
\8bæ
\95Ê
\82µ
\82È
\82¢
53 if ( IsWordChar( *p ) )
63 const tchar *wordtail = NULL;
64 const tchar *wordprev = NULL;
65 const tchar *wordprev2 = NULL;
67 // pos
\82É
\82 \82é
\92P
\8cê
\82Ìstart
\82Æend
\82ð
\8b\81\82ß
\82é
69 if ( !IsWordChar( *p ) || (alnum && !isalphanum(*p)) ){
70 //
\94ñ
\92P
\8cê
\95¶
\8e\9a
71 if ( orgp + pos < p ){
72 //
\92P
\8cê
\82Ì
\8fI
\82í
\82è
77 if ( _ismbblead(*p) ){
78 //
\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
79 //
\8dÅ
\8f\89\82©
\82çscan
\82ð
\82â
\82è
\92¼
\82·
101 // wordtop
\82ªpos
\82æ
\82è
\8cã
\82ë
102 if ( (unsigned)wordtop - (about ? 3 : 0) > (unsigned)(orgp + pos) ){
103 //
\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½
104 // 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
109 // int wordcount = 10; // 10
\8cê
\82Ü
\82Å
110 while ( *p && *p != '.' ){
111 if ( !IsWordChar( *p ) || (alnum && !isalphanum(*p)) ){
113 if ( --wordcount == 0 )
131 start = STR_DIFF( wordtop, orgp );
132 end = STR_DIFF( wordtail, orgp );
135 if ( numPrev >= 2 && wordprev2 ){
136 prevstart = STR_DIFF( wordprev2, orgp );
138 if ( numPrev >= 1 && wordprev ){
139 prevstart = STR_DIFF( wordprev, orgp );
146 bool mbGetWord( const tchar *str, int pos, int &start, int &end, bool fLongest, int wordcount )
149 const tchar *sp = str + pos;
151 if ( !mbIsWordChar( c ) )
154 const tchar *orgp = str;
155 const tchar *p = orgp;
156 const tchar *wordtop = p;
157 const tchar *wordtail = NULL;
162 if ( (tuchar)c == 0x00 )
164 if ( !mbIsWordChar( c ) ){
165 if ( orgp + pos < sp ){
178 if ( wordtop > orgp + pos ){
179 //
\92P
\8cê
\82Ì
\8bæ
\90Ø
\82è
\82¾
\82Á
\82½
184 // int wordcount = 10; // 10
\8cê
\82Ü
\82Å
188 if ( (tuchar)c == 0x00 )
192 if ( !mbIsWordChar( c ) ){
194 if ( --wordcount == 0 )
207 start = STR_DIFF( wordtop, orgp );
208 end = STR_DIFF( wordtail, orgp );
211 bool mbIsWordChar( unsigned short c )
214 //
\94¼
\8ap
\95¶
\8e\9a
215 if ( isalphanum( c ) || c == '-' || c == '\'' ||
216 (c >= 0x86 && c <= 0xBF ) )
221 //
\91S
\8ap
\95¶
\8e\9a
223 //
\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
224 (c >= 0x824f && c <= 0x8491) ||
227 //
\83A
\83|
\83X
\83g
\83\8d\83t
\83B
228 (c == CODE_APOSTROPHE)
235 //
\89p
\90\94\8e\9a\82Ì
\94»
\95Ê
236 int isalphanum( tuchar c )
238 if ( c >= _t('A') && c <= _t('Z') ){
241 if ( c >= _t('a') && c <= _t('z') ){
244 if ( c >= _t('0') && c <= _t('9') ){