From unknown Sun Jun 15 08:37:15 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#36244 <36244@debbugs.gnu.org> To: bug#36244 <36244@debbugs.gnu.org> Subject: Status: [PATCH] guix: canonical-newline-port: Fix handling of carriage return at buffer end. Reply-To: bug#36244 <36244@debbugs.gnu.org> Date: Sun, 15 Jun 2025 15:37:15 +0000 retitle 36244 [PATCH] guix: canonical-newline-port: Fix handling of carriag= e return at buffer end. reassign 36244 guix-patches submitter 36244 Robert Vollmert severity 36244 normal tag 36244 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 16 10:22:01 2019 Received: (at submit) by debbugs.gnu.org; 16 Jun 2019 14:22:01 +0000 Received: from localhost ([127.0.0.1]:41222 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hcW2i-0000EE-Ot for submit@debbugs.gnu.org; Sun, 16 Jun 2019 10:22:01 -0400 Received: from lists.gnu.org ([209.51.188.17]:48711) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hcW2g-0000E4-A9 for submit@debbugs.gnu.org; Sun, 16 Jun 2019 10:22:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34078) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcW2f-0008CP-3x for guix-patches@gnu.org; Sun, 16 Jun 2019 10:21:58 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_LOW, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcVzb-0003Ih-P8 for guix-patches@gnu.org; Sun, 16 Jun 2019 10:18:49 -0400 Received: from mx1.mailbox.org ([80.241.60.212]:17646) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcVzb-0003G4-JG for guix-patches@gnu.org; Sun, 16 Jun 2019 10:18:47 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id C09A04F953; Sun, 16 Jun 2019 16:18:43 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id fAU7ixNWBzsy; Sun, 16 Jun 2019 16:18:35 +0200 (CEST) From: Robert Vollmert To: guix-patches@gnu.org Subject: [PATCH] guix: canonical-newline-port: Fix handling of carriage return at buffer end. Date: Sun, 16 Jun 2019 16:18:29 +0200 Message-Id: <20190616141829.28689-1-rob@vllmrt.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 80.241.60.212 X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit Cc: Robert Vollmert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) Prior to this change the added test fails for me locally at byte 1024. It might depend on some default buffer sizes. Fixes https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D35863 * tests/utils.scm ("canonical-newline-port-1024"): Add test. * guix/utils.scm (canonical-newline-port): Correct comments on CR/LF. Remove CR even when they're at the end of the buffer. --- guix/utils.scm | 6 +++--- tests/utils.scm | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/guix/utils.scm b/guix/utils.scm index 709cdf9353..f480c3291f 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -718,7 +718,7 @@ environment variable name like \"XDG_CONFIG_HOME\"; S= UFFIX is a suffix like =20 (define (canonical-newline-port port) "Return an input port that wraps PORT such that all newlines consist - of a single carriage return." + of a single linefeed." (define (get-position) (if (port-has-port-position? port) (port-position port) #f)) (define (set-position! position) @@ -730,11 +730,11 @@ environment variable name like \"XDG_CONFIG_HOME\";= SUFFIX is a suffix like (let loop ((count 0) (byte (get-u8 port))) (cond ((eof-object? byte) count) + ;; XXX: consume all CRs even if not followed by LF. + ((eqv? byte (char->integer #\return)) (loop count (get-u8 po= rt))) ((=3D count (- n 1)) (bytevector-u8-set! bv (+ start count) byte) n) - ;; XXX: consume all LFs even if not followed by CR. - ((eqv? byte (char->integer #\return)) (loop count (get-u8 po= rt))) (else (bytevector-u8-set! bv (+ start count) byte) (loop (+ count 1) (get-u8 port)))))) diff --git a/tests/utils.scm b/tests/utils.scm index 44861384ab..f78ec356bd 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -230,6 +230,12 @@ skip these tests." "This is a journey\r\nInto the sound\r\nA journey ...\n")= )) (get-string-all (canonical-newline-port port)))) =20 +(test-equal "canonical-newline-port-1024" + (string-concatenate (make-list 100 "0123456789abcde\n")) + (let ((port (open-string-input-port + (string-concatenate + (make-list 100 "0123456789abcde\r\n"))))) + (get-string-all (canonical-newline-port port)))) =20 (test-equal "edit-expression" "(display \"GNU Guix\")\n(newline)\n" --=20 2.20.1 (Apple Git-117) From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 20 08:17:24 2019 Received: (at 36244-done) by debbugs.gnu.org; 20 Jun 2019 12:17:24 +0000 Received: from localhost ([127.0.0.1]:48003 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdw0K-0005rE-Ay for submit@debbugs.gnu.org; Thu, 20 Jun 2019 08:17:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52285) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdw0H-0005qk-H7 for 36244-done@debbugs.gnu.org; Thu, 20 Jun 2019 08:17:21 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:58326) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hdw0B-0008H0-50; Thu, 20 Jun 2019 08:17:16 -0400 Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:45924 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hdvio-00013d-R9; Thu, 20 Jun 2019 07:59:22 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Robert Vollmert Subject: Re: [bug#36244] [PATCH] guix: canonical-newline-port: Fix handling of carriage return at buffer end. References: <20190616141829.28689-1-rob@vllmrt.net> Date: Thu, 20 Jun 2019 13:59:13 +0200 In-Reply-To: <20190616141829.28689-1-rob@vllmrt.net> (Robert Vollmert's message of "Sun, 16 Jun 2019 16:18:29 +0200") Message-ID: <87sgs4jwmm.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 36244-done Cc: 36244-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Robert, Robert Vollmert skribis: > Prior to this change the added test fails for me locally at byte > 1024. It might depend on some default buffer sizes. > > Fixes https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D35863 > > * tests/utils.scm ("canonical-newline-port-1024"): Add test. > * guix/utils.scm (canonical-newline-port): Correct comments on CR/LF. > Remove CR even when they're at the end of the buffer. Good catch. I tweaked the commit log and applied it. Thanks, Ludo=E2=80=99. From unknown Sun Jun 15 08:37:15 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 19 Jul 2019 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator