summaryrefslogtreecommitdiffstats
path: root/makcrc.scm
diff options
context:
space:
mode:
authorSteve Langasek <vorlon@debian.org>2005-01-10 08:53:33 +0000
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:30 -0800
commite33f9eb9cf5cc29c36ce2aa7e10cd0f37ae0cc8e (patch)
treeabbf06041619e445f9d0b772b0d58132009d8234 /makcrc.scm
parentf559c149c83da84d0b1c285f0298c84aec564af9 (diff)
parent8466d8cfa486fb30d1755c4261b781135083787b (diff)
downloadslib-e33f9eb9cf5cc29c36ce2aa7e10cd0f37ae0cc8e.tar.gz
slib-e33f9eb9cf5cc29c36ce2aa7e10cd0f37ae0cc8e.zip
Import Debian changes 3a1-4.2debian/3a1-4.2
slib (3a1-4.2) unstable; urgency=low * Non-maintainer upload. * Add guile.init.local for use within the build dir, since otherwise we have an (earlier unnoticed) circular build-dep due to a difference between scm and guile. slib (3a1-4.1) unstable; urgency=low * Non-maintainer upload. * Build-depend on guile-1.6 instead of scm, since the new version of scm is wedged in unstable (closes: #281809). slib (3a1-4) unstable; urgency=low * Also check for expected creation on slibcat. (Closes: #240096) slib (3a1-3) unstable; urgency=low * Also check for /usr/share/guile/1.6/slib before installing for guile 1.6. (Closes: #239267) slib (3a1-2) unstable; urgency=low * Add format.scm back into slib until gnucash stops using it. * Call guile-1.6 new-catalog (Closes: #238231) slib (3a1-1) unstable; urgency=low * New upstream release * Remove Info section from doc-base file (Closes: #186950) * Remove period from end of description (linda, lintian) * html gen fixed upstream (Closes: #111778) slib (2d4-2) unstable; urgency=low * Fix url for upstream source (Closes: #144981) * Fix typo in slib.texi (enquque->enqueue) (Closes: #147475) * Add build depends. slib (2d4-1) unstable; urgency=low * New upstream. slib (2d3-1) unstable; urgency=low * New upstream. * Remove texi2html call in debian/rules. Now done upstream. Add make html instead. * Changes to rules and doc-base to conform to upstream html gen * Clean up upstream makefile to make sure it cleans up after itself.
Diffstat (limited to 'makcrc.scm')
-rw-r--r--makcrc.scm96
1 files changed, 0 insertions, 96 deletions
diff --git a/makcrc.scm b/makcrc.scm
deleted file mode 100644
index debd5c9..0000000
--- a/makcrc.scm
+++ /dev/null
@@ -1,96 +0,0 @@
-;;;; "makcrc.scm" Compute Cyclic Checksums
-;;; Copyright (C) 1995, 1996, 1997, 2001 Aubrey Jaffer
-;
-;Permission to copy this software, to modify it, to redistribute it,
-;to distribute modified versions, and to use it for any purpose is
-;granted, subject to the following restrictions and understandings.
-;
-;1. Any copy made of this software must include this copyright notice
-;in full.
-;
-;2. I have made no warrantee or representation that the operation of
-;this software will be error-free, and I am under no obligation to
-;provide any services, by way of maintenance, update, or otherwise.
-;
-;3. In conjunction with products arising from the use of this
-;material, there shall be no use of my name in any advertising,
-;promotional, or sales literature without prior written consent in
-;each case.
-
-(require 'byte)
-(require 'logical)
-
-(define (make-port-crc . margs)
- (define (make-mask hibit)
- (+ (ash (+ -1 (ash 1 (+ 1 (- hibit 2)))) 1) 1))
- (define chunk-bits (integer-length (+ -1 char-code-limit)))
- (define accum-bits #f)
- (define generator #f)
- (case (length margs)
- ((0) #t)
- ((1) (if (< (car margs) 128)
- (set! accum-bits (car margs))
- (set! generator (car margs))))
- ((2)
- (set! accum-bits (car margs))
- (set! generator (cadr margs)))
- (else (slib:error 'make-port-crc 'args margs)))
- (cond ((not generator)
- (case accum-bits
- ((#f 32) (set! accum-bits 32)
- (set! generator #b00000100110000010001110110110111)) ; CRC-32
- ((16) (set! generator #b0001000000001011)) ; CRC-16
- ;;((16) (set! generator #b0001000000100001)) ; CRC-CCIT
- ;;((08) (set! generator #b101011))
- (else (slib:error 'make-port-crc "no default polynomial for"
- accum-bits "bits"))))
- ((not accum-bits)
- (set! accum-bits (+ -1 (integer-length generator)))))
- (set! generator (logand generator (lognot (ash 1 accum-bits))))
- (cond ((>= (integer-length generator) accum-bits)
- (slib:error 'make-port-crc
- "generator longer than" accum-bits "bits")))
- (let* ((chunk-mask (make-mask chunk-bits))
- (crctab (make-vector (+ 1 chunk-mask))))
- (define (accum src)
- `(set!
- crc
- (logxor (ash (logand ,(make-mask (- accum-bits chunk-bits)) crc)
- ,chunk-bits)
- (vector-ref crctab
- (logand ,chunk-mask
- (logxor
- (ash crc ,(- chunk-bits accum-bits))
- ,src))))))
- (define (make-crc-table)
- (letrec ((r (make-vector chunk-bits))
- (remd (lambda (m)
- (define rem 0)
- (do ((i 0 (+ 1 i)))
- ((>= i chunk-bits) rem)
- (if (logbit? i m)
- (set! rem (logxor rem (vector-ref r i))))))))
- (vector-set! r 0 generator)
- (do ((i 1 (+ 1 i)))
- ((>= i chunk-bits))
- (let ((r-1 (vector-ref r (+ -1 i)))
- (m-1 (make-mask (+ -1 accum-bits))))
- (vector-set! r i (if (logbit? (+ -1 accum-bits) r-1)
- (logxor (ash (logand m-1 r-1) 1) generator)
- (ash (logand m-1 r-1) 1)))))
- (do ((i 0 (+ 1 i)))
- ((> i chunk-mask))
- (vector-set! crctab i (remd i)))))
- (make-crc-table)
- `(lambda (port)
- (define crc 0)
- (define byte-count 0)
- (define crctab ',crctab)
- (do ((ci (read-byte port) (read-byte port)))
- ((eof-object? ci))
- ,(accum 'ci)
- (set! byte-count (+ 1 byte-count)))
- (do ((byte-count byte-count (ash byte-count ,(- chunk-bits))))
- ((zero? byte-count))
- ,(accum 'byte-count))
- (logxor ,(make-mask accum-bits) crc))))