fix for PR8331

svn: r4487

original commit: 4f7cc1e56b37485e565f5b0e3ed2d93ac51f49b8
This commit is contained in:
Eli Barzilay 2006-10-05 01:54:36 +00:00
parent dcaa481278
commit ddd6157459

View File

@ -2050,11 +2050,10 @@
;; * Write out any remaining bits in an incomplete byte. ;; * Write out any remaining bits in an incomplete byte.
;; */ ;; */
(define (bi_windup) (define (bi_windup)
(cond (cond [(> bi_valid 8)
[(> bi_valid 8) (put_short bi_buf)]
(put_short bi_buf)] [(> bi_valid 0)
[(> bi_valid 0) (put_byte bi_buf)])
(put_byte bi_buf)])
(set! bi_buf 0) (set! bi_buf 0)
(set! bi_valid 0) (set! bi_valid 0)
(set! bits_sent (bitwise-and (+ bits_sent 7) (bitwise-not 7)))) (set! bits_sent (bitwise-and (+ bits_sent 7) (bitwise-not 7))))
@ -2253,9 +2252,15 @@
(values bytes_in bytes_out (bitwise-xor crc #xffffffff))) (values bytes_in bytes_out (bitwise-xor crc #xffffffff)))
(define (gzip-through-ports in out origname time_stamp) (define (gzip-through-ports in out origname time_stamp)
(define flags (if origname #x8 0)) ;; /* general purpose bit flags */ (define flags (if origname #x8 0)) ;; /* general purpose bit flags */
;; make origname be a byte string
(set! origname (cond [(not origname) #f]
[(string? origname) (string->bytes/utf-8 origname)]
[(path? origname) (path->bytes origname)]
[else origname]))
(set! bytes_in 0) (set! bytes_in 0)
(set! ifd in) (set! ifd in)
@ -2275,14 +2280,14 @@
(bi_init) (bi_init)
(ct_init) (ct_init)
(put_byte (lm_init LEVEL));; /* extra flags */ (put_byte (lm_init LEVEL));; /* extra flags */
(put_byte 3) ;; /* OS identifier */ (put_byte 3) ;; /* OS identifier */
(when origname (when origname
(for-each put_byte (map char->integer (string->list origname))) (for-each put_byte (bytes->list origname))
(put_byte 0)) (put_byte 0))
(do-deflate) (do-deflate)
;; /* Write the crc and uncompressed size */ ;; /* Write the crc and uncompressed size */