From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#21829: guix import hackage failures Date: Fri, 13 Nov 2015 22:19:57 +0100 Message-ID: <87h9kp1ts2.fsf@gnu.org> References: <87d1vghjhk.fsf@gnu.org> <87vb971t74.fsf@gnu.org> <87lha3ufxv.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxLmN-0004nM-9f for bug-guix@gnu.org; Fri, 13 Nov 2015 16:21:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZxLmJ-0004Vs-8R for bug-guix@gnu.org; Fri, 13 Nov 2015 16:21:07 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:47792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxLmJ-0004Vo-4v for bug-guix@gnu.org; Fri, 13 Nov 2015 16:21:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZxLmI-0007Gm-Nx for bug-guix@gnu.org; Fri, 13 Nov 2015 16:21:02 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: (Federico Beffa's message of "Fri, 13 Nov 2015 18:08:33 +0100") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: Federico Beffa Cc: 21829@debbugs.gnu.org Federico Beffa 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) (=3D count n)) count) BYTE is lost here in the case it is not EOF. It may be best to move the (=3D count n) case right before the recursive call below. > ((eqv? byte (char->integer #\return)) (loop count (get-u8 por= t))) In practice this discards LF even if it=E2=80=99s not following CR; that=E2= =80=99s 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=E2=80=99.