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

Side by Side Diff: third_party/sqlite/src/ext/misc/amatch.c

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/ext/icu/icu.c ('k') | third_party/sqlite/src/ext/misc/carray.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ** 2013-03-14 2 ** 2013-03-14
3 ** 3 **
4 ** The author disclaims copyright to this source code. In place of 4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing: 5 ** a legal notice, here is a blessing:
6 ** 6 **
7 ** May you do good and not evil. 7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others. 8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give. 9 ** May you share freely, never taking more than you give.
10 ** 10 **
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 if( strcmp(zFrom,"?")==0 && strcmp(zTo,"")==0 ){ 618 if( strcmp(zFrom,"?")==0 && strcmp(zTo,"")==0 ){
619 if( p->rDel==0 || p->rDel>rCost ) p->rDel = rCost; 619 if( p->rDel==0 || p->rDel>rCost ) p->rDel = rCost;
620 }else 620 }else
621 { 621 {
622 pRule = sqlite3_malloc( sizeof(*pRule) + nFrom + nTo ); 622 pRule = sqlite3_malloc( sizeof(*pRule) + nFrom + nTo );
623 if( pRule==0 ){ 623 if( pRule==0 ){
624 rc = SQLITE_NOMEM; 624 rc = SQLITE_NOMEM;
625 }else{ 625 }else{
626 memset(pRule, 0, sizeof(*pRule)); 626 memset(pRule, 0, sizeof(*pRule));
627 pRule->zFrom = &pRule->zTo[nTo+1]; 627 pRule->zFrom = &pRule->zTo[nTo+1];
628 pRule->nFrom = nFrom; 628 pRule->nFrom = (amatch_len)nFrom;
629 memcpy(pRule->zFrom, zFrom, nFrom+1); 629 memcpy(pRule->zFrom, zFrom, nFrom+1);
630 memcpy(pRule->zTo, zTo, nTo+1); 630 memcpy(pRule->zTo, zTo, nTo+1);
631 pRule->nTo = nTo; 631 pRule->nTo = (amatch_len)nTo;
632 pRule->rCost = rCost; 632 pRule->rCost = rCost;
633 pRule->iLang = (int)iLang; 633 pRule->iLang = (int)iLang;
634 } 634 }
635 } 635 }
636 636
637 *ppRule = pRule; 637 *ppRule = pRule;
638 return rc; 638 return rc;
639 } 639 }
640 640
641 /* 641 /*
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 assert( pOther==0 ); (void)pOther; 1074 assert( pOther==0 ); (void)pOther;
1075 } 1075 }
1076 return; 1076 return;
1077 } 1077 }
1078 pWord = sqlite3_malloc( sizeof(*pWord) + nBase + nTail - 1 ); 1078 pWord = sqlite3_malloc( sizeof(*pWord) + nBase + nTail - 1 );
1079 if( pWord==0 ) return; 1079 if( pWord==0 ) return;
1080 memset(pWord, 0, sizeof(*pWord)); 1080 memset(pWord, 0, sizeof(*pWord));
1081 pWord->rCost = rCost; 1081 pWord->rCost = rCost;
1082 pWord->iSeq = pCur->nWord++; 1082 pWord->iSeq = pCur->nWord++;
1083 amatchWriteCost(pWord); 1083 amatchWriteCost(pWord);
1084 pWord->nMatch = nMatch; 1084 pWord->nMatch = (short)nMatch;
1085 pWord->pNext = pCur->pAllWords; 1085 pWord->pNext = pCur->pAllWords;
1086 pCur->pAllWords = pWord; 1086 pCur->pAllWords = pWord;
1087 pWord->sCost.zKey = pWord->zCost; 1087 pWord->sCost.zKey = pWord->zCost;
1088 pWord->sCost.pWord = pWord; 1088 pWord->sCost.pWord = pWord;
1089 pOther = amatchAvlInsert(&pCur->pCost, &pWord->sCost); 1089 pOther = amatchAvlInsert(&pCur->pCost, &pWord->sCost);
1090 assert( pOther==0 ); (void)pOther; 1090 assert( pOther==0 ); (void)pOther;
1091 pWord->sWord.zKey = pWord->zWord; 1091 pWord->sWord.zKey = pWord->zWord;
1092 pWord->sWord.pWord = pWord; 1092 pWord->sWord.pWord = pWord;
1093 amatchStrcpy(pWord->zWord, pCur->zBuf); 1093 amatchStrcpy(pWord->zWord, pCur->zBuf);
1094 pOther = amatchAvlInsert(&pCur->pWord, &pWord->sWord); 1094 pOther = amatchAvlInsert(&pCur->pWord, &pWord->sWord);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 pWord = pNode->pWord; 1155 pWord = pNode->pWord;
1156 amatchAvlRemove(&pCur->pCost, &pWord->sCost); 1156 amatchAvlRemove(&pCur->pCost, &pWord->sCost);
1157 1157
1158 #ifdef AMATCH_TRACE_1 1158 #ifdef AMATCH_TRACE_1
1159 printf("PROCESS [%s][%.*s^%s] %d (\"%s\" \"%s\")\n", 1159 printf("PROCESS [%s][%.*s^%s] %d (\"%s\" \"%s\")\n",
1160 pWord->zWord+2, pWord->nMatch, pCur->zInput, pCur->zInput+pWord->nMatch, 1160 pWord->zWord+2, pWord->nMatch, pCur->zInput, pCur->zInput+pWord->nMatch,
1161 pWord->rCost, pWord->zWord, pWord->zCost); 1161 pWord->rCost, pWord->zWord, pWord->zCost);
1162 #endif 1162 #endif
1163 nWord = (int)strlen(pWord->zWord+2); 1163 nWord = (int)strlen(pWord->zWord+2);
1164 if( nWord+20>nBuf ){ 1164 if( nWord+20>nBuf ){
1165 nBuf = nWord+100; 1165 nBuf = (char)(nWord+100);
1166 zBuf = sqlite3_realloc(zBuf, nBuf); 1166 zBuf = sqlite3_realloc(zBuf, nBuf);
1167 if( zBuf==0 ) return SQLITE_NOMEM; 1167 if( zBuf==0 ) return SQLITE_NOMEM;
1168 } 1168 }
1169 amatchStrcpy(zBuf, pWord->zWord+2); 1169 amatchStrcpy(zBuf, pWord->zWord+2);
1170 zNext[0] = 0; 1170 zNext[0] = 0;
1171 zNextIn[0] = pCur->zInput[pWord->nMatch]; 1171 zNextIn[0] = pCur->zInput[pWord->nMatch];
1172 if( zNextIn[0] ){ 1172 if( zNextIn[0] ){
1173 for(i=1; i<=4 && (pCur->zInput[pWord->nMatch+i]&0xc0)==0x80; i++){ 1173 for(i=1; i<=4 && (pCur->zInput[pWord->nMatch+i]&0xc0)==0x80; i++){
1174 zNextIn[i] = pCur->zInput[pWord->nMatch+i]; 1174 zNextIn[i] = pCur->zInput[pWord->nMatch+i];
1175 } 1175 }
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 const sqlite3_api_routines *pApi 1496 const sqlite3_api_routines *pApi
1497 ){ 1497 ){
1498 int rc = SQLITE_OK; 1498 int rc = SQLITE_OK;
1499 SQLITE_EXTENSION_INIT2(pApi); 1499 SQLITE_EXTENSION_INIT2(pApi);
1500 (void)pzErrMsg; /* Not used */ 1500 (void)pzErrMsg; /* Not used */
1501 #ifndef SQLITE_OMIT_VIRTUALTABLE 1501 #ifndef SQLITE_OMIT_VIRTUALTABLE
1502 rc = sqlite3_create_module(db, "approximate_match", &amatchModule, 0); 1502 rc = sqlite3_create_module(db, "approximate_match", &amatchModule, 0);
1503 #endif /* SQLITE_OMIT_VIRTUALTABLE */ 1503 #endif /* SQLITE_OMIT_VIRTUALTABLE */
1504 return rc; 1504 return rc;
1505 } 1505 }
OLDNEW
« no previous file with comments | « third_party/sqlite/src/ext/icu/icu.c ('k') | third_party/sqlite/src/ext/misc/carray.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698