This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

elem_hash.h


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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]