Mercurial > hg > xemacs-beta
comparison src/symbols.c @ 24:4103f0995bd7 r19-15b95
Import from CVS: tag r19-15b95
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:51:03 +0200 |
parents | 859a2309aef8 |
children | 131b0175ea99 |
comparison
equal
deleted
inserted
replaced
23:0edd3412f124 | 24:4103f0995bd7 |
---|---|
326 break; | 326 break; |
327 } | 327 } |
328 return (make_int (hash)); | 328 return (make_int (hash)); |
329 } | 329 } |
330 | 330 |
331 #if 0 /* Emacs 19.34 */ | |
331 int | 332 int |
332 hash_string (CONST Bufbyte *ptr, Bytecount len) | 333 hash_string (CONST Bufbyte *ptr, Bytecount len) |
333 { | 334 { |
334 CONST Bufbyte *p = ptr; | 335 CONST Bufbyte *p = ptr; |
335 CONST Bufbyte *end = p + len; | 336 CONST Bufbyte *end = p + len; |
339 while (p != end) | 340 while (p != end) |
340 { | 341 { |
341 c = *p++; | 342 c = *p++; |
342 if (c >= 0140) c -= 40; | 343 if (c >= 0140) c -= 40; |
343 hash = ((hash<<3) + (hash>>28) + c); | 344 hash = ((hash<<3) + (hash>>28) + c); |
345 } | |
346 return hash & 07777777777; | |
347 } | |
348 #endif | |
349 | |
350 /* derived from hashpjw, Dragon Book P436. */ | |
351 int | |
352 hash_string (CONST Bufbyte *ptr, Bytecount len) | |
353 { | |
354 CONST Bufbyte *p = ptr; | |
355 int hash = 0, g; | |
356 Bytecount count = len; | |
357 | |
358 while (count-- > 0) | |
359 { | |
360 hash = (hash << 4) + *p++; | |
361 if (g = (hash & 0xf0000000)) { | |
362 hash = hash ^ (g >> 24); | |
363 hash = hash ^ g; | |
364 } | |
344 } | 365 } |
345 return hash & 07777777777; | 366 return hash & 07777777777; |
346 } | 367 } |
347 | 368 |
348 void | 369 void |