summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorThien-Thi Nguyen <ttn@gnuvola.org>2006-05-25 08:51:31 +0000
committerThien-Thi Nguyen <ttn@gnuvola.org>2006-05-25 08:51:31 +0000
commit5299552dcadb2c140cd37f64b325323c19634c3f (patch)
tree35e84492ed84b578ecf095b19135d945c8083718 /lisp/emacs-lisp
parentcde00df601d2c75adef41ea06776cce9d9f87dd5 (diff)
downloademacs-5299552dcadb2c140cd37f64b325323c19634c3f.tar.gz
emacs-5299552dcadb2c140cd37f64b325323c19634c3f.tar.bz2
emacs-5299552dcadb2c140cd37f64b325323c19634c3f.zip
(bindat-unpack, bindat-pack):
Signal error if RAW-DATA is a multibyte string.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/bindat.el14
1 files changed, 8 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/bindat.el b/lisp/emacs-lisp/bindat.el
index 823fcf869b6..377ff8cc27e 100644
--- a/lisp/emacs-lisp/bindat.el
+++ b/lisp/emacs-lisp/bindat.el
@@ -345,8 +345,10 @@
(defun bindat-unpack (spec raw-data &optional pos)
"Return structured data according to SPEC for binary data in RAW-DATA.
-RAW-DATA is a string or vector. Optional third arg POS specifies the
-starting offset in RAW-DATA."
+RAW-DATA is a unibyte string or vector. Optional third arg POS specifies
+the starting offset in RAW-DATA."
+ (when (multibyte-string-p raw-data)
+ (error "String is multibyte"))
(unless pos (setq pos 0))
(bindat--unpack-group spec))
@@ -581,10 +583,10 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
(defun bindat-pack (spec struct &optional raw-data pos)
"Return binary data packed according to SPEC for structured data STRUCT.
-Optional third arg RAW-DATA is a pre-allocated string or vector to pack into.
-Optional fourth arg POS is the starting offset into RAW-DATA.
-Note: The result is a multibyte string; use `string-make-unibyte' on it
-to make it unibyte if necessary."
+Optional third arg RAW-DATA is a pre-allocated unibyte string or vector to
+pack into. Optional fourth arg POS is the starting offset into RAW-DATA."
+ (when (multibyte-string-p raw-data)
+ (error "Pre-allocated string is multibyte"))
(let ((no-return raw-data))
(unless pos (setq pos 0))
(unless raw-data