all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Federico Beffa <beffa@ieee.org>
Cc: 21829@debbugs.gnu.org
Subject: bug#21829: guix import hackage failures
Date: Fri, 13 Nov 2015 22:19:57 +0100	[thread overview]
Message-ID: <87h9kp1ts2.fsf@gnu.org> (raw)
In-Reply-To: <CAKrPhPN7oqedUgDKi41jQWEWiXAGb_7xMgnrv09YrQTn1CcJGQ@mail.gmail.com> (Federico Beffa's message of "Fri, 13 Nov 2015 18:08:33 +0100")

Federico Beffa <beffa@ieee.org> skribis:

> ---------------------------------------------------------------
> (define (canonical-newline-port port)
>   "Return an input port that wraps PORT such that all newlines consist
>   of a single carriage return."
>   (define (get-position)
>     (if (port-has-port-position? port) (port-position port) #f))
>   (define (set-position! position)
>     (if (port-has-set-port-position!? port)
>         (set-port-position! position port)
>         #f))
>   (define (close) (close-port port))
>   (define (read! bv start n)
>     (let loop ((count 0)
>                (byte (get-u8 port)))
>       (cond ((or (eof-object? byte) (= count n)) count)

BYTE is lost here in the case it is not EOF.

It may be best to move the (= count n) case right before the recursive
call below.

>             ((eqv? byte (char->integer #\return)) (loop count (get-u8 port)))

In practice this discards LF even if it’s not following CR; that’s
probably a good enough approximation, but an XXX comment would be
welcome.

>             (else
>              (bytevector-u8-set! bv (+ start count) byte)
>              (loop (+ count 1) (get-u8 port))))))
>   (make-custom-binary-input-port "canonical-newline-port"
>                                  read!
>                                  get-position
>                                  set-position!
>                                  close))
> ---------------------------------------------------------------
>
> IMO this is general enough that it could go into "guix/utils.scm". Are
> you OK with this?

Looks good!  Could you make a patch that does that, along with adding a
test or two in tests/utils.scm?

Thank you!

Ludo’.

  reply	other threads:[~2015-11-13 21:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04 15:00 bug#21829: guix import hackage failures Paul van der Walt
2015-11-04 23:11 ` Ludovic Courtès
2015-11-10 16:40 ` Federico Beffa
2015-11-11 11:18   ` Ludovic Courtès
2015-11-11 21:29     ` Federico Beffa
2015-11-12  9:07       ` Ludovic Courtès
2015-11-12 16:54         ` Federico Beffa
2015-11-12 20:21           ` Ludovic Courtès
2015-11-13 17:08             ` Federico Beffa
2015-11-13 21:19               ` Ludovic Courtès [this message]
2015-11-14 14:37                 ` Federico Beffa
2015-11-15 20:59                   ` Ludovic Courtès
2015-11-25 16:55                     ` Federico Beffa
2015-11-25 21:45                       ` Ludovic Courtès
2015-11-26  8:28                         ` Federico Beffa
2015-11-26  8:46                           ` Ludovic Courtès
2015-11-26 17:23                         ` Federico Beffa
2015-11-26 19:56                           ` 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=87h9kp1ts2.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=21829@debbugs.gnu.org \
    --cc=beffa@ieee.org \
    /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.