diff options
author | James LewisMoss <dres@debian.org> | 2001-07-27 23:45:29 -0400 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:05:29 -0800 |
commit | f559c149c83da84d0b1c285f0298c84aec564af9 (patch) | |
tree | f1c91bcb9bb5e6dad87b643127c3f878d80d89ee /makcrc.scm | |
parent | c394920caedf3dac1981bb6b10eeb47fd6e4bb21 (diff) | |
parent | 87b82b5822ca54228cfa6df29be3ad9d4bc47d16 (diff) | |
download | slib-f559c149c83da84d0b1c285f0298c84aec564af9.tar.gz slib-f559c149c83da84d0b1c285f0298c84aec564af9.zip |
Import Debian changes 2d2-1debian/2d2-1
slib (2d2-1) unstable; urgency=low
* New upstream version
* Revert back to free. Is now so.
slib (2d1-1) unstable; urgency=low
* New upstream version.
* Move to non-free. FSF pointed out license doesn't allow modified
versions to be distributed.
* Get a complete list of copyrights that apply to the source into
copyright file.
* Remove setup for guile 1.3.
* Remove postrm. Just calling install-info (lintian) Move install-info
call to prerm since doc-base doesn't do install-info.
slib (2c9-3) unstable; urgency=low
* Change info location to section "The Algorithmic Language Scheme" to
match up with where guile puts it's files.
* Postinst is running slibconfig now. (Closes: #75891)
slib (2c9-2) unstable; urgency=low
* Stop installing slibconfig (for guile).
* In postinst if /usr/sbin/slibconnfig exists call it (Close: #75843
#75891).
slib (2c9-1) unstable; urgency=low
* New upstream (Closes: #74760)
* replace string-index with strsrch:string-index in http-cgi.scm.
* Add doc-base support (Closes: #31163)
Diffstat (limited to 'makcrc.scm')
-rw-r--r-- | makcrc.scm | 49 |
1 files changed, 29 insertions, 20 deletions
@@ -1,9 +1,9 @@ ;;;; "makcrc.scm" Compute Cyclic Checksums -;;; Copyright (C) 1995, 1996, 1997 Aubrey Jaffer. +;;; Copyright (C) 1995, 1996, 1997, 2001 Aubrey Jaffer ; -;Permission to copy this software, to redistribute it, and to use it -;for any purpose is granted, subject to the following restrictions and -;understandings. +;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. @@ -17,27 +17,39 @@ ;promotional, or sales literature without prior written consent in ;each case. +(require 'byte) (require 'logical) -;;;(define crc (eval (make-port-crc 16 #o010013))) -;;;(define crc (eval (make-port-crc 08 #o053))) -;;;(define (file-check-sum file) (call-with-input-file file crc32)) - (define (make-port-crc . margs) (define (make-mask hibit) (+ (ash (+ -1 (ash 1 (+ 1 (- hibit 2)))) 1) 1)) - (define accum-bits 32) (define chunk-bits (integer-length (+ -1 char-code-limit))) + (define accum-bits #f) (define generator #f) - (cond ((pair? margs) - (set! accum-bits (car margs)) - (cond ((pair? (cdr margs)) - (set! generator (cadr margs)))))) + (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 - ((32) (set! generator #b00000100110000010001110110110111)) + ((#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"))))) + 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) @@ -69,17 +81,14 @@ (do ((i 0 (+ 1 i))) ((> i chunk-mask)) (vector-set! crctab i (remd i))))) - (cond ((>= (integer-length generator) accum-bits) - (slib:error 'make-port-crc - "generator longer than" accum-bits "bits"))) (make-crc-table) `(lambda (port) (define crc 0) (define byte-count 0) (define crctab ',crctab) - (do ((ci (read-char port) (read-char port))) + (do ((ci (read-byte port) (read-byte port))) ((eof-object? ci)) - ,(accum '(char->integer ci)) + ,(accum 'ci) (set! byte-count (+ 1 byte-count))) (do ((byte-count byte-count (ash byte-count ,(- chunk-bits)))) ((zero? byte-count)) |