aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThien-Thi Nguyen2006-05-25 08:51:31 +0000
committerThien-Thi Nguyen2006-05-25 08:51:31 +0000
commit5299552dcadb2c140cd37f64b325323c19634c3f (patch)
tree35e84492ed84b578ecf095b19135d945c8083718
parentcde00df601d2c75adef41ea06776cce9d9f87dd5 (diff)
downloademacs-5299552dcadb2c140cd37f64b325323c19634c3f.tar.gz
emacs-5299552dcadb2c140cd37f64b325323c19634c3f.zip
(bindat-unpack, bindat-pack):
Signal error if RAW-DATA is a multibyte string.
-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 @@
345 345
346(defun bindat-unpack (spec raw-data &optional pos) 346(defun bindat-unpack (spec raw-data &optional pos)
347 "Return structured data according to SPEC for binary data in RAW-DATA. 347 "Return structured data according to SPEC for binary data in RAW-DATA.
348RAW-DATA is a string or vector. Optional third arg POS specifies the 348RAW-DATA is a unibyte string or vector. Optional third arg POS specifies
349starting offset in RAW-DATA." 349the starting offset in RAW-DATA."
350 (when (multibyte-string-p raw-data)
351 (error "String is multibyte"))
350 (unless pos (setq pos 0)) 352 (unless pos (setq pos 0))
351 (bindat--unpack-group spec)) 353 (bindat--unpack-group spec))
352 354
@@ -581,10 +583,10 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
581 583
582(defun bindat-pack (spec struct &optional raw-data pos) 584(defun bindat-pack (spec struct &optional raw-data pos)
583 "Return binary data packed according to SPEC for structured data STRUCT. 585 "Return binary data packed according to SPEC for structured data STRUCT.
584Optional third arg RAW-DATA is a pre-allocated string or vector to pack into. 586Optional third arg RAW-DATA is a pre-allocated unibyte string or vector to
585Optional fourth arg POS is the starting offset into RAW-DATA. 587pack into. Optional fourth arg POS is the starting offset into RAW-DATA."
586Note: The result is a multibyte string; use `string-make-unibyte' on it 588 (when (multibyte-string-p raw-data)
587to make it unibyte if necessary." 589 (error "Pre-allocated string is multibyte"))
588 (let ((no-return raw-data)) 590 (let ((no-return raw-data))
589 (unless pos (setq pos 0)) 591 (unless pos (setq pos 0))
590 (unless raw-data 592 (unless raw-data