From: Federico Beffa <beffa@ieee.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 21829@debbugs.gnu.org
Subject: bug#21829: guix import hackage failures
Date: Fri, 13 Nov 2015 18:08:33 +0100 [thread overview]
Message-ID: <CAKrPhPN7oqedUgDKi41jQWEWiXAGb_7xMgnrv09YrQTn1CcJGQ@mail.gmail.com> (raw)
In-Reply-To: <87lha3ufxv.fsf@gnu.org>
On Thu, Nov 12, 2015 at 9:21 PM, Ludovic Courtès <ludo@gnu.org> 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
next prev parent reply other threads:[~2015-11-13 17:09 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 [this message]
2015-11-13 21:19 ` Ludovic Courtès
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKrPhPN7oqedUgDKi41jQWEWiXAGb_7xMgnrv09YrQTn1CcJGQ@mail.gmail.com \
--to=beffa@ieee.org \
--cc=21829@debbugs.gnu.org \
--cc=ludo@gnu.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 public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).