From 01f75f2d68a17d52db2aa7c966e2c687b9e75897 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 2 Oct 2013 20:46:30 +0000 Subject: [PATCH] In the lemon parser generator, change all hashes to unsigned to avoid potential problems with signed integer overflow. FossilOrigin-Name: 8d399a03de63c15908d63ed69140ee15c6275b8d --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lemon.c | 38 +++++++++++++++++++------------------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index a90b2c12b9..cce6c31761 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Bring\ssome\sfile\sformat\scomments\sin\sbtreeInt.h\sup\sto\sdate. -D 2013-10-01T20:29:30.106 +C In\sthe\slemon\sparser\sgenerator,\schange\sall\shashes\sto\sunsigned\sto\savoid\npotential\sproblems\swith\ssigned\sinteger\soverflow. +D 2013-10-02T20:46:30.804 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1080,7 +1080,7 @@ F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c 680980c7935bfa1edec20c804c9e5ba4b1dd96f5 +F tool/lemon.c 323e54ac86fb2393f9950219224e304620d2fb12 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkautoconfamal.sh f8d8dbf7d62f409ebed5134998bf5b51d7266383 F tool/mkkeywordhash.c bb52064aa614e1426445e4b2b9b00eeecd23cc79 @@ -1118,7 +1118,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P e0db7b38e1bc0edb1c3995cb23c46488aa6a0909 -R 2a738c8214c86a0fa4841687a9a6b019 +P 012d54d0d2b40888d08915082592ba75d70891c1 +R 38c31151664dc230209e6e8e0d82d69e U drh -Z 1d3a10d5db55bb3286dbd9e3921936ff +Z 767364e5a4324e897c21661eb6e99a80 diff --git a/manifest.uuid b/manifest.uuid index 7c054883ad..f340f41c8d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -012d54d0d2b40888d08915082592ba75d70891c1 \ No newline at end of file +8d399a03de63c15908d63ed69140ee15c6275b8d \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index f63e76facb..ac08250220 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -3391,7 +3391,7 @@ void print_stack_union( int maxdtlength; /* Maximum length of any ".datatype" field. */ char *stddt; /* Standardized name for a datatype */ int i,j; /* Loop counters */ - int hash; /* For hashing the name of a type */ + unsigned hash; /* For hashing the name of a type */ const char *name; /* Name of the parser */ /* Allocate and initialize types[] and allocate stddt[] */ @@ -4234,10 +4234,10 @@ int SetUnion(char *s1, char *s2) ** Code for processing tables in the LEMON parser generator. */ -PRIVATE int strhash(const char *x) +PRIVATE unsigned strhash(const char *x) { - int h = 0; - while( *x) h = h*13 + *(x++); + unsigned h = 0; + while( *x ) h = h*13 + *(x++); return h; } @@ -4309,8 +4309,8 @@ void Strsafe_init(){ int Strsafe_insert(const char *data) { x1node *np; - int h; - int ph; + unsigned h; + unsigned ph; if( x1a==0 ) return 0; ph = strhash(data); @@ -4364,7 +4364,7 @@ int Strsafe_insert(const char *data) ** if no such key. */ const char *Strsafe_find(const char *key) { - int h; + unsigned h; x1node *np; if( x1a==0 ) return 0; @@ -4475,8 +4475,8 @@ void Symbol_init(){ int Symbol_insert(struct symbol *data, const char *key) { x2node *np; - int h; - int ph; + unsigned h; + unsigned ph; if( x2a==0 ) return 0; ph = strhash(key); @@ -4532,7 +4532,7 @@ int Symbol_insert(struct symbol *data, const char *key) ** if no such key. */ struct symbol *Symbol_find(const char *key) { - int h; + unsigned h; x2node *np; if( x2a==0 ) return 0; @@ -4606,9 +4606,9 @@ PRIVATE int statecmp(struct config *a, struct config *b) } /* Hash a state */ -PRIVATE int statehash(struct config *a) +PRIVATE unsigned statehash(struct config *a) { - int h=0; + unsigned h=0; while( a ){ h = h*571 + a->rp->index*37 + a->dot; a = a->bp; @@ -4674,8 +4674,8 @@ void State_init(){ int State_insert(struct state *data, struct config *key) { x3node *np; - int h; - int ph; + unsigned h; + unsigned ph; if( x3a==0 ) return 0; ph = statehash(key); @@ -4731,7 +4731,7 @@ int State_insert(struct state *data, struct config *key) ** if no such key. */ struct state *State_find(struct config *key) { - int h; + unsigned h; x3node *np; if( x3a==0 ) return 0; @@ -4761,9 +4761,9 @@ struct state **State_arrayof() } /* Hash a configuration */ -PRIVATE int confighash(struct config *a) +PRIVATE unsigned confighash(struct config *a) { - int h=0; + unsigned h=0; h = h*571 + a->rp->index*37 + a->dot; return h; } @@ -4816,8 +4816,8 @@ void Configtable_init(){ int Configtable_insert(struct config *data) { x4node *np; - int h; - int ph; + unsigned h; + unsigned ph; if( x4a==0 ) return 0; ph = confighash(data);