all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Pierre Neidhardt <mail@ambrevar.xyz>
Cc: 35880@debbugs.gnu.org
Subject: [bug#35880] [PATCH 1/7] lzlib: Add 'make-lzip-input-port/compressed'.
Date: Sun, 26 May 2019 21:51:41 +0200	[thread overview]
Message-ID: <87ftp1m1te.fsf@gnu.org> (raw)
In-Reply-To: <87d0k6o3am.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Sat, 25 May 2019 19:24:33 +0200")

Hi!

Pierre Neidhardt <mail@ambrevar.xyz> skribis:

> As an Lzip enthusiast, I have some questions ;)
>
> I see you are using make-lzip-input-port/compressed in a subsequent
> patch, but this does not map how it's done for gzip et al., the latter
> being invoked via it's system command "gzip -c ...".  Why did you decide
> to do it differently for lzip?
>
> Much of the code induced by make-lzip-input-port/compressed seems to
> repeat the lzread! / lzwrite business, maybe there is a way to factor
> some of it?

Actually, ‘make-lzip-input-port/compressed’ exists solely so we can have
‘compressed-port’ for lzip, which in turn allows us to write tests.

It uses (guix lzlib) instead of invoking the ‘lzip’ command because we
can.  :-)  Invoking commands is not as nice, because it’s more
expensive, requires us to spawn an additional process when the input is
not a file port (e.g., it’s a string port), and it’s forking is not
possible in multi-threaded programs like ‘guix publish’.

>> +(define (lzwrite! encoder source source-offset source-count
>> +                  target target-offset target-count)
>> +  "Write up to SOURCE-COUNT bytes from SOURCE to ENCODER, and read up to
>> +TARGET-COUNT bytes into TARGET at TARGET-OFFSET.  Return two values: the
>> +number of bytes read from SOURCE, and the number of bytes written to TARGET."
>> +  (define read
>> +    (if (< 0 (lz-compress-write-size encoder))
>> +        (match (lz-compress-write encoder source source-offset source-count)
>> +          (0 (lz-compress-finish encoder) 0)
>> +          (n n))
>> +        0))
>> +
>> +  (let loop ()
>> +    (match (lz-compress-read encoder target target-offset target-count)
>> +      (0       (loop))
>> +      (written (values read written)))))
>
> Why looping on 0?  If there is no byte to read, wouldn't this loop indefinitely?

Hmm, good point.  The idea is that ‘lzwrite!’ should return 0 only on
end-of-file, but then the loop should include reading more from SOURCE.
I’ll follow up on this one.

Thanks!

Ludo’.

  reply	other threads:[~2019-05-26 19:52 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-24 13:31 [bug#35880] [PATCH 0/7] Lzip support for 'guix publish' and 'guix substitute' Ludovic Courtès
2019-05-24 13:42 ` [bug#35880] [PATCH 1/7] lzlib: Add 'make-lzip-input-port/compressed' Ludovic Courtès
2019-05-24 13:42   ` [bug#35880] [PATCH 2/7] utils: Test 'compressed-port' and 'decompressed-port' for both gzip and xz Ludovic Courtès
2019-05-24 13:42   ` [bug#35880] [PATCH 3/7] utils: Support compression and decompression with lzip Ludovic Courtès
2019-05-25 17:27     ` Pierre Neidhardt
2019-05-26 19:52       ` Ludovic Courtès
2019-05-24 13:42   ` [bug#35880] [PATCH 4/7] publish: Add support for lzip Ludovic Courtès
2019-05-24 13:42   ` [bug#35880] [PATCH 5/7] self: Add dependency on lzlib Ludovic Courtès
2019-05-24 13:42   ` [bug#35880] [PATCH 6/7] gnu: guix: " Ludovic Courtès
2019-05-24 13:42   ` [bug#35880] [PATCH 7/7] lzlib: 'lzread!' never returns more than it was asked for Ludovic Courtès
2019-05-25 17:31     ` Pierre Neidhardt
2019-05-26 19:54       ` Ludovic Courtès
2019-05-26 20:57         ` Pierre Neidhardt
2019-05-26 21:28           ` Ludovic Courtès
2019-05-27  7:00             ` Pierre Neidhardt
2019-05-27 10:00               ` Ludovic Courtès
2019-05-25 17:24   ` [bug#35880] [PATCH 1/7] lzlib: Add 'make-lzip-input-port/compressed' Pierre Neidhardt
2019-05-26 19:51     ` Ludovic Courtès [this message]
2019-05-27 15:45       ` Ludovic Courtès
2019-05-27 16:24         ` Pierre Neidhardt
2019-05-27 20:53           ` bug#35880: " Ludovic Courtès
2019-05-27 21:12             ` [bug#35880] " Pierre Neidhardt
2019-05-28  7:52               ` Ludovic Courtès
2019-05-28  8:46                 ` Pierre Neidhardt
2019-05-28 13:47                   ` Ludovic Courtès
2019-05-29 14:57                     ` Pierre Neidhardt
2019-05-31 20:54                       ` Ludovic Courtès
2019-06-01  6:02                         ` Pierre Neidhardt
2019-06-01  9:41                           ` Ludovic Courtès
2019-06-01  9:58                             ` Pierre Neidhardt
2019-06-01 12:21                               ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ftp1m1te.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=35880@debbugs.gnu.org \
    --cc=mail@ambrevar.xyz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.