[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#35880] [PATCH 1/7] lzlib: Add 'make-lzip-input-port/compressed'.
From: |
Ludovic Courtès |
Subject: |
[bug#35880] [PATCH 1/7] lzlib: Add 'make-lzip-input-port/compressed'. |
Date: |
Sat, 01 Jun 2019 11:41:59 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Hi!
Pierre Neidhardt <address@hidden> skribis:
> Ludovic Courtès <address@hidden> writes:
>
>> I think the ‘lzread!’ loop should look like this (the tests still pass
>> with this):
>>
>> --8<---------------cut here---------------start------------->8---
>> (let loop ((read 0)
>> (start start))
>> (cond ((< read count)
>> (match (lz-decompress-read decoder bv start (- count read))
>> (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)))
>> --8<---------------cut here---------------end--------------->8---
>
> Looks good to me!
OK, committed!
>>> (match (lz-decompress-read decoder bv start (- count read))
>>> (0 (if (eof-object? (feed-decoder! decoder))
>>> read
>>> (loop read start)))
>>>
>>> I'm not sure I understand the above: if we read nothing, then we try
>>> again?
>>
>> No: if we read *something*, we try again; if we read nothing, we return.
>
> If we read nothing _and_ it is not an EOF (it can be an empty vector),
> then we loop indefinitely, no?
‘feed-decoder!’ cannot return an empty bytevector because
‘lz-decompress-write-size’ necessarily returns a strictly positive
integer at this point.
(Imperative programming is hard! :-))
Thanks,
Ludo’.