summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-06-01 11:38:33 +0200
committerLudovic Courtès <ludo@gnu.org>2019-06-01 15:26:30 +0200
commit87399dfc209fdec523947e7b45a1ad348afa4d46 (patch)
tree36ee7596a142801d40f33e457bc54528aba5ca66
parentb6cf7e54ea412ed24e6b3ca55a5b452a70ec957f (diff)
downloadpatches-87399dfc209fdec523947e7b45a1ad348afa4d46.tar
patches-87399dfc209fdec523947e7b45a1ad348afa4d46.tar.gz
lzlib: 'make-lzip-input-port' better handles end of decompression.
Suggested by Pierre Neidhardt <mail@ambrevar.xyz>. * guix/lzlib.scm (lzread!): Call 'lz-decompress-finish' when 'feed-decoder!' returns EOF. Call 'lz-decompress-finished?' to determine end of compression.
-rw-r--r--guix/lzlib.scm10
1 files changed, 7 insertions, 3 deletions
diff --git a/guix/lzlib.scm b/guix/lzlib.scm
index 31d84971cb..24c7b4b448 100644
--- a/guix/lzlib.scm
+++ b/guix/lzlib.scm
@@ -510,9 +510,13 @@ the end-of-stream has been reached."
(start start))
(cond ((< read count)
(match (lz-decompress-read decoder bv start (- count read))
- (0 (if (eof-object? (feed-decoder! decoder))
- read
- (loop read start)))
+ (0 (cond ((lz-decompress-finished? decoder)
+ read)
+ ((eof-object? (feed-decoder! decoder))
+ (lz-decompress-finish decoder)
+ (loop read start))
+ (else ;read again
+ (loop read start))))
(n (loop (+ read n) (+ start n)))))
(else
read))))