diff --git a/pitfall/pitfall/check-pdf.rkt b/pitfall/pitfall/check-pdf.rkt index 8ab5eab3..433ccc28 100644 --- a/pitfall/pitfall/check-pdf.rkt +++ b/pitfall/pitfall/check-pdf.rkt @@ -63,7 +63,7 @@ (for/list ([kv (in-slice 2 items)] ;; suppress these keys so we can compare pdfkit & pitfall output #:unless (member (car kv) (list #"/Producer" #"/Creator" #"/CreationDate"))) - (apply cons kv)) + (apply cons kv)) bytesdict pdf) (define pdf-bs (file->bytes pdf)) @@ -100,14 +105,14 @@ (sort ; sort by byte offset (cdr ; drop zeroth record: there is no zeroth object (for/list ([i (in-range ref-count)]) - (cons i (read (open-input-bytes (car (regexp-match #px"\\d{10}" xref-ip))))))) + (cons i (read (open-input-bytes (car (regexp-match #px"\\d{10}" xref-ip))))))) < #:key cdr) (list (cons #f xoff)))) (sort ; sort by index (parameterize ([current-input-port (open-input-bytes pdf-bs)]) (for/list ([(idx start) (in-dict obj-locations)] [(_ end) (in-dict (cdr obj-locations))]) - (cons idx (parse-pdf-bytes (peek-bytes (- end start) start))))) + (cons idx (parse-pdf-bytes (peek-bytes (- end start) start))))) < #:key car)) (define (dict-compare d1 d2) @@ -115,19 +120,19 @@ (= (length d1) (length d2)) (for/and ([(k1 v1) (in-dict d1)] [(k2 v2) (in-dict d2)]) - (unless (equal? k1 k2) - (error (format "keys unequal: ~a ~a" k1 k2))) - (unless (equal? v1 v2) - (define val1 (if (and (bytes? v1) (> (bytes-length v1) 200)) - (subbytes v1 0 200) - v1)) - (define val2 (if (and (bytes? v2) (> (bytes-length v2) 200)) - (subbytes v2 0 200) - v2)) - (error (format "values unequal: ~a ~a" val1 val2))) - (when (dict? v1) - (dict-compare v1 v2)) - #true))) + (unless (equal? k1 k2) + (error (format "keys unequal: ~a ~a" k1 k2))) + (unless (equal? v1 v2) + (define val1 (if (and (bytes? v1) (> (bytes-length v1) 200)) + (subbytes v1 0 200) + v1)) + (define val2 (if (and (bytes? v2) (> (bytes-length v2) 200)) + (subbytes v2 0 200) + v2)) + (error (format "values unequal: ~a ~a" val1 val2))) + (when (dict? v1) + (dict-compare v1 v2)) + #true))) (define-simple-check (check-pdfs-equal? ps1 ps2) (dict-compare (pdf->dict ps1) (pdf->dict ps2))) @@ -135,5 +140,5 @@ #;(module+ main (for ([p (in-directory)] #:when (path-has-extension? p #"pdf")) - (with-handlers ([exn:fail? (λ (exn) (println (format "~a failed" p)))]) - (pdf->dict p)))) + (with-handlers ([exn:fail? (λ (exn) (println (format "~a failed" p)))]) + (pdf->dict p)))) diff --git a/pitfall/ptest/test10.rkt b/pitfall/ptest/test10.rkt index 9792e7ff..355b41eb 100644 --- a/pitfall/ptest/test10.rkt +++ b/pitfall/ptest/test10.rkt @@ -24,5 +24,5 @@ (define-runtime-path this "test10rkt.pdf") (make-doc this #f proc) -#;(define-runtime-path that "test10crkt.pdf") -#;(make-doc that #t proc) +(define-runtime-path that "test10crkt.pdf") +(make-doc that #t proc)