emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/slime 6ef28864d4 13/43: Handle null characters correctly i


From: ELPA Syncer
Subject: [nongnu] elpa/slime 6ef28864d4 13/43: Handle null characters correctly in the Allegro backend.
Date: Thu, 28 Dec 2023 22:00:29 -0500 (EST)

branch: elpa/slime
commit 6ef28864d4a6b4d9390dbd0cac64f2a56582682d
Author: Robert Brown <robert.brown@gmail.com>
Commit: Luís Oliveira <luismbo@gmail.com>

    Handle null characters correctly in the Allegro backend.
    
    The Allegro function EXCL:OCTETS-TO-STRING, at least in Free Express Edition
    10.1, stops processing octets when it encounters a null character, unless 
the
    target of octet conversion is an existing string.  Work around the behavior
    in UTF8-TO-STRING.
    
    Modify test utf-8-source in slime-tests.el so that it includes a null
    character.
---
 slime-tests.el     | 7 ++++---
 swank/allegro.lisp | 9 +++++++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/slime-tests.el b/slime-tests.el
index b122119ee8..5a6c7767f3 100644
--- a/slime-tests.el
+++ b/slime-tests.el
@@ -735,9 +735,10 @@ Confirm that SUBFORM is correctly located."
 (def-slime-test utf-8-source
     (input output)
     "Source code containing utf-8 should work"
-    (list (let*  ((bytes "\343\201\212\343\201\257\343\202\210\343\201\206")
-                  ;;(encode-coding-string (string #x304a #x306f #x3088 #x3046)
-                  ;;                      'utf-8)
+    (list (let*  ((bytes 
"\000\343\201\212\343\201\257\343\202\210\343\201\206")
+                  ;; (encode-coding-string
+                  ;;   (string #x0000 #x304a #x306f #x3088 #x3046)
+                  ;;   'utf-8)
                   (string (decode-coding-string bytes 'utf-8-unix)))
             (cl-assert (equal bytes (encode-coding-string string 'utf-8-unix)))
             (list (concat "(defun cl-user::foo () \"" string "\")")
diff --git a/swank/allegro.lisp b/swank/allegro.lisp
index 9df6874afd..61ea12074b 100644
--- a/swank/allegro.lisp
+++ b/swank/allegro.lisp
@@ -41,8 +41,13 @@
   (excl:string-to-octets s :external-format utf8-ef
                          :null-terminate nil))
 
-(defimplementation utf8-to-string (u)
-  (excl:octets-to-string u :external-format utf8-ef))
+(defimplementation utf8-to-string (octets)
+  (let ((string (make-string (length octets))))
+    (multiple-value-bind (string chars-copied)
+        ;; Allegro 10.1 stops processing octets when it sees a zero,
+        ;; unless it is copying into an existing string.
+        (excl:octets-to-string octets :string string :external-format utf8-ef)
+      (subseq string 0 chars-copied))))
 
 
 ;;;; TCP Server



reply via email to

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