1 # $MirOS: src/bin/mksh/dot.mkshrc,v 1.88 2014/01/11 18:09:39 tg Exp $
3 # Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010,
4 # 2011, 2012, 2013, 2014
5 # Thorsten Glaser <tg@mirbsd.org>
7 # Provided that these terms and disclaimer and all copyright notices
8 # are retained or reproduced in an accompanying document, permission
9 # is granted to deal in this work without restriction, including un-
10 # limited rights to use, publicly perform, distribute, sell, modify,
11 # merge, give away, or sublicence.
13 # This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
14 # the utmost extent permitted by applicable law, neither express nor
15 # implied; without malicious intent or gross negligence. In no event
16 # may a licensor, author or contributor be held liable for indirect,
17 # direct, other damage, loss, or other issues arising in any way out
18 # of dealing in the work, even if advised of the possibility of such
19 # damage or existence of a defect, except proven that it results out
20 # of said person's immediate fault when using the work as intended.
22 # Better Avalanche for the Jenkins Hash
23 typeset -Z11 -Uui16 Lbafh_v
28 [[ -o utf8-mode ]]; local u=$?
37 local -i i=0 n=${#s[*]}
40 ((# Lbafh_v = (Lbafh_v + s[i++] + 1) * 1025 ))
41 ((# Lbafh_v ^= Lbafh_v >> 6 ))
46 function Lbafh_finish {
49 ((# t = (((Lbafh_v >> 7) & 0x01010101) * 0x1B) ^ \
50 ((Lbafh_v << 1) & 0xFEFEFEFE) ))
51 ((# Lbafh_v = t ^ (t >>> 8) ^ (Lbafh_v >>> 8) ^ \
52 (Lbafh_v >>> 16) ^ (Lbafh_v >>> 24) ))