Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Unified Diff: third_party/sqlite/src/ext/fts3/fts3_porter.c

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/ext/fts3/fts3_hash.c ('k') | third_party/sqlite/src/ext/fts3/fts3_snippet.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/ext/fts3/fts3_porter.c
diff --git a/third_party/sqlite/src/ext/fts3/fts3_porter.c b/third_party/sqlite/src/ext/fts3/fts3_porter.c
index 001060c43b32d5bb92f1800e7de14861e0bce817..27f9cf39d7535e4272017df2613f9aba4461f215 100644
--- a/third_party/sqlite/src/ext/fts3/fts3_porter.c
+++ b/third_party/sqlite/src/ext/fts3/fts3_porter.c
@@ -24,6 +24,7 @@
*/
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
+#include "fts3Int.h"
#include <assert.h>
#include <stdlib.h>
@@ -53,10 +54,6 @@ typedef struct porter_tokenizer_cursor {
} porter_tokenizer_cursor;
-/* Forward declaration */
-static const sqlite3_tokenizer_module porterTokenizerModule;
-
-
/*
** Create a new tokenizer instance.
*/
@@ -65,6 +62,10 @@ static int porterCreate(
sqlite3_tokenizer **ppTokenizer
){
porter_tokenizer *t;
+
+ UNUSED_PARAMETER(argc);
+ UNUSED_PARAMETER(argv);
+
t = (porter_tokenizer *) sqlite3_malloc(sizeof(*t));
if( t==NULL ) return SQLITE_NOMEM;
memset(t, 0, sizeof(*t));
@@ -93,6 +94,8 @@ static int porterOpen(
){
porter_tokenizer_cursor *c;
+ UNUSED_PARAMETER(pTokenizer);
+
c = (porter_tokenizer_cursor *) sqlite3_malloc(sizeof(*c));
if( c==NULL ) return SQLITE_NOMEM;
@@ -233,7 +236,7 @@ static int hasVowel(const char *z){
** the first two characters of z[].
*/
static int doubleConsonant(const char *z){
- return isConsonant(z) && z[0]==z[1] && isConsonant(z+1);
+ return isConsonant(z) && z[0]==z[1];
}
/*
@@ -246,10 +249,10 @@ static int doubleConsonant(const char *z){
*/
static int star_oh(const char *z){
return
- z[0]!=0 && isConsonant(z) &&
+ isConsonant(z) &&
z[0]!='w' && z[0]!='x' && z[0]!='y' &&
- z[1]!=0 && isVowel(z+1) &&
- z[2]!=0 && isConsonant(z+2);
+ isVowel(z+1) &&
+ isConsonant(z+2);
}
/*
@@ -293,7 +296,7 @@ static void copy_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){
int i, mx, j;
int hasDigit = 0;
for(i=0; i<nIn; i++){
- int c = zIn[i];
+ char c = zIn[i];
if( c>='A' && c<='Z' ){
zOut[i] = c - 'A' + 'a';
}else{
@@ -337,17 +340,17 @@ static void copy_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){
** no chance of overflowing the zOut buffer.
*/
static void porter_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){
- int i, j, c;
+ int i, j;
char zReverse[28];
char *z, *z2;
- if( nIn<3 || nIn>=sizeof(zReverse)-7 ){
+ if( nIn<3 || nIn>=(int)sizeof(zReverse)-7 ){
/* The word is too big or too small for the porter stemmer.
** Fallback to the copy stemmer */
copy_stemmer(zIn, nIn, zOut, pnOut);
return;
}
for(i=0, j=sizeof(zReverse)-6; i<nIn; i++, j--){
- c = zIn[i];
+ char c = zIn[i];
if( c>='A' && c<='Z' ){
zReverse[j] = c + 'a' - 'A';
}else if( c>='a' && c<='z' ){
@@ -546,7 +549,7 @@ static void porter_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){
/* z[] is now the stemmed word in reverse order. Flip it back
** around into forward order and return.
*/
- *pnOut = i = strlen(z);
+ *pnOut = i = (int)strlen(z);
zOut[i] = 0;
while( *z ){
zOut[--i] = *(z++);
@@ -601,9 +604,11 @@ static int porterNext(
if( c->iOffset>iStartOffset ){
int n = c->iOffset-iStartOffset;
if( n>c->nAllocated ){
+ char *pNew;
c->nAllocated = n+20;
- c->zToken = sqlite3_realloc(c->zToken, c->nAllocated);
- if( c->zToken==NULL ) return SQLITE_NOMEM;
+ pNew = sqlite3_realloc(c->zToken, c->nAllocated);
+ if( !pNew ) return SQLITE_NOMEM;
+ c->zToken = pNew;
}
porter_stemmer(&z[iStartOffset], n, c->zToken, pnBytes);
*pzToken = c->zToken;
« no previous file with comments | « third_party/sqlite/src/ext/fts3/fts3_hash.c ('k') | third_party/sqlite/src/ext/fts3/fts3_snippet.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698