From: shaneh Date: Thu, 3 Dec 2009 06:26:46 +0000 (+0000) Subject: Updates to FTS3 to correct compiler warnings under MSVC. X-Git-Tag: version-3.7.2~760 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e585b8f05c082fbf38c29c38df86d3466f56b5b6;p=thirdparty%2Fsqlite.git Updates to FTS3 to correct compiler warnings under MSVC. FossilOrigin-Name: 37495b55ffbdc2db4482367ac7d8e32d4d71d58e --- diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 7df7803371..ad3cf6f773 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -447,7 +447,7 @@ void sqlite3Fts3Dequote(char *z){ for(i=1, j=0; z[i]; i++){ if( z[i]==quote ){ if( z[i+1]==quote ){ - z[j++] = quote; + z[j++] = (char)quote; i++; }else{ z[j++] = 0; @@ -653,8 +653,8 @@ int fts3InitVtab( const char *zTokenizer = 0; /* Name of tokenizer to use */ sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */ - nDb = strlen(argv[1]) + 1; - nName = strlen(argv[2]) + 1; + nDb = (int)strlen(argv[1]) + 1; + nName = (int)strlen(argv[2]) + 1; for(i=3; inOutput + nDoclist; char *aNew = sqlite3_malloc(nNew); + UNUSED_PARAMETER(p); + UNUSED_PARAMETER(zTerm); + UNUSED_PARAMETER(nTerm); + if( !aNew ){ return SQLITE_NOMEM; } @@ -1798,6 +1804,9 @@ static int fts3FilterMethod( Fts3Table *p = (Fts3Table *)pCursor->pVtab; Fts3Cursor *pCsr = (Fts3Cursor *)pCursor; + UNUSED_PARAMETER(idxStr); + UNUSED_PARAMETER(nVal); + assert( idxNum>=0 && idxNum<=(FTS3_FULLTEXT_SEARCH+p->nColumn) ); assert( nVal==0 || nVal==1 ); assert( (nVal==0)==(idxNum==FTS3_FULLSCAN_SEARCH) ); @@ -1820,7 +1829,7 @@ static int fts3FilterMethod( sqlite3_free(zSql); } if( rc!=SQLITE_OK ) return rc; - pCsr->eSearch = idxNum; + pCsr->eSearch = (i16)idxNum; if( idxNum==FTS3_DOCID_SEARCH ){ rc = sqlite3_bind_value(pCsr->pStmt, 1, apVal[0]); @@ -1930,6 +1939,7 @@ static int fts3SyncMethod(sqlite3_vtab *pVtab){ ** Implementation of xBegin() method. This is a no-op. */ static int fts3BeginMethod(sqlite3_vtab *pVtab){ + UNUSED_PARAMETER(pVtab); assert( ((Fts3Table *)pVtab)->nPendingData==0 ); return SQLITE_OK; } @@ -1940,6 +1950,7 @@ static int fts3BeginMethod(sqlite3_vtab *pVtab){ ** by fts3SyncMethod(). */ static int fts3CommitMethod(sqlite3_vtab *pVtab){ + UNUSED_PARAMETER(pVtab); assert( ((Fts3Table *)pVtab)->nPendingData==0 ); return SQLITE_OK; } @@ -2018,6 +2029,8 @@ static void fts3OffsetsFunc( ){ Fts3Cursor *pCsr; /* Cursor handle passed through apVal[0] */ + UNUSED_PARAMETER(nVal); + assert( nVal==1 ); if( fts3FunctionArg(pContext, "offsets", apVal[0], &pCsr) ) return; assert( pCsr ); @@ -2042,6 +2055,8 @@ static void fts3OptimizeFunc( Fts3Table *p; /* Virtual table handle */ Fts3Cursor *pCursor; /* Cursor handle passed through apVal[0] */ + UNUSED_PARAMETER(nVal); + assert( nVal==1 ); if( fts3FunctionArg(pContext, "optimize", apVal[0], &pCursor) ) return; p = (Fts3Table *)pCursor->base.pVtab; @@ -2082,6 +2097,11 @@ static int fts3FindFunctionMethod( { "optimize", fts3OptimizeFunc }, }; int i; /* Iterator variable */ + + UNUSED_PARAMETER(pVtab); + UNUSED_PARAMETER(nArg); + UNUSED_PARAMETER(ppArg); + for(i=0; ipPhrase->nToken-1):0) * sizeof(struct PhraseToken); @@ -311,7 +311,7 @@ static int getNextNode( int *pnConsumed /* OUT: Number of bytes consumed */ ){ static const struct Fts3Keyword { - char z[4]; /* Keyword text */ + char *z; /* Keyword text */ unsigned char n; /* Length of the keyword */ unsigned char parenOnly; /* Only valid in paren mode */ unsigned char eType; /* Keyword code */ @@ -381,7 +381,7 @@ static int getNextNode( pRet->eType = pKey->eType; pRet->nNear = nNear; *ppExpr = pRet; - *pnConsumed = (zInput - z) + nKey; + *pnConsumed = (int)((zInput - z) + nKey); return SQLITE_OK; } @@ -401,14 +401,14 @@ static int getNextNode( if( rc==SQLITE_OK && !*ppExpr ){ rc = SQLITE_DONE; } - *pnConsumed = (zInput - z) + 1 + nConsumed; + *pnConsumed = (int)((zInput - z) + 1 + nConsumed); return rc; } /* Check for a close bracket. */ if( *zInput==')' ){ pParse->nNest--; - *pnConsumed = (zInput - z) + 1; + *pnConsumed = (int)((zInput - z) + 1); return SQLITE_DONE; } } @@ -420,7 +420,7 @@ static int getNextNode( */ if( *zInput=='"' ){ for(ii=1; iinCol; ii++){ const char *zStr = pParse->azCol[ii]; - int nStr = strlen(zStr); + int nStr = (int)strlen(zStr); if( nInput>nStr && zInput[nStr]==':' && sqlite3_strnicmp(zStr, zInput, nStr)==0 ){ iCol = ii; - iColLen = ((zInput - z) + nStr + 1); + iColLen = (int)((zInput - z) + nStr + 1); break; } } @@ -714,7 +714,7 @@ int sqlite3Fts3ExprParse( return SQLITE_OK; } if( n<0 ){ - n = strlen(z); + n = (int)strlen(z); } rc = fts3ExprParse(&sParse, z, n, ppExpr, &nParsed); @@ -769,7 +769,7 @@ static int queryTestTokenizer( sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC); if( SQLITE_ROW==sqlite3_step(pStmt) ){ if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){ - memcpy(pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp)); + memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp)); } } diff --git a/ext/fts3/fts3_hash.c b/ext/fts3/fts3_hash.c index 4a29604f23..3cb91f3d2c 100644 --- a/ext/fts3/fts3_hash.c +++ b/ext/fts3/fts3_hash.c @@ -56,7 +56,7 @@ static void fts3HashFree(void *p){ ** true if the hash table should make its own private copy of keys and ** false if it should just use the supplied pointer. */ -void sqlite3Fts3HashInit(Fts3Hash *pNew, int keyClass, int copyKey){ +void sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey){ assert( pNew!=0 ); assert( keyClass>=FTS3_HASH_STRING && keyClass<=FTS3_HASH_BINARY ); pNew->keyClass = keyClass; diff --git a/ext/fts3/fts3_hash.h b/ext/fts3/fts3_hash.h index 6080408fb3..b00f365b09 100644 --- a/ext/fts3/fts3_hash.h +++ b/ext/fts3/fts3_hash.h @@ -71,7 +71,7 @@ struct Fts3HashElem { /* ** Access routines. To delete, insert a NULL pointer. */ -void sqlite3Fts3HashInit(Fts3Hash*, int keytype, int copyKey); +void sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey); void *sqlite3Fts3HashInsert(Fts3Hash*, const void *pKey, int nKey, void *pData); void *sqlite3Fts3HashFind(const Fts3Hash*, const void *pKey, int nKey); void sqlite3Fts3HashClear(Fts3Hash*); diff --git a/ext/fts3/fts3_porter.c b/ext/fts3/fts3_porter.c index b9153a48c2..4e68087299 100644 --- a/ext/fts3/fts3_porter.c +++ b/ext/fts3/fts3_porter.c @@ -24,6 +24,7 @@ */ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) +#include "fts3Int.h" #include #include @@ -54,10 +55,6 @@ typedef struct porter_tokenizer_cursor { } porter_tokenizer_cursor; -/* Forward declaration */ -static const sqlite3_tokenizer_module porterTokenizerModule; - - /* ** Create a new tokenizer instance. */ @@ -66,6 +63,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)); @@ -94,6 +95,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; @@ -294,7 +297,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='A' && c<='Z' ){ zOut[i] = c - 'A' + 'a'; }else{ @@ -338,7 +341,7 @@ 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 ){ @@ -348,7 +351,7 @@ static void porter_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){ return; } for(i=0, j=sizeof(zReverse)-6; i='A' && c<='Z' ){ zReverse[j] = c + 'a' - 'A'; }else if( c>='a' && c<='z' ){ @@ -547,7 +550,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++); diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index 935bcecb62..cdc55aff46 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -78,7 +78,7 @@ static void fts3SnippetSbInit(StringBuffer *p){ */ static void fts3SnippetAppend(StringBuffer *p, const char *zNew, int nNew){ if( p->z==0 ) return; - if( nNew<0 ) nNew = strlen(zNew); + if( nNew<0 ) nNew = (int)strlen(zNew); if( p->nUsed + nNew >= p->nAlloc ){ int nAlloc; char *zNew; @@ -155,11 +155,11 @@ static int snippetAppendMatch( } i = p->nMatch++; pMatch = &p->aMatch[i]; - pMatch->iCol = iCol; - pMatch->iTerm = iTerm; + pMatch->iCol = (short)iCol; + pMatch->iTerm = (short)iTerm; pMatch->iToken = iToken; pMatch->iStart = iStart; - pMatch->nByte = nByte; + pMatch->nByte = (short)nByte; return SQLITE_OK; } diff --git a/ext/fts3/fts3_tokenizer.c b/ext/fts3/fts3_tokenizer.c index 4846675266..cab6dcc383 100644 --- a/ext/fts3/fts3_tokenizer.c +++ b/ext/fts3/fts3_tokenizer.c @@ -145,7 +145,7 @@ const char *sqlite3Fts3NextToken(const char *zStr, int *pn){ } } - *pn = (z2-z1); + *pn = (int)(z2-z1); return z1; } @@ -183,7 +183,7 @@ int sqlite3Fts3InitTokenizer( z[n] = '\0'; sqlite3Fts3Dequote(z); - m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, z, strlen(z)+1); + m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, z, (int)strlen(z)+1); if( !m ){ *pzErr = sqlite3_mprintf("unknown tokenizer: %s", z); rc = SQLITE_ERROR; @@ -191,12 +191,12 @@ int sqlite3Fts3InitTokenizer( char const **aArg = 0; int iArg = 0; z = &z[n+1]; - while( zpModule = m; } - sqlite3_free(aArg); + sqlite3_free((void *)aArg); } sqlite3_free(zCopy); @@ -380,7 +380,7 @@ int queryTokenizer( sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC); if( SQLITE_ROW==sqlite3_step(pStmt) ){ if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){ - memcpy(pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp)); + memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp)); } } @@ -417,6 +417,9 @@ static void intTestFunc( const sqlite3_tokenizer_module *p2; sqlite3 *db = (sqlite3 *)sqlite3_user_data(context); + UNUSED_PARAMETER(argc); + UNUSED_PARAMETER(argv); + /* Test the query function */ sqlite3Fts3SimpleTokenizerModule(&p1); rc = queryTokenizer(db, "simple", &p2); @@ -476,13 +479,13 @@ int sqlite3Fts3InitHashTable( } #endif - if( rc!=SQLITE_OK - || (rc = sqlite3_create_function(db, zName, 1, any, p, scalarFunc, 0, 0)) - || (rc = sqlite3_create_function(db, zName, 2, any, p, scalarFunc, 0, 0)) + if( SQLITE_OK!=rc + || SQLITE_OK!=(rc = sqlite3_create_function(db, zName, 1, any, p, scalarFunc, 0, 0)) + || SQLITE_OK!=(rc = sqlite3_create_function(db, zName, 2, any, p, scalarFunc, 0, 0)) #ifdef SQLITE_TEST - || (rc = sqlite3_create_function(db, zTest, 2, any, p, testFunc, 0, 0)) - || (rc = sqlite3_create_function(db, zTest, 3, any, p, testFunc, 0, 0)) - || (rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0)) + || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest, 2, any, p, testFunc, 0, 0)) + || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest, 3, any, p, testFunc, 0, 0)) + || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0)) #endif ); diff --git a/ext/fts3/fts3_tokenizer1.c b/ext/fts3/fts3_tokenizer1.c index da255d95a1..654e55ddec 100644 --- a/ext/fts3/fts3_tokenizer1.c +++ b/ext/fts3/fts3_tokenizer1.c @@ -24,6 +24,7 @@ */ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) +#include "fts3Int.h" #include #include @@ -49,9 +50,6 @@ typedef struct simple_tokenizer_cursor { } simple_tokenizer_cursor; -/* Forward declaration */ -static const sqlite3_tokenizer_module simpleTokenizerModule; - static int simpleDelim(simple_tokenizer *t, unsigned char c){ return c<0x80 && t->delim[c]; } @@ -75,7 +73,7 @@ static int simpleCreate( ** information on the initial create. */ if( argc>1 ){ - int i, n = strlen(argv[1]); + int i, n = (int)strlen(argv[1]); for(i=0; idelim[i] = !isalnum(i); + t->delim[i] = !isalnum(i) ? -1 : 0; } } @@ -118,6 +116,8 @@ static int simpleOpen( ){ simple_tokenizer_cursor *c; + UNUSED_PARAMETER(pTokenizer); + c = (simple_tokenizer_cursor *) sqlite3_malloc(sizeof(*c)); if( c==NULL ) return SQLITE_NOMEM; @@ -191,7 +191,7 @@ static int simpleNext( ** case-insensitivity. */ unsigned char ch = p[iStartOffset+i]; - c->pToken[i] = ch<0x80 ? tolower(ch) : ch; + c->pToken[i] = (char)(ch<0x80 ? tolower(ch) : ch); } *ppToken = c->pToken; *pnBytes = n; diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 7673f2a09e..3a2ed6e166 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -682,14 +682,14 @@ static int fts3SegmentMerge(Fts3Table *, int); static int fts3AllocateSegdirIdx(Fts3Table *p, int iLevel, int *piIdx){ int rc; /* Return Code */ sqlite3_stmt *pNextIdx; /* Query for next idx at level iLevel */ - int iNext; /* Result of query pNextIdx */ + int iNext = 0; /* Result of query pNextIdx */ /* Set variable iNext to the next available segdir index at level iLevel. */ rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pNextIdx, 0); if( rc==SQLITE_OK ){ sqlite3_bind_int(pNextIdx, 1, iLevel); if( SQLITE_ROW==sqlite3_step(pNextIdx) ){ - iNext = sqlite3_column_int64(pNextIdx, 0); + iNext = sqlite3_column_int(pNextIdx, 0); } rc = sqlite3_reset(pNextIdx); } @@ -807,7 +807,7 @@ static void fts3SegReaderNextDocid( */ if( ppOffsetList ){ *ppOffsetList = pReader->pOffsetList; - *pnOffsetList = p - pReader->pOffsetList - 1; + *pnOffsetList = (int)(p - pReader->pOffsetList - 1); } /* If there are no more entries in the doclist, set pOffsetList to @@ -1160,6 +1160,7 @@ static int fts3PrefixCompress( int nNext /* Size of buffer zNext in bytes */ ){ int n; + UNUSED_PARAMETER(nNext); for(n=0; npTree ){ - sqlite3_int64 iLast; /* Largest block id written to database */ + sqlite3_int64 iLast = 0; /* Largest block id written to database */ sqlite3_int64 iLastLeaf; /* Largest leaf block id written to db */ - char *zRoot; /* Pointer to buffer containing root node */ - int nRoot; /* Size of buffer zRoot */ + char *zRoot = NULL; /* Pointer to buffer containing root node */ + int nRoot = 0; /* Size of buffer zRoot */ iLastLeaf = pWriter->iFree; rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, pWriter->nData); @@ -1696,11 +1697,11 @@ static void fts3ColumnFilter( while( p