Always return a simple-string from OCTETS-TO-STRING

UCS and UTF external formats were returning the adjustable array
directly, which wasn't necessarily a disaster in itself but was also
not conforming with the type declaration of OCTETS-TO-STRING, so could
have led to problems in downstream code.
This commit is contained in:
Christophe Rhodes 2023-07-12 21:16:22 +01:00
parent 04c7b03380
commit 6bb16a7dbc
3 changed files with 11 additions and 8 deletions

3
NEWS
View file

@ -40,6 +40,9 @@ changes in the external-format-line-endings branch:
* bug fix: converting from octets using the UCS-2, UCS-4 and UTF-32 external
formats no longer reads past the end of an octet array with a non-integral
number of two- or four-byte units.
* bug fix: converting from octets using the UCS-2, UCS-4, UTF-16 or UTF-32
external formats now returns a simple string, as required by the type
declaration of OCTETS-TO-STRING.
* bug fix: providing an invalid external format argument to OPEN or
WITH-OPEN-FILE (or the internal MAKE-FD-STREAM) no longer leaks a file
descriptor.

View file

@ -220,7 +220,7 @@
(dotimes (i (length instead))
(vector-push-extend (char instead i) string))))
(incf pos bytes)))
string))
(copy-seq string)))
(defun ,name-be (array astart aend replacement)
(declare (optimize speed #.*safety-0*)
(type ,type array)
@ -243,7 +243,7 @@
(dotimes (i (length instead))
(vector-push-extend (char instead i) string))))
(incf pos bytes)))
string)))))
(copy-seq string))))))
(instantiate-octets-definition define-ucs-2->string)
@ -416,7 +416,7 @@
(string (dotimes (i (length thing))
(vector-push-extend (char thing i) string)))))
(incf pos bytes)))
string))
(copy-seq string)))
(defun ,name-be (array astart aend replacement)
(declare (optimize speed #.*safety-0*)
(type ,type array)
@ -438,7 +438,7 @@
(string (dotimes (i (length thing))
(vector-push-extend (char thing i) string)))))
(incf pos bytes)))
string)))))
(copy-seq string))))))
(instantiate-octets-definition define-ucs-4->string)

View file

@ -231,7 +231,7 @@
(t (dotimes (i (length invalid))
(vector-push-extend (char invalid i) string))))
(incf pos bytes)))
string))
(copy-seq string)))
(defun ,name-be (array astart aend replacement)
(declare (optimize speed #.*safety-0*)
(type ,type array)
@ -251,7 +251,7 @@
(t (dotimes (i (length invalid))
(vector-push-extend (char invalid i) string))))
(incf pos bytes)))
string)))))
(copy-seq string))))))
(instantiate-octets-definition define-utf-16->string)
@ -479,7 +479,7 @@
(string (dotimes (i (length thing))
(vector-push-extend (char thing i) string)))))
(incf pos bytes)))
string))
(copy-seq string)))
(defun ,name-be (array astart aend replacement)
(declare (optimize speed #.*safety-0*)
(type ,type array)
@ -501,7 +501,7 @@
(string (dotimes (i (length thing))
(vector-push-extend (char thing i) string)))))
(incf pos bytes)))
string)))))
(copy-seq string))))))
(instantiate-octets-definition define-utf-32->string)