move zlib

main
Matthew Butterick 5 years ago
parent 5351deaa75
commit a84955b8cc

@ -1,5 +1,5 @@
#lang debug racket
(require rackunit (prefix-in zlib: pitfall/zlib) fontland/table/cff/cff-top)
(require rackunit (prefix-in zlib: fontland/zlib) fontland/table/cff/cff-top)
(provide (all-defined-out))
(define (xref-offset bs)

@ -3,6 +3,7 @@
racket/class
"reference.rkt"
"core.rkt"
fontland/zlib
racket/dict
racket/list
racket/file
@ -12,7 +13,6 @@
#|
https://github.com/mbutterick/pdfkit/blob/master/lib/image/png.coffee
|#
(require "zlib.rkt")
(provide (all-defined-out))

@ -1,7 +1,7 @@
#lang debug racket/base
(require "core.rkt"
"object.rkt"
"zlib.rkt")
fontland/zlib)
(provide (all-defined-out))
(define ref-listeners null)

@ -1,31 +0,0 @@
#lang racket/base
(provide deflate inflate)
;; see https://groups.google.com/d/topic/racket-users/3CvjHLAmwSQ/discussion
;; for discrepancies between gzip gunzip and zlib
(require (prefix-in gzip: file/gzip)
(prefix-in gunzip: file/gunzip) png-image)
(define (deflate bstr)
;; https://www.ietf.org/rfc/rfc1950.txt
(define rfc-1950-header (bytes #x78 #x9c))
(define op (open-output-bytes))
(gzip:deflate (open-input-bytes bstr) op)
(bytes-append rfc-1950-header
(get-output-bytes op)
(integer->integer-bytes (bytes-adler32 bstr) 4 #f 'want-big-endian)))
(define (inflate bstr)
(define op (open-output-bytes))
(gunzip:inflate (open-input-bytes (subbytes bstr 2)) op)
(get-output-bytes op))
(module+ test
(require rackunit)
(for ([i (in-range 100)])
(define random-bytes
(apply bytes (for/list ([bidx (in-range 100)])
(random 256))))
(check-equal? random-bytes (inflate (deflate random-bytes)))))

@ -5,5 +5,4 @@
(dynamic-require which #f))
(require
pitfall/page-test
(submod pitfall/zlib test))
pitfall/page-test)
Loading…
Cancel
Save