/ Check-in [73958060]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Avoid surplus bytes at the end of the keyword string table. Add testcase() macros to make sure all keywords are used during testing. (CVS 6090)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 73958060aaf641d93bede3a42851e5b3451f5432
User & Date: drh 2008-12-31 21:52:41
Context
2009-01-01
04:19
Fix a bug parsing "<expr> AND (abc NEAR def)" in fts3_expr.c. (CVS 6091) check-in: d1a6a2ed user: danielk1977 tags: trunk
2008-12-31
21:52
Avoid surplus bytes at the end of the keyword string table. Add testcase() macros to make sure all keywords are used during testing. (CVS 6090) check-in: 73958060 user: drh tags: trunk
19:27
Fix the name in the documentation of the compile-time macro for enabling FTS3 parenthesis processing. (CVS 6089) check-in: ac8258da user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/mkkeywordhash.c.

    11     11   ** A header comment placed at the beginning of generated code.
    12     12   */
    13     13   static const char zHdr[] = 
    14     14     "/***** This file contains automatically generated code ******\n"
    15     15     "**\n"
    16     16     "** The code in this file has been automatically generated by\n"
    17     17     "**\n"
    18         -  "**     $Header: /home/drh/sqlite/trans/cvs/sqlite/sqlite/tool/mkkeywordhash.c,v 1.35 2008/12/17 17:30:26 danielk1977 Exp $\n"
           18  +  "**     $Header: /home/drh/sqlite/trans/cvs/sqlite/sqlite/tool/mkkeywordhash.c,v 1.36 2008/12/31 21:52:41 drh Exp $\n"
    19     19     "**\n"
    20     20     "** The code in this file implements a function that determines whether\n"
    21     21     "** or not a given identifier is really an SQL keyword.  The same thing\n"
    22     22     "** might be implemented more directly using a hand-written hash table.\n"
    23     23     "** But by using this automatically generated code, the size of the code\n"
    24     24     "** is substantially reduced.  This is important for embedded applications\n"
    25     25     "** on platforms with limited memory.\n"
................................................................................
   481    481       }
   482    482       printf("%s", p->zName);
   483    483       j += p->len;
   484    484     }
   485    485     if( j>0 ){
   486    486       printf("%*s */\n", 74-j, "");
   487    487     }
   488         -  printf("  static const char zText[%d] = {\n", nChar+1);
   489         -  for(i=j=0; i<=k; i++){
          488  +  printf("  static const char zText[%d] = {\n", nChar);
          489  +  zText[nChar] = 0;
          490  +  for(i=j=0; i<k; i++){
   490    491       if( j==0 ){
   491    492         printf("    ");
   492    493       }
   493    494       if( zText[i]==0 ){
   494    495         printf("0");
   495    496       }else{
   496    497         printf("'%c',", zText[i]);
................................................................................
   569    570     printf("  if( n<2 ) return TK_ID;\n");
   570    571     printf("  h = ((charMap(z[0])*4) ^\n"
   571    572            "      (charMap(z[n-1])*3) ^\n"
   572    573            "      n) %% %d;\n", bestSize);
   573    574     printf("  for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){\n");
   574    575     printf("    if( aLen[i]==n &&"
   575    576                      " sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){\n");
          577  +  for(i=0; i<nKeyword; i++){
          578  +    printf("      testcase( i==%d ); /* %s */\n",
          579  +           i, aKeywordTable[i].zTokenType);
          580  +  }
   576    581     printf("      return aCode[i];\n");
   577    582     printf("    }\n");
   578    583     printf("  }\n");
   579    584     printf("  return TK_ID;\n");
   580    585     printf("}\n");
   581    586     printf("int sqlite3KeywordCode(const unsigned char *z, int n){\n");
   582    587     printf("  return keywordCode((char*)z, n);\n");
   583    588     printf("}\n");
   584    589   
   585    590     return 0;
   586    591   }