summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclObj.c27
2 files changed, 14 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 718571c..5d205c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-03-31 Donal K. Fellows <donal.k.fellows@man.ac.uk>
+
+ * generic/tclObj.c (HashObjKey): Make sure this hashes the whole
+ string rep of the object, instead of missing the last character.
+
2004-03-29 Jeff Hobbs <jeffh@ActiveState.com>
* generic/tclInt.h:
diff --git a/generic/tclObj.c b/generic/tclObj.c
index a98fe1c..b1183c3 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclObj.c,v 1.42.2.4 2003/05/23 21:29:11 dgp Exp $
+ * RCS: @(#) $Id: tclObj.c,v 1.42.2.5 2004/03/30 23:34:21 dkf Exp $
*/
#include "tclInt.h"
@@ -2717,9 +2717,9 @@ CompareObjKeys(keyPtr, hPtr)
* Don't use Tcl_GetStringFromObj as it would prevent l1 and l2 being
* in a register.
*/
- p1 = Tcl_GetString (objPtr1);
+ p1 = TclGetString(objPtr1);
l1 = objPtr1->length;
- p2 = Tcl_GetString (objPtr2);
+ p2 = TclGetString(objPtr2);
l2 = objPtr2->length;
/*
@@ -2789,14 +2789,11 @@ HashObjKey(tablePtr, keyPtr)
VOID *keyPtr; /* Key from which to compute hash value. */
{
Tcl_Obj *objPtr = (Tcl_Obj *) keyPtr;
- register CONST char *string;
- register int length;
- register unsigned int result;
- register int c;
+ CONST char *string = TclGetString(objPtr);
+ int length = objPtr->length;
+ unsigned int result;
+ int i;
- string = Tcl_GetString (objPtr);
- length = objPtr->length;
-
/*
* I tried a zillion different hash functions and asked many other
* people for advice. Many people had their own favorite functions,
@@ -2814,14 +2811,8 @@ HashObjKey(tablePtr, keyPtr)
*/
result = 0;
- while (length) {
- c = *string;
- string++;
- length--;
- if (length == 0) {
- break;
- }
- result += (result<<3) + c;
+ for (i=0 ; i<length ; i++) {
+ result += (result<<3) + string[i];
}
return result;
}