OLD | NEW |
1 /* | 1 /* |
2 ** 2007 June 22 | 2 ** 2007 June 22 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 int iOut = 0; | 111 int iOut = 0; |
112 | 112 |
113 *ppCursor = 0; | 113 *ppCursor = 0; |
114 | 114 |
115 if( nInput<0 ){ | 115 if( nInput<0 ){ |
116 nInput = strlen(zInput); | 116 nInput = strlen(zInput); |
117 } | 117 } |
118 nChar = nInput+1; | 118 nChar = nInput+1; |
119 pCsr = (IcuCursor *)sqlite3_malloc( | 119 pCsr = (IcuCursor *)sqlite3_malloc( |
120 sizeof(IcuCursor) + /* IcuCursor */ | 120 sizeof(IcuCursor) + /* IcuCursor */ |
121 (nChar+1) * sizeof(int) + /* IcuCursor.aOffset[] */ | 121 ((nChar+3)&~3) * sizeof(UChar) + /* IcuCursor.aChar[] */ |
122 nChar * sizeof(UChar) /* IcuCursor.aChar[] */ | 122 (nChar+1) * sizeof(int) /* IcuCursor.aOffset[] */ |
123 ); | 123 ); |
124 if( !pCsr ){ | 124 if( !pCsr ){ |
125 return SQLITE_NOMEM; | 125 return SQLITE_NOMEM; |
126 } | 126 } |
127 memset(pCsr, 0, sizeof(IcuCursor)); | 127 memset(pCsr, 0, sizeof(IcuCursor)); |
128 pCsr->aOffset = (int *)&pCsr[1]; | 128 pCsr->aChar = (UChar *)&pCsr[1]; |
129 pCsr->aChar = (UChar *)&pCsr->aOffset[nChar+1]; | 129 pCsr->aOffset = (int *)&pCsr->aChar[(nChar+3)&~3]; |
130 | 130 |
131 pCsr->aOffset[iOut] = iInput; | 131 pCsr->aOffset[iOut] = iInput; |
132 U8_NEXT(zInput, iInput, nInput, c); | 132 U8_NEXT(zInput, iInput, nInput, c); |
133 while( c>0 ){ | 133 while( c>0 ){ |
134 int isError = 0; | 134 int isError = 0; |
135 c = u_foldCase(c, opt); | 135 c = u_foldCase(c, opt); |
136 U16_APPEND(pCsr->aChar, iOut, nChar, c, isError); | 136 U16_APPEND(pCsr->aChar, iOut, nChar, c, isError); |
137 if( isError ){ | 137 if( isError ){ |
138 sqlite3_free(pCsr); | 138 sqlite3_free(pCsr); |
139 return SQLITE_ERROR; | 139 return SQLITE_ERROR; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 ** Set *ppModule to point at the implementation of the ICU tokenizer. | 251 ** Set *ppModule to point at the implementation of the ICU tokenizer. |
252 */ | 252 */ |
253 void sqlite3Fts2IcuTokenizerModule( | 253 void sqlite3Fts2IcuTokenizerModule( |
254 sqlite3_tokenizer_module const**ppModule | 254 sqlite3_tokenizer_module const**ppModule |
255 ){ | 255 ){ |
256 *ppModule = &icuTokenizerModule; | 256 *ppModule = &icuTokenizerModule; |
257 } | 257 } |
258 | 258 |
259 #endif /* defined(SQLITE_ENABLE_ICU) */ | 259 #endif /* defined(SQLITE_ENABLE_ICU) */ |
260 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */ | 260 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */ |
OLD | NEW |