OLD | NEW |
1 /* | 1 /* |
2 ** The author disclaims copyright to this source code. | 2 ** The author disclaims copyright to this source code. |
3 ** | 3 ** |
4 ************************************************************************* | 4 ************************************************************************* |
5 ** Implementation of the "simple" full-text-search tokenizer. | 5 ** Implementation of the "simple" full-text-search tokenizer. |
6 */ | 6 */ |
7 | 7 |
8 /* | 8 /* |
9 ** The code in this file is only compiled if: | 9 ** The code in this file is only compiled if: |
10 ** | 10 ** |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 if( n>c->nTokenAllocated ){ | 175 if( n>c->nTokenAllocated ){ |
176 c->nTokenAllocated = n+20; | 176 c->nTokenAllocated = n+20; |
177 c->pToken = realloc(c->pToken, c->nTokenAllocated); | 177 c->pToken = realloc(c->pToken, c->nTokenAllocated); |
178 if( c->pToken==NULL ) return SQLITE_NOMEM; | 178 if( c->pToken==NULL ) return SQLITE_NOMEM; |
179 } | 179 } |
180 for(i=0; i<n; i++){ | 180 for(i=0; i<n; i++){ |
181 /* TODO(shess) This needs expansion to handle UTF-8 | 181 /* TODO(shess) This needs expansion to handle UTF-8 |
182 ** case-insensitivity. | 182 ** case-insensitivity. |
183 */ | 183 */ |
184 unsigned char ch = p[iStartOffset+i]; | 184 unsigned char ch = p[iStartOffset+i]; |
185 c->pToken[i] = (ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch; | 185 c->pToken[i] = ch<0x80 ? tolower(ch) : ch; |
186 } | 186 } |
187 *ppToken = c->pToken; | 187 *ppToken = c->pToken; |
188 *pnBytes = n; | 188 *pnBytes = n; |
189 *piStartOffset = iStartOffset; | 189 *piStartOffset = iStartOffset; |
190 *piEndOffset = c->iOffset; | 190 *piEndOffset = c->iOffset; |
191 *piPosition = c->iToken++; | 191 *piPosition = c->iToken++; |
192 | 192 |
193 return SQLITE_OK; | 193 return SQLITE_OK; |
194 } | 194 } |
195 } | 195 } |
(...skipping 16 matching lines...) Expand all Loading... |
212 ** Allocate a new simple tokenizer. Return a pointer to the new | 212 ** Allocate a new simple tokenizer. Return a pointer to the new |
213 ** tokenizer in *ppModule | 213 ** tokenizer in *ppModule |
214 */ | 214 */ |
215 void sqlite3Fts1SimpleTokenizerModule( | 215 void sqlite3Fts1SimpleTokenizerModule( |
216 sqlite3_tokenizer_module const**ppModule | 216 sqlite3_tokenizer_module const**ppModule |
217 ){ | 217 ){ |
218 *ppModule = &simpleTokenizerModule; | 218 *ppModule = &simpleTokenizerModule; |
219 } | 219 } |
220 | 220 |
221 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS1) */ | 221 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS1) */ |
OLD | NEW |