From e34d227e3ff8025e6f63d79f77df0479e359a158 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Mon, 3 Dec 2018 22:40:41 -0800 Subject: [PATCH] port pos --- pitfall/pitfall/image.rkt | 2 +- pitfall/pitfall/jpeg.rkt | 5 ++--- pitfall/ptest/alltest.rkt | 16 +++++++--------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/pitfall/pitfall/image.rkt b/pitfall/pitfall/image.rkt index 856addbb..91d0a823 100644 --- a/pitfall/pitfall/image.rkt +++ b/pitfall/pitfall/image.rkt @@ -22,7 +22,7 @@ [else (open-input-file src)])) (cond [(equal? (peek-bytes 2 0 data) (bytes #xff #xd8)) - (make-object JPEG (port->bytes data) label)] + (make-object JPEG data label)] [(equal? (peek-bytes 4 0 data) (apply bytes (cons #x89 (map char->integer '(#\P #\N #\G))))) (make-object PNG data label)] [else (raise-argument-error 'PDFImage-open "valid image format" src)])) diff --git a/pitfall/pitfall/jpeg.rkt b/pitfall/pitfall/jpeg.rkt index ab5f2ddd..45c74cf5 100644 --- a/pitfall/pitfall/jpeg.rkt +++ b/pitfall/pitfall/jpeg.rkt @@ -8,9 +8,7 @@ (define-subclass object% (JPEG data [label #f]) (define last-ip (current-input-port)) - (current-input-port (if (input-port? data) - data - (open-input-bytes data))) + (current-input-port (if (input-port? data) data (open-input-bytes data))) (unless (equal? (read-16bit-integer) #xffd8) (error 'JPEG "Start of Input marker byte not found")) @@ -66,6 +64,7 @@ (when (equal? (· this colorSpace) "DeviceCMYK") (hash-set! (· this obj payload) 'Decode '(1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0))) + (port-position (· this data) 0) (send (· this obj) end (· this data)))) (module+ test diff --git a/pitfall/ptest/alltest.rkt b/pitfall/ptest/alltest.rkt index dfaa38c2..3f736dd4 100644 --- a/pitfall/ptest/alltest.rkt +++ b/pitfall/ptest/alltest.rkt @@ -1,11 +1,9 @@ #lang racket -(module+ test +(for ([i (in-range 20)]) + (define which (string->symbol (format "ptest/test~a" i))) + (println which) + (dynamic-require which #f)) - (for ([i (in-range 20)]) - (define which (string->symbol (format "ptest/test~a" i))) - (println which) - (dynamic-require which #f)) - - (require - pitfall/page-test - (submod pitfall/zlib test))) \ No newline at end of file +(require + pitfall/page-test + (submod pitfall/zlib test)) \ No newline at end of file