diff options
author | Daniel Caujolle-Bert <f1rmb@users.sourceforge.net> | 2001-12-27 14:30:28 +0000 |
---|---|---|
committer | Daniel Caujolle-Bert <f1rmb@users.sourceforge.net> | 2001-12-27 14:30:28 +0000 |
commit | aff58bf56ef83eb8174400026a5bf8af7f8cc3bd (patch) | |
tree | 988ec00948b2f1548ba6ecfbf290005bca51b29d /intl/hash-string.h | |
parent | d84bc803279874f30108bd6567013151b58f8571 (diff) | |
download | xine-lib-aff58bf56ef83eb8174400026a5bf8af7f8cc3bd.tar.gz xine-lib-aff58bf56ef83eb8174400026a5bf8af7f8cc3bd.tar.bz2 |
Add intl support + more logging messages.
CVS patchset: 1308
CVS date: 2001/12/27 14:30:28
Diffstat (limited to 'intl/hash-string.h')
-rw-r--r-- | intl/hash-string.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/intl/hash-string.h b/intl/hash-string.h new file mode 100644 index 000000000..37d4ce1a2 --- /dev/null +++ b/intl/hash-string.h @@ -0,0 +1,58 @@ +/* Description of GNU message catalog format: string hashing function. + Copyright (C) 1995, 1997, 1998, 2000, 2001 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* @@ end of prolog @@ */ + +#ifndef PARAMS +# if __STDC__ +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +#endif + +/* We assume to have `unsigned long int' value with at least 32 bits. */ +#define HASHWORDBITS 32 + + +/* Defines the so called `hashpjw' function by P.J. Weinberger + [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools, + 1986, 1987 Bell Telephone Laboratories, Inc.] */ +static unsigned long int hash_string PARAMS ((const char *__str_param)); + +static inline unsigned long int +hash_string (str_param) + const char *str_param; +{ + unsigned long int hval, g; + const char *str = str_param; + + /* Compute the hash value for the given string. */ + hval = 0; + while (*str != '\0') + { + hval <<= 4; + hval += (unsigned long int) *str++; + g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4)); + if (g != 0) + { + hval ^= g >> (HASHWORDBITS - 8); + hval ^= g; + } + } + return hval; +} |