From debbugs-submit-bounces@debbugs.gnu.org Sun May 26 17:28:54 2019 Received: (at 35880) by debbugs.gnu.org; 26 May 2019 21:28:54 +0000 Received: from localhost ([127.0.0.1]:51967 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hV0hK-0005xt-5f for submit@debbugs.gnu.org; Sun, 26 May 2019 17:28:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42369) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hV0hG-0005xd-6s for 35880@debbugs.gnu.org; Sun, 26 May 2019 17:28:50 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:52830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hV0h9-0003uJ-UH; Sun, 26 May 2019 17:28:44 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=49916 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hV0h6-00006j-CB; Sun, 26 May 2019 17:28:42 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Pierre Neidhardt Subject: Re: [PATCH 7/7] lzlib: 'lzread!' never returns more than it was asked for. References: <20190524134238.22802-1-ludo@gnu.org> <20190524134238.22802-7-ludo@gnu.org> <877eaeo2zr.fsf@ambrevar.xyz> <87zhn9kn3p.fsf@gnu.org> <87r28llyr4.fsf@ambrevar.xyz> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 7 Prairial an 227 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Sun, 26 May 2019 23:28:38 +0200 In-Reply-To: <87r28llyr4.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Sun, 26 May 2019 22:57:51 +0200") Message-ID: <87a7f8kird.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 35880 Cc: 35880@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Pierre Neidhardt skribis: > Ludovic Court=C3=A8s writes: > >> Pierre Neidhardt skribis: >> >>>> Fixes a bug whereby 'lzread!' could return more than COUNT. >>> >>> Hmm... But why is this a bug? >> >> Because then the =E2=80=98read!=E2=80=99 method of the custom binary inp= ut port could >> return more than =E2=80=98count=E2=80=99, which is understandably not pe= rmitted. > > That's the part where I'm a bit confused because we deal with compressed > data here. > > So when we say "(read count)", does COUNT refer to the compressed or > uncompressed data? We have this: (define* (make-lzip-input-port port) (define decoder (lz-decompress-open)) (define (read! bv start count) (lzread! decoder port bv start count)) (make-custom-binary-input-port "lzip-input" read! #f #f (lambda () =E2=80=A6))) Here =E2=80=98read!=E2=80=99 must return an integer between 1 and COUNT; it= must return 0 if and only if the end-of-file is reached. IOW, =E2=80=98lzread!=E2=80=99 must return the number of uncompressed bytes= of BV that it consumed, and that number is necessarily <=3D COUNT. Does that make sense? Thanks, Ludo=E2=80=99.