bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21829: guix import hackage failures


From: Ludovic Courtès
Subject: bug#21829: guix import hackage failures
Date: Fri, 13 Nov 2015 22:19:57 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Federico Beffa <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]