Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 35 additions and 276 deletions.
  1. +6 −2 autoload/tlib/bitwise.vim
  2. +29 −274 autoload/tlib/hash.vim
View
8 autoload/tlib/bitwise.vim
@@ -1,6 +1,6 @@
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
-" @Revision: 92
+" @Revision: 93
function! tlib#bitwise#Num2Bits(num) "{{{3
@@ -26,7 +26,11 @@ function! tlib#bitwise#Bits2Num(bits, ...) "{{{3
endfor
" TLogVAR num
if base == 10
- return float2nr(num)
+ if type(base) == 5
+ return num
+ else
+ return float2nr(num)
+ endif
else
return tlib#number#ConvertBase(num, base)
endif
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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,1,1,0,1,1,0,0,0,0,0,0,1,0,1,1,0,1,0,1,1,1,0,1],
- " \ [1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0,1,1,1,0,1,0,1,1,1,0,1,1,0,0,1,1],
- " \ [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,1,1,1,0,1,1,1,1,0,0,1,1,0,1,0,0,1,1,0,1,1,1,1,0,0,0,1],
- " \ [0,1,1,1,0,1,0,0,0,1,0,1,1,1,1,0,0,1,1,0,0,1,1,0,1,1,0,0,1,1,0,1],
- " \ [0,0,0,1,1,1,0,1,0,1,0,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

No commit comments for this range

Something went wrong with that request. Please try again.