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

Unified Diff: third_party/sqlite/src/tool/mkkeywordhash.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/tool/mkautoconfamal.sh ('k') | third_party/sqlite/src/tool/mkmsvcmin.tcl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/tool/mkkeywordhash.c
diff --git a/third_party/sqlite/src/tool/mkkeywordhash.c b/third_party/sqlite/src/tool/mkkeywordhash.c
index 003ed7d66eff0debe8492e6c2fed5ca758b8f6ea..7e5287ea5437e5a84890ab2ca9f2d4dc34b534f5 100644
--- a/third_party/sqlite/src/tool/mkkeywordhash.c
+++ b/third_party/sqlite/src/tool/mkkeywordhash.c
@@ -277,7 +277,10 @@ static Keyword aKeywordTable[] = {
/* Number of keywords */
static int nKeyword = (sizeof(aKeywordTable)/sizeof(aKeywordTable[0]));
-/* Map all alphabetic characters into the same case */
+/* Map all alphabetic characters into lower-case for hashing. This is
+** only valid for alphabetics. In particular it does not work for '_'
+** and so the hash cannot be on a keyword position that might be an '_'.
+*/
#define charMap(X) (0x20|(X))
/*
@@ -565,20 +568,28 @@ int main(int argc, char **argv){
}
printf("%s };\n", j==0 ? "" : "\n");
- printf(" int h, i;\n");
+ printf(" int i, j;\n");
+ printf(" const char *zKW;\n");
printf(" if( n>=2 ){\n");
- printf(" h = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n) %% %d;\n",
+ printf(" i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n) %% %d;\n",
bestSize);
- printf(" for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){\n");
- printf(" if( aLen[i]==n &&"
- " sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){\n");
+ printf(" for(i=((int)aHash[i])-1; i>=0; i=((int)aNext[i])-1){\n");
+ printf(" if( aLen[i]!=n ) continue;\n");
+ printf(" j = 0;\n");
+ printf(" zKW = &zText[aOffset[i]];\n");
+ printf("#ifdef SQLITE_ASCII\n");
+ printf(" while( j<n && (z[j]&~0x20)==zKW[j] ){ j++; }\n");
+ printf("#endif\n");
+ printf("#ifdef SQLITE_EBCDIC\n");
+ printf(" while( j<n && toupper(z[j])==zKW[j] ){ j++; }\n");
+ printf("#endif\n");
+ printf(" if( j<n ) continue;\n");
for(i=0; i<nKeyword; i++){
- printf(" testcase( i==%d ); /* %s */\n",
+ printf(" testcase( i==%d ); /* %s */\n",
i, aKeywordTable[i].zOrigName);
}
- printf(" *pType = aCode[i];\n");
- printf(" break;\n");
- printf(" }\n");
+ printf(" *pType = aCode[i];\n");
+ printf(" break;\n");
printf(" }\n");
printf(" }\n");
printf(" return n;\n");
« no previous file with comments | « third_party/sqlite/src/tool/mkautoconfamal.sh ('k') | third_party/sqlite/src/tool/mkmsvcmin.tcl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698