GNU bug report logs - #36244
[PATCH] guix: canonical-newline-port: Fix handling of carriage return at buffer end.

Previous Next

Package: guix-patches;

Reported by: Robert Vollmert <rob <at> vllmrt.net>

Date: Sun, 16 Jun 2019 14:22:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 36244 in the body.
You can then email your comments to 36244 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#36244; Package guix-patches. (Sun, 16 Jun 2019 14:22:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Robert Vollmert <rob <at> vllmrt.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 16 Jun 2019 14:22:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Robert Vollmert <rob <at> vllmrt.net>
To: guix-patches <at> gnu.org
Cc: Robert Vollmert <rob <at> vllmrt.net>
Subject: [PATCH] guix: canonical-newline-port: Fix handling of carriage return
 at buffer end.
Date: Sun, 16 Jun 2019 16:18:29 +0200
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=35863

* 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\"; SUFFIX is a suffix like
 
 (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 port)))
             ((= 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 port)))
             (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))))
 
+(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))))
 
 (test-equal "edit-expression"
   "(display \"GNU Guix\")\n(newline)\n"
-- 
2.20.1 (Apple Git-117)





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Thu, 20 Jun 2019 12:18:02 GMT) Full text and rfc822 format available.

Notification sent to Robert Vollmert <rob <at> vllmrt.net>:
bug acknowledged by developer. (Thu, 20 Jun 2019 12:18:02 GMT) Full text and rfc822 format available.

Message #10 received at 36244-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Robert Vollmert <rob <at> vllmrt.net>
Cc: 36244-done <at> debbugs.gnu.org
Subject: Re: [bug#36244] [PATCH] guix: canonical-newline-port: Fix handling of
 carriage return at buffer end.
Date: Thu, 20 Jun 2019 13:59:13 +0200
Hi Robert,

Robert Vollmert <rob <at> vllmrt.net> 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=35863
>
> * 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’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 19 Jul 2019 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 282 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.