mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
bindat (str, strz): Reject non-ASCII, non-`eight-bit' characters
* lisp/emacs-lisp/bindat.el (str) (strz): Signal an error if the user attempts to pack a multibyte string containing characters other than ASCII and `eight-bit' characters (bug#55897). * doc/lispref/processes.texi (Bindat Types): Update documentation. * test/lisp/emacs-lisp/bindat-tests.el (str) (strz): Add tests.
This commit is contained in:
parent
c2695621fc
commit
c1829b307c
3 changed files with 32 additions and 8 deletions
|
|
@ -435,12 +435,14 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
|
|||
(bindat--pack-u32r (ash v -32)))
|
||||
|
||||
(defun bindat--pack-str (len v)
|
||||
(dotimes (i (min len (length v)))
|
||||
(aset bindat-raw (+ bindat-idx i) (aref v i)))
|
||||
(setq bindat-idx (+ bindat-idx len)))
|
||||
(let ((v (string-to-unibyte v)))
|
||||
(dotimes (i (min len (length v)))
|
||||
(aset bindat-raw (+ bindat-idx i) (aref v i)))
|
||||
(setq bindat-idx (+ bindat-idx len))))
|
||||
|
||||
(defun bindat--pack-strz (v)
|
||||
(let ((len (length v)))
|
||||
(let* ((v (string-to-unibyte v))
|
||||
(len (length v)))
|
||||
(dotimes (i len)
|
||||
(aset bindat-raw (+ bindat-idx i) (aref v i)))
|
||||
(setq bindat-idx (+ bindat-idx len 1))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue