Missing dependencies added.
[AROS-Contrib.git] / rexx / lstring / hashvalu.c
blob90585209857a097e2b9c6e6869dd620099622d55
1 /*
2 * $Header$
3 * $Log$
4 * Revision 1.1 2001/04/04 05:43:37 wang
5 * First commit: compiles on Linux, Amiga, Windows, Windows CE, generic gcc
7 * Revision 1.2 1999/11/26 09:56:55 bnv
8 * Added: Error message fror CE
10 * Revision 1.1 1998/07/02 17:18:00 bnv
11 * Initial Version
15 #include <lstring.h>
17 /* --------------- Lhashvalue ------------------ */
18 word
19 Lhashvalue( const PLstr str )
21 #ifdef WCE
22 # error "Lhashvalue is not used!"
23 #endif
24 word value = 0;
25 size_t i,l = 0;
27 if (LISNULL(*str)) return 0;
29 switch (LTYPE(*str)) {
30 case LINTEGER_TY: l = sizeof(long); break;
31 case LREAL_TY: l = sizeof(double); break;
32 case LSTRING_TY: l = MIN(255,LLEN(*str)); break;
34 for (i=0; i<l; i++) {
35 value ^= LSTR(*str)[i];
36 #ifdef __BORLANDC__
37 value = _rotl(value,1);
38 #else
39 value = ((value>>1) | (value<<7)) & 0xFF;
40 #endif
42 return value;
43 } /* Lhashvalue */