Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

tlib#hash#CRC32(): Alternative implementation of crc32 (doesn't work …

…yet)
  • Loading branch information...
commit 28d307311ef41f1f43af0e94efde36b080ba2ed2 1 parent 52ca8d2
@tomtom authored
Showing with 29 additions and 274 deletions.
  1. +29 −274 autoload/tlib/hash.vim
View
303 autoload/tlib/hash.vim
@@ -3,12 +3,12 @@
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2012-12-14.
" @Last Change: 2010-09-26.
-" @Revision: 145
+" @Revision: 187
function! tlib#hash#CRC32(chars) "{{{3
- let rv = ''
- if has('ruby')
+ if 0 && has('ruby')
+ let rv = ''
ruby << EOR
require 'zlib'
VIM::command('let rv = "%08x"' % Zlib.crc32(VIM::evaluate("a:chars")))
@@ -19,282 +19,37 @@ EOR
else
throw "tlib: No implementation for CRC32"
" if !exists('s:crc_table')
- " let s:crc_table = [
- " \ [0],
- " \ [0,1,1,0,1,0,0,1,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0,1,1,1,0,1,1,1],
- " \ [0,0,1,1,0,1,0,0,1,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0,1,1,1,0,1,1,1],
- " \ [0,1,0,1,1,1,0,1,1,0,0,0,1,0,1,0,1,0,0,1,0,0,0,0,1,0,0,1,1,0,0,1],
- " \ [1,0,0,1,1,0,0,0,0,0,1,0,0,0,1,1,1,0,1,1,0,1,1,0,1,1,1],
- " \ [1,1,1,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,1,0,1,1,0,0,0,0,0,1,1,1],
- " \ [1,0,1,0,1,1,0,0,1,0,1,0,0,1,0,1,1,1,0,0,0,1,1,0,1,0,0,1,0,1,1,1],
- " \ [1,1,0,0,0,1,0,1,1,0,1,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,1,1,1,0,0,1],
- " \ [0,1,0,0,1,1,0,0,0,0,0,1,0,0,0,1,1,1,0,1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,1,0,0,1,0,1,0,0,0,0,1,1,0,0,0,1,0,0,0,1,1],
- " \ [0,1,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,0,1,0,1,1,0,1,0,1,1,1,0,1],
- " \ [0,0,1,0,1,0,0,1,1,1,0,1,0,1,0,0,1,1,1,1,0,1,1,0,0,1,0,1,0,1],
- " \ [1,1,1,0,1,1,0,0,0,1,1,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,1,0,1,1,0,1],
- " \ [1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1],
- " \ [1,1,0,1,1,0,0,0,1,1,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,1,0,1,1,0,1],
- " \ [1,0,1,1,0,0,0,1,1,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,1,0,1,1,0,1]
- " \ ]
+ " let sum = 0.0
+ " for exponent in [0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26, 32]
+ " let sum += tlib#bitwise#Bits2Num(repeat([0], 32 - exponent) + [1])
+ " endfor
+ " let divisor = tlib#bitwise#Num2Bits(sum)
+ " " TLogVAR divisor
+ " let s:crc_table = []
+ " for octet in range(256)
+ " let remainder = tlib#bitwise#Num2Bits(octet)
+ " for i in range(8)
+ " if get(remainder, i) != 0
+ " let remainder = tlib#bitwise#XOR(remainder, tlib#bitwise#ShiftLeft(copy(divisor), i), "bits")
+ " endif
+ " endfor
+ " let remainder = tlib#bitwise#ShiftRight(remainder, 8)
+ " " TLogVAR octet, remainder
+ " call add(s:crc_table, remainder)
+ " endfor
" endif
- " let crc = [0]
- " let x00FFFFFF = tlib#bitwise#Num2Bits(0x00FFFFFF)
+ " let xFFFF_FFFF = repeat([1], 32)
+ " let crc = tlib#bitwise#XOR([0], xFFFF_FFFF, 'bits')
" for char in split(a:chars, '\zs')
- " let byte = char2nr(char)
+ " let octet = char2nr(char)
" let v0 = tlib#bitwise#ShiftRight(crc, 8)
- " " TLogVAR byte, v0
- " let v1 = tlib#bitwise#AND(v0, x00FFFFFF, 'bits')
- " " TLogVAR v1
- " let i1 = tlib#bitwise#XOR(crc, byte, 'bits')
+ " let r1 = tlib#bitwise#AND(crc, xFFFF_FFFF, 'bits')
+ " let i1 = tlib#bitwise#XOR(r1, octet, 'bits')
" let i2 = tlib#bitwise#Bits2Num(tlib#bitwise#AND(i1, 0xff, 'bits'))
- " " TLogVAR i1, i2
- " let v2 = s:crc_table[i2]
- " " TLogVAR v2
- " let crc = tlib#bitwise#XOR(v1, v2, 'bits')
- " " TLogVAR crc
+ " let r2 = s:crc_table[i2]
+ " let crc = tlib#bitwise#XOR(r1, r2, 'bits')
" endfor
- " " TLogVAR crc
+ " let crc = tlib#bitwise#XOR(crc, xFFFF_FFFF, 'bits')
" let rv = tlib#bitwise#Bits2Num(crc, 16)
endif
return rv
Please sign in to comment.
Something went wrong with that request. Please try again.