annotate intl/hash-string.h @ 936:311b3f72e7b9

[gaim-migrate @ 946] Sha la la la la la la, mmm, uh huh Was down at the linux expo, starin' at this blue octane, Mr. Flynn strikes up a conversation, with a black haired CS Major. She codes in C while her father hacks, oh, she's suddenly geeky. We all want something geeky, man I wish I was geeky. So come hack in silence down through the morning, sha la la la la la la la, yeah, uhh huh, yeah. Cut up Mark Spencer, show me some of that free software, and pass me a laptop, Mr. Flynn! Believe in me! Help me believe in anything, cuz, I wanna be someone geeky! Mr. Flynn and Me, tell each other linux tales, and we stare at the beautiful penguins, it's lookin' at you, oh no no, it's looking at me. Smiling in the CRT, Mp3's on the stero, when everyone's geeky, you can never be lonely. Well I'm gonna hack a program, syntax highlighting in blue and red and black and grey. All of the beautiful colours are very very meaningingful. Well you know C is my favorite language, I felt so symbolic yesterday. If I knew R. Stallman, I'd buy myself a grey keyboard and hack! Mr. Flynn and me look into the future! We stare at the beautiful Penguins, it's lookin at me, I dont think so, It's looking at me. Hacking in the CRT, I bought myself a grey keyboard, When everbody's geeky, I will never be lonely. I will never be lonely. I'm never gonna be .. loonely. I wanna be a penguin. Eeh -- everybody wanna pass as birds, they all wanna be big big birds, but we got different reasons for that. Believe in me, cuz I don't believe in anything. And I, wanna be someone, geeky, geeky, geeky, yeaaaah! Mr. Flynn and me, storming through the expo, and we stare at the beautiful penguin! It's coming for you, man there's got to be one for me! I wanna be L. Torvalds, Mr. Flynn wishes he was someone just a little more geeky, when everybody loves you, oh son! It's just about as geeky as you can be! Mr. Flynn and me .. starin' at the penguins, when I look at slashdot I wanna see me, staring right back at me. We all wanna be big geeks, but we dont know why and we don't know how .. when everybody loves me I'll be just about as geeky as I can be ... Mr. Flynn and me.. gonna be big geeks. **bows and cheers** Thank You, Thank You. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Sun, 24 Sep 2000 22:48:54 +0000
parents d64101dc5c7e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
347
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /* Implements a string hashing function.
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 Copyright (C) 1995, 1997 Free Software Foundation, Inc.
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 the Free Software Foundation; either version 2, or (at your option)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 any later version.
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 GNU General Public License for more details.
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 You should have received a copy of the GNU Library General Public
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 Boston, MA 02111-1307, USA. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 /* @@ end of prolog @@ */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 #ifndef PARAMS
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 # if __STDC__
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 # define PARAMS(Args) Args
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 # else
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 # define PARAMS(Args) ()
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 # endif
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #endif
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 /* We assume to have `unsigned long int' value with at least 32 bits. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #define HASHWORDBITS 32
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 /* Defines the so called `hashpjw' function by P.J. Weinberger
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 1986, 1987 Bell Telephone Laboratories, Inc.] */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 static unsigned long int hash_string PARAMS ((const char *__str_param));
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 static inline unsigned long int
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 hash_string (str_param)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 const char *str_param;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 {
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 unsigned long int hval, g;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 const char *str = str_param;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 /* Compute the hash value for the given string. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 hval = 0;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 while (*str != '\0')
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 {
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 hval <<= 4;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 hval += (unsigned long int) *str++;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4));
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 if (g != 0)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 {
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 hval ^= g >> (HASHWORDBITS - 8);
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 hval ^= g;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 }
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 }
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 return hval;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 }