[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#21829: guix import hackage failures
From: |
Federico Beffa |
Subject: |
bug#21829: guix import hackage failures |
Date: |
Fri, 13 Nov 2015 18:08:33 +0100 |
On Thu, Nov 12, 2015 at 9:21 PM, Ludovic Courtès <address@hidden> wrote:
> If we go for the CRLF conversion port, we should avoid the pipe and
> extra thread. Instead, I would suggest something like:
>
> (define (canonical-newline-port port)
> "Return an input port that wraps PORT such that all newlines consist
> of a single carriage return."
> (make-custom-binary-input-port …))
I like this suggestion :-)
I never used custom ports. Is something like this OK? (Seems to work
in the REPL.)
---------------------------------------------------------------
(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)
((eqv? byte (char->integer #\return)) (loop count (get-u8 port)))
(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?
Regards,
Fede
- bug#21829: guix import hackage failures, Paul van der Walt, 2015/11/04
- bug#21829: guix import hackage failures, Ludovic Courtès, 2015/11/04
- bug#21829: guix import hackage failures, Federico Beffa, 2015/11/10
- bug#21829: guix import hackage failures, Ludovic Courtès, 2015/11/11
- bug#21829: guix import hackage failures, Federico Beffa, 2015/11/11
- bug#21829: guix import hackage failures, Ludovic Courtès, 2015/11/12
- bug#21829: guix import hackage failures, Federico Beffa, 2015/11/12
- bug#21829: guix import hackage failures, Ludovic Courtès, 2015/11/12
- bug#21829: guix import hackage failures,
Federico Beffa <=
- bug#21829: guix import hackage failures, Ludovic Courtès, 2015/11/13
- bug#21829: guix import hackage failures, Federico Beffa, 2015/11/14
- bug#21829: guix import hackage failures, Ludovic Courtès, 2015/11/16
- bug#21829: guix import hackage failures, Federico Beffa, 2015/11/25
- bug#21829: guix import hackage failures, Ludovic Courtès, 2015/11/25
- bug#21829: guix import hackage failures, Federico Beffa, 2015/11/26
- bug#21829: guix import hackage failures, Ludovic Courtès, 2015/11/26
- bug#21829: guix import hackage failures, Federico Beffa, 2015/11/26
- bug#21829: guix import hackage failures, Ludovic Courtès, 2015/11/26