elem_hash.h

Isamu Hasegawa isamu@yamato.ibm.com
Wed Aug 8 21:15:00 GMT 2001


Hello,

In libc/locale/elem-hash.h

> static inline int32_t
> elem_hash (const char *str, int_fast32_t n)
> {
>   int32_t result = n;
> 
>   while (n > 0)
>     {
>       n <<= 3;
>       n += *str++;
>     }
> 
>   return result;
> }

`elem_hash' seems to return just the argument `n'.
It's incorrect behavior, isn't it?
And is the following fix appropriate?

Thanks,
-- 
Isamu Hasegawa
IBM Japan, Ltd.

--- libc/locale/elem-hash.h	Tue Jul 24 13:36:49 2001
+++ libc/locale/elem-hash.h.tmp	Thu Aug  9 13:14:36 2001
@@ -26,8 +26,9 @@
 
   while (n > 0)
     {
-      n <<= 3;
-      n += *str++;
+      result <<= 3;
+      result += *str++;
+      n--;
     }
 
   return result;



More information about the Libc-alpha mailing list