guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/03: serialization: Read Latin-1 strings with 'get-bytevector-n'.


From: Ludovic Courtès
Subject: 02/03: serialization: Read Latin-1 strings with 'get-bytevector-n'.
Date: Sun, 18 Jan 2015 21:22:33 +0000

civodul pushed a commit to branch master
in repository guix.

commit aa27b56083f1b4f05db11bfb160860ed6af34e2b
Author: Ludovic Courtès <address@hidden>
Date:   Sun Jan 18 22:17:09 2015 +0100

    serialization: Read Latin-1 strings with 'get-bytevector-n'.
    
    * guix/serialization.scm (read-latin1-string): Use 'get-bytevector-n'
      instead of 'get-string-n'.  Use 'list->string' etc. to convert the
      bytevector to a string.
---
 guix/serialization.scm |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/guix/serialization.scm b/guix/serialization.scm
index 64eacf9..e36751e 100644
--- a/guix/serialization.scm
+++ b/guix/serialization.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <address@hidden>
+;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <address@hidden>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -102,10 +102,16 @@
 (define (read-latin1-string p)
   (let* ((len (read-int p))
          (m   (modulo len 8))
-         (str (get-string-n p len)))
+         ;; Note: do not use 'get-string-n' to work around Guile bug
+         ;; <http://bugs.gnu.org/19621>.  See <http://bugs.gnu.org/19610> for
+         ;; a discussion.
+         (str (get-bytevector-n p len)))
     (or (zero? m)
         (get-bytevector-n p (- 8 m)))
-    str))
+
+    ;; XXX: Rewrite using (ice-9 iconv) when the minimum requirement is
+    ;; upgraded to Guile >= 2.0.9.
+    (list->string (map integer->char (bytevector->u8-list str)))))
 
 (define (write-string-list l p)
   (write-int (length l) p)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]