| 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 #include <assert.h> | 8 #include <assert.h> |
| 9 #if !defined(__APPLE__) | 9 #if !defined(__APPLE__) |
| 10 #include <malloc.h> | 10 #include <malloc.h> |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 int n = (int) strcspn(c->pCurrent, t->zDelim); | 131 int n = (int) strcspn(c->pCurrent, t->zDelim); |
| 132 if( n>0 ){ | 132 if( n>0 ){ |
| 133 if( n+1>c->nTokenAllocated ){ | 133 if( n+1>c->nTokenAllocated ){ |
| 134 c->zToken = realloc(c->zToken, n+1); | 134 c->zToken = realloc(c->zToken, n+1); |
| 135 } | 135 } |
| 136 for(ii=0; ii<n; ii++){ | 136 for(ii=0; ii<n; ii++){ |
| 137 /* TODO(shess) This needs expansion to handle UTF-8 | 137 /* TODO(shess) This needs expansion to handle UTF-8 |
| 138 ** case-insensitivity. | 138 ** case-insensitivity. |
| 139 */ | 139 */ |
| 140 char ch = c->pCurrent[ii]; | 140 char ch = c->pCurrent[ii]; |
| 141 c->zToken[ii] = ((ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch); | 141 c->zToken[ii] = (unsigned char)ch<0x80 ? tolower(ch) : ch; |
| 142 } | 142 } |
| 143 c->zToken[n] = '\0'; | 143 c->zToken[n] = '\0'; |
| 144 *ppToken = c->zToken; | 144 *ppToken = c->zToken; |
| 145 *pnBytes = n; | 145 *pnBytes = n; |
| 146 *piStartOffset = (int) (c->pCurrent-c->pInput); | 146 *piStartOffset = (int) (c->pCurrent-c->pInput); |
| 147 *piEndOffset = *piStartOffset+n; | 147 *piEndOffset = *piStartOffset+n; |
| 148 *piPosition = c->iToken++; | 148 *piPosition = c->iToken++; |
| 149 c->pCurrent += n + 1; | 149 c->pCurrent += n + 1; |
| 150 | 150 |
| 151 return SQLITE_OK; | 151 return SQLITE_OK; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 165 simpleOpen, | 165 simpleOpen, |
| 166 simpleClose, | 166 simpleClose, |
| 167 simpleNext, | 167 simpleNext, |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 void get_simple_tokenizer_module( | 170 void get_simple_tokenizer_module( |
| 171 sqlite3_tokenizer_module **ppModule | 171 sqlite3_tokenizer_module **ppModule |
| 172 ){ | 172 ){ |
| 173 *ppModule = &simpleTokenizerModule; | 173 *ppModule = &simpleTokenizerModule; |
| 174 } | 174 } |
| OLD | NEW |