diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/misc/st/st.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/misc/st/st.c b/src/misc/st/st.c index cbdac8be..b54509d6 100644 --- a/src/misc/st/st.c +++ b/src/misc/st/st.c @@ -448,14 +448,13 @@ int int st__strhash(const char *string, int modulus) { - int val = 0; - int c; - - while ((c = *string++) != '\0') { - val = val*997 + c; + unsigned char * ustring = (unsigned char *)string; + unsigned c, val = 0; + assert( modulus > 0 ); + while ((c = *ustring++) != '\0') { + val = val*997 + c; } - - return ((val < 0) ? -val : val)%modulus; + return (int)(val%modulus); } int |