GNU bug report logs - #21829
guix import hackage failures

Previous Next

Package: guix;

Reported by: Paul van der Walt <paul <at> denknerd.org>

Date: Wed, 4 Nov 2015 16:26:03 UTC

Severity: normal

Done: ludo <at> gnu.org (Ludovic Courtès)

Bug is archived. No further changes may be made.

Full log


Message #32 received at 21829 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Federico Beffa <beffa <at> ieee.org>
Cc: 21829 <at> debbugs.gnu.org, Paul van der Walt <paul <at> denknerd.org>
Subject: Re: guix import hackage failures
Date: Fri, 13 Nov 2015 22:19:57 +0100
Federico Beffa <beffa <at> 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’.




This bug report was last modified 9 years and 239 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.