Overview
| SHA1 Hash: | aaa2d9b0db74d8452d9294de17cff786ab4ec7c8 |
|---|---|
| Date: | 2012-10-19 02:10:53 |
| User: | drh |
| Comment: | Make sure substructure elements have proper alignment in the ICU tokenizers of FTS2 and FTS3. |
Tags And Properties
- branch=trunk inherited from [704b122e53]
- sym-trunk inherited from [704b122e53]
Changes
Changes to ext/fts2/fts2_icu.c
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 * sizeof(UChar) + /* IcuCursor.aChar[] */ | 121 ((nChar+3)&~3) * sizeof(UChar) + /* IcuCursor.aChar[] */ 122 (nChar+1) * sizeof(int) /* IcuCursor.aOffset[] */ 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->aChar = (UChar *)&pCsr[1]; 128 pCsr->aChar = (UChar *)&pCsr[1]; 129 pCsr->aOffset = (int *)&pCsr->aChar[nChar]; | 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);
Changes to ext/fts3/fts3_icu.c
115 zInput = ""; 115 zInput = ""; 116 }else if( nInput<0 ){ 116 }else if( nInput<0 ){ 117 nInput = strlen(zInput); 117 nInput = strlen(zInput); 118 } 118 } 119 nChar = nInput+1; 119 nChar = nInput+1; 120 pCsr = (IcuCursor *)sqlite3_malloc( 120 pCsr = (IcuCursor *)sqlite3_malloc( 121 sizeof(IcuCursor) + /* IcuCursor */ 121 sizeof(IcuCursor) + /* IcuCursor */ 122 nChar * sizeof(UChar) + /* IcuCursor.aChar[] */ | 122 ((nChar+3)&~3) * sizeof(UChar) + /* IcuCursor.aChar[] */ 123 (nChar+1) * sizeof(int) /* IcuCursor.aOffset[] */ 123 (nChar+1) * sizeof(int) /* IcuCursor.aOffset[] */ 124 ); 124 ); 125 if( !pCsr ){ 125 if( !pCsr ){ 126 return SQLITE_NOMEM; 126 return SQLITE_NOMEM; 127 } 127 } 128 memset(pCsr, 0, sizeof(IcuCursor)); 128 memset(pCsr, 0, sizeof(IcuCursor)); 129 pCsr->aChar = (UChar *)&pCsr[1]; 129 pCsr->aChar = (UChar *)&pCsr[1]; 130 pCsr->aOffset = (int *)&pCsr->aChar[nChar]; | 130 pCsr->aOffset = (int *)&pCsr->aChar[(nChar+3)&~3]; 131 131 132 pCsr->aOffset[iOut] = iInput; 132 pCsr->aOffset[iOut] = iInput; 133 U8_NEXT(zInput, iInput, nInput, c); 133 U8_NEXT(zInput, iInput, nInput, c); 134 while( c>0 ){ 134 while( c>0 ){ 135 int isError = 0; 135 int isError = 0; 136 c = u_foldCase(c, opt); 136 c = u_foldCase(c, opt); 137 U16_APPEND(pCsr->aChar, iOut, nChar, c, isError); 137 U16_APPEND(pCsr->aChar, iOut, nChar, c, isError);