| OLD | NEW |
| 1 /* fts2 has a design flaw which can lead to database corruption (see | 1 /* fts2 has a design flaw which can lead to database corruption (see |
| 2 ** below). It is recommended not to use it any longer, instead use | 2 ** below). It is recommended not to use it any longer, instead use |
| 3 ** fts3 (or higher). If you believe that your use of fts2 is safe, | 3 ** fts3 (or higher). If you believe that your use of fts2 is safe, |
| 4 ** add -DSQLITE_ENABLE_BROKEN_FTS2=1 to your CFLAGS. | 4 ** add -DSQLITE_ENABLE_BROKEN_FTS2=1 to your CFLAGS. |
| 5 */ | 5 */ |
| 6 #if (!defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2)) \ | 6 #if (!defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2)) \ |
| 7 && !defined(SQLITE_ENABLE_BROKEN_FTS2) | 7 && !defined(SQLITE_ENABLE_BROKEN_FTS2) |
| 8 #error fts2 has a design flaw and has been deprecated. | 8 #error fts2 has a design flaw and has been deprecated. |
| 9 #endif | 9 #endif |
| 10 /* The flaw is that fts2 uses the content table's unaliased rowid as | 10 /* The flaw is that fts2 uses the content table's unaliased rowid as |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) | 313 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) |
| 314 | 314 |
| 315 #if defined(SQLITE_ENABLE_FTS2) && !defined(SQLITE_CORE) | 315 #if defined(SQLITE_ENABLE_FTS2) && !defined(SQLITE_CORE) |
| 316 # define SQLITE_CORE 1 | 316 # define SQLITE_CORE 1 |
| 317 #endif | 317 #endif |
| 318 | 318 |
| 319 #include <assert.h> | 319 #include <assert.h> |
| 320 #include <stdlib.h> | 320 #include <stdlib.h> |
| 321 #include <stdio.h> | 321 #include <stdio.h> |
| 322 #include <string.h> | 322 #include <string.h> |
| 323 #include <ctype.h> | |
| 324 | |
| 325 #include "fts2.h" | 323 #include "fts2.h" |
| 326 #include "fts2_hash.h" | 324 #include "fts2_hash.h" |
| 327 #include "fts2_tokenizer.h" | 325 #include "fts2_tokenizer.h" |
| 328 #include "sqlite3.h" | 326 #include "sqlite3.h" |
| 329 #ifndef SQLITE_CORE | 327 #ifndef SQLITE_CORE |
| 330 # include "sqlite3ext.h" | 328 # include "sqlite3ext.h" |
| 331 SQLITE_EXTENSION_INIT1 | 329 SQLITE_EXTENSION_INIT1 |
| 332 #endif | 330 #endif |
| 333 | 331 |
| 334 | 332 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 364 /* It is not safe to call isspace(), tolower(), or isalnum() on | 362 /* It is not safe to call isspace(), tolower(), or isalnum() on |
| 365 ** hi-bit-set characters. This is the same solution used in the | 363 ** hi-bit-set characters. This is the same solution used in the |
| 366 ** tokenizer. | 364 ** tokenizer. |
| 367 */ | 365 */ |
| 368 /* TODO(shess) The snippet-generation code should be using the | 366 /* TODO(shess) The snippet-generation code should be using the |
| 369 ** tokenizer-generated tokens rather than doing its own local | 367 ** tokenizer-generated tokens rather than doing its own local |
| 370 ** tokenization. | 368 ** tokenization. |
| 371 */ | 369 */ |
| 372 /* TODO(shess) Is __isascii() a portable version of (c&0x80)==0? */ | 370 /* TODO(shess) Is __isascii() a portable version of (c&0x80)==0? */ |
| 373 static int safe_isspace(char c){ | 371 static int safe_isspace(char c){ |
| 374 return (c&0x80)==0 ? isspace(c) : 0; | 372 return c==' ' || c=='\t' || c=='\n' || c=='\r' || c=='\v' || c=='\f'; |
| 375 } | 373 } |
| 376 static int safe_tolower(char c){ | 374 static int safe_tolower(char c){ |
| 377 return (c>='A' && c<='Z') ? (c-'A'+'a') : c; | 375 return (c>='A' && c<='Z') ? (c - 'A' + 'a') : c; |
| 378 } | 376 } |
| 379 static int safe_isalnum(char c){ | 377 static int safe_isalnum(char c){ |
| 380 return (c&0x80)==0 ? isalnum(c) : 0; | 378 return (c>='0' && c<='9') || (c>='A' && c<='Z') || (c>='a' && c<='z'); |
| 381 } | 379 } |
| 382 | 380 |
| 383 typedef enum DocListType { | 381 typedef enum DocListType { |
| 384 DL_DOCIDS, /* docids only */ | 382 DL_DOCIDS, /* docids only */ |
| 385 DL_POSITIONS, /* docids + positions */ | 383 DL_POSITIONS, /* docids + positions */ |
| 386 DL_POSITIONS_OFFSETS /* docids + positions + offsets */ | 384 DL_POSITIONS_OFFSETS /* docids + positions + offsets */ |
| 387 } DocListType; | 385 } DocListType; |
| 388 | 386 |
| 389 /* | 387 /* |
| 390 ** By default, only positions and not offsets are stored in the doclists. | 388 ** By default, only positions and not offsets are stored in the doclists. |
| (...skipping 6891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7282 sqlite3 *db, | 7280 sqlite3 *db, |
| 7283 char **pzErrMsg, | 7281 char **pzErrMsg, |
| 7284 const sqlite3_api_routines *pApi | 7282 const sqlite3_api_routines *pApi |
| 7285 ){ | 7283 ){ |
| 7286 SQLITE_EXTENSION_INIT2(pApi) | 7284 SQLITE_EXTENSION_INIT2(pApi) |
| 7287 return sqlite3Fts2Init(db); | 7285 return sqlite3Fts2Init(db); |
| 7288 } | 7286 } |
| 7289 #endif | 7287 #endif |
| 7290 | 7288 |
| 7291 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */ | 7289 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */ |
| OLD | NEW |