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

Unified Diff: third_party/sqlite/src/ext/misc/amatch.c

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/icu/icu.c ('k') | third_party/sqlite/src/ext/misc/closure.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/ext/misc/amatch.c
diff --git a/third_party/sqlite/src/ext/misc/amatch.c b/third_party/sqlite/src/ext/misc/amatch.c
index d869dbd8d1394af672f96a5508d9e5ab91a2934f..852491988aa0e606e91928569977e1d0a7765037 100644
--- a/third_party/sqlite/src/ext/misc/amatch.c
+++ b/third_party/sqlite/src/ext/misc/amatch.c
@@ -398,7 +398,7 @@ static amatch_avl *amatchAvlInsert(amatch_avl **ppHead, amatch_avl *pNew){
*/
static void amatchAvlRemove(amatch_avl **ppHead, amatch_avl *pOld){
amatch_avl **ppParent;
- amatch_avl *pBalance;
+ amatch_avl *pBalance = 0;
/* assert( amatchAvlSearch(*ppHead, pOld->zKey)==pOld ); */
ppParent = amatchAvlFromPtr(pOld, ppHead);
if( pOld->pBefore==0 && pOld->pAfter==0 ){
@@ -816,10 +816,10 @@ static const char *amatchValueOfKey(const char *zKey, const char *zStr){
int i;
if( nStr<nKey+1 ) return 0;
if( memcmp(zStr, zKey, nKey)!=0 ) return 0;
- for(i=nKey; isspace(zStr[i]); i++){}
+ for(i=nKey; isspace((unsigned char)zStr[i]); i++){}
if( zStr[i]!='=' ) return 0;
i++;
- while( isspace(zStr[i]) ){ i++; }
+ while( isspace((unsigned char)zStr[i]) ){ i++; }
return zStr+i;
}
@@ -998,6 +998,23 @@ static void amatchWriteCost(amatch_word *pWord){
pWord->zCost[8] = 0;
}
+/* Circumvent compiler warnings about the use of strcpy() by supplying
+** our own implementation.
+*/
+#if defined(__OpenBSD__)
+static void amatchStrcpy(char *dest, const char *src){
+ while( (*(dest++) = *(src++))!=0 ){}
+}
+static void amatchStrcat(char *dest, const char *src){
+ while( *dest ) dest++;
+ amatchStrcpy(dest, src);
+}
+#else
+# define amatchStrcpy strcpy
+# define amatchStrcat strcat
+#endif
+
+
/*
** Add a new amatch_word object to the queue.
**
@@ -1073,7 +1090,7 @@ static void amatchAddWord(
assert( pOther==0 ); (void)pOther;
pWord->sWord.zKey = pWord->zWord;
pWord->sWord.pWord = pWord;
- strcpy(pWord->zWord, pCur->zBuf);
+ amatchStrcpy(pWord->zWord, pCur->zBuf);
pOther = amatchAvlInsert(&pCur->pWord, &pWord->sWord);
assert( pOther==0 ); (void)pOther;
#ifdef AMATCH_TRACE_1
@@ -1083,6 +1100,7 @@ static void amatchAddWord(
#endif
}
+
/*
** Advance a cursor to its next row of output
*/
@@ -1148,7 +1166,7 @@ static int amatchNext(sqlite3_vtab_cursor *cur){
zBuf = sqlite3_realloc(zBuf, nBuf);
if( zBuf==0 ) return SQLITE_NOMEM;
}
- strcpy(zBuf, pWord->zWord+2);
+ amatchStrcpy(zBuf, pWord->zWord+2);
zNext[0] = 0;
zNextIn[0] = pCur->zInput[pWord->nMatch];
if( zNextIn[0] ){
@@ -1163,7 +1181,7 @@ static int amatchNext(sqlite3_vtab_cursor *cur){
if( zNextIn[0] && zNextIn[0]!='*' ){
sqlite3_reset(p->pVCheck);
- strcat(zBuf, zNextIn);
+ amatchStrcat(zBuf, zNextIn);
sqlite3_bind_text(p->pVCheck, 1, zBuf, nWord+nNextIn, SQLITE_STATIC);
rc = sqlite3_step(p->pVCheck);
if( rc==SQLITE_ROW ){
@@ -1176,13 +1194,13 @@ static int amatchNext(sqlite3_vtab_cursor *cur){
}
while( 1 ){
- strcpy(zBuf+nWord, zNext);
+ amatchStrcpy(zBuf+nWord, zNext);
sqlite3_reset(p->pVCheck);
sqlite3_bind_text(p->pVCheck, 1, zBuf, -1, SQLITE_TRANSIENT);
rc = sqlite3_step(p->pVCheck);
if( rc!=SQLITE_ROW ) break;
zW = (const char*)sqlite3_column_text(p->pVCheck, 0);
- strcpy(zBuf+nWord, zNext);
+ amatchStrcpy(zBuf+nWord, zNext);
if( strncmp(zW, zBuf, nWord)!=0 ) break;
if( (zNextIn[0]=='*' && zNextIn[1]==0)
|| (zNextIn[0]==0 && zW[nWord]==0)
« no previous file with comments | « third_party/sqlite/src/ext/icu/icu.c ('k') | third_party/sqlite/src/ext/misc/closure.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698