Mercurial > hg > xemacs-beta
comparison src/symbols.c @ 100:4be1180a9e89 r20-1b2
Import from CVS: tag r20-1b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:15:11 +0200 |
parents | 6a378aca36af |
children | 85ec50267440 |
comparison
equal
deleted
inserted
replaced
99:2d83cbd90d8d | 100:4be1180a9e89 |
---|---|
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 |