1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

In the lemon parser generator, change all hashes to unsigned to avoid

potential problems with signed integer overflow.

FossilOrigin-Name: 8d399a03de63c15908d63ed69140ee15c6275b8d
This commit is contained in:
drh
2013-10-02 20:46:30 +00:00
parent e75fb06146
commit 01f75f2d68
3 changed files with 26 additions and 26 deletions

View File

@ -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);