From a84955b8cc1c48c7be4afe5900f9177ef1fd8943 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Wed, 22 May 2019 16:29:51 -0700 Subject: [PATCH] move zlib --- pitfall/pitfall/check-pdf.rkt | 2 +- pitfall/pitfall/png.rkt | 2 +- pitfall/pitfall/reference.rkt | 2 +- pitfall/pitfall/zlib.rkt | 31 ------------------------------- pitfall/ptest/alltest.rkt | 3 +-- 5 files changed, 4 insertions(+), 36 deletions(-) delete mode 100644 pitfall/pitfall/zlib.rkt diff --git a/pitfall/pitfall/check-pdf.rkt b/pitfall/pitfall/check-pdf.rkt index 909cdc3e..e00cb226 100644 --- a/pitfall/pitfall/check-pdf.rkt +++ b/pitfall/pitfall/check-pdf.rkt @@ -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) diff --git a/pitfall/pitfall/png.rkt b/pitfall/pitfall/png.rkt index 4f8d7aad..cdb58f26 100644 --- a/pitfall/pitfall/png.rkt +++ b/pitfall/pitfall/png.rkt @@ -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)) diff --git a/pitfall/pitfall/reference.rkt b/pitfall/pitfall/reference.rkt index b534d13f..776d7053 100644 --- a/pitfall/pitfall/reference.rkt +++ b/pitfall/pitfall/reference.rkt @@ -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) diff --git a/pitfall/pitfall/zlib.rkt b/pitfall/pitfall/zlib.rkt deleted file mode 100644 index 1a223d74..00000000 --- a/pitfall/pitfall/zlib.rkt +++ /dev/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))))) \ No newline at end of file diff --git a/pitfall/ptest/alltest.rkt b/pitfall/ptest/alltest.rkt index 911b3acd..ac524898 100644 --- a/pitfall/ptest/alltest.rkt +++ b/pitfall/ptest/alltest.rkt @@ -5,5 +5,4 @@ (dynamic-require which #f)) (require - pitfall/page-test - (submod pitfall/zlib test)) \ No newline at end of file + pitfall/page-test) \ No newline at end of file