/ Check-in [3b02df27]
Login

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

Overview
Comment:Force all qsort() calls in mkkeywordhash.c to be stable so that we get predictable results on different platforms.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3b02df27ab63936226a90098d88535ed19c2b782
User & Date: drh 2009-11-03 13:08:17
Context
2009-11-03
19:18
Enhancements to lemon to generate more compact action tables and to avoid making array bounds tests that can never fail on action table calculations. check-in: 27d8e684 user: drh tags: trunk
13:08
Force all qsort() calls in mkkeywordhash.c to be stable so that we get predictable results on different platforms. check-in: 3b02df27 user: drh tags: trunk
13:02
Adjust the lemon implementation so that it always computes the same PDA regardless of qsort() implementation on the host platform. In other words, make all sorts in lemon stable. check-in: d66a0f31 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/mkkeywordhash.c.

    12     12   ** A header comment placed at the beginning of generated code.
    13     13   */
    14     14   static const char zHdr[] = 
    15     15     "/***** This file contains automatically generated code ******\n"
    16     16     "**\n"
    17     17     "** The code in this file has been automatically generated by\n"
    18     18     "**\n"
    19         -  "**     $Header: /home/drh/sqlite/trans/cvs/sqlite/sqlite/tool/mkkeywordhash.c,v 1.38 2009/06/09 14:27:41 drh Exp $\n"
           19  +  "**   sqlite/tool/mkkeywordhash.c\n"
    20     20     "**\n"
    21     21     "** The code in this file implements a function that determines whether\n"
    22     22     "** or not a given identifier is really an SQL keyword.  The same thing\n"
    23     23     "** might be implemented more directly using a hand-written hash table.\n"
    24     24     "** But by using this automatically generated code, the size of the code\n"
    25     25     "** is substantially reduced.  This is important for embedded applications\n"
    26     26     "** on platforms with limited memory.\n"
................................................................................
   297    297   static int keywordCompare1(const void *a, const void *b){
   298    298     const Keyword *pA = (Keyword*)a;
   299    299     const Keyword *pB = (Keyword*)b;
   300    300     int n = pA->len - pB->len;
   301    301     if( n==0 ){
   302    302       n = strcmp(pA->zName, pB->zName);
   303    303     }
          304  +  assert( n!=0 );
   304    305     return n;
   305    306   }
   306    307   static int keywordCompare2(const void *a, const void *b){
   307    308     const Keyword *pA = (Keyword*)a;
   308    309     const Keyword *pB = (Keyword*)b;
   309    310     int n = pB->longestSuffix - pA->longestSuffix;
   310    311     if( n==0 ){
   311    312       n = strcmp(pA->zName, pB->zName);
   312    313     }
          314  +  assert( n!=0 );
   313    315     return n;
   314    316   }
   315    317   static int keywordCompare3(const void *a, const void *b){
   316    318     const Keyword *pA = (Keyword*)a;
   317    319     const Keyword *pB = (Keyword*)b;
   318    320     int n = pA->offset - pB->offset;
          321  +  if( n==0 ) n = pB->id - pA->id;
          322  +  assert( n!=0 );
   319    323     return n;
   320    324   }
   321    325   
   322    326   /*
   323    327   ** Return a KeywordTable entry with the given id
   324    328   */
   325    329   static Keyword *findById(int id){