Show
Ignore:
Timestamp:
05/27/06 10:35:24 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/emacs-lisp/bindat.el

    r4037 r4091  
    172172;;          |  DEREF 
    173173 
    174 ;; DEREF   ::= ( [NAME | INTEGER]... )  -- Field NAME or Array index relative to 
    175 ;;                                         current structure spec. 
     174;; DEREF   ::= ( [NAME | INTEGER]... )  -- Field NAME or Array index relative 
     175;;                                         to current structure spec. 
    176176;;                                      -- see bindat-get-field 
    177177 
     
    346346(defun bindat-unpack (spec raw-data &optional pos) 
    347347  "Return structured data according to SPEC for binary data in RAW-DATA. 
    348 RAW-DATA is a string or vector.  Optional third arg POS specifies the 
    349 starting offset in RAW-DATA." 
     348RAW-DATA is a unibyte string or vector.  Optional third arg POS specifies 
     349the starting offset in RAW-DATA." 
     350  (when (multibyte-string-p raw-data) 
     351    (error "String is multibyte")) 
    350352  (unless pos (setq pos 0)) 
    351353  (bindat--unpack-group spec)) 
     
    416418          (let ((index 0)) 
    417419            (while (< index len) 
    418               (bindat--length-group (nth index (bindat-get-field struct field)) (nthcdr tail item)) 
     420              (bindat--length-group 
     421               (nth index (bindat-get-field struct field)) 
     422               (nthcdr tail item)) 
    419423              (setq index (1+ index))))) 
    420424         ((eq type 'union) 
     
    437441 
    438442(defun bindat-length (spec struct) 
    439   "Calculate raw-data length for STRUCT according to bindat specification SPEC." 
     443  "Calculate raw-data length for STRUCT according to bindat SPEC." 
    440444  (let ((pos 0)) 
    441445    (bindat--length-group struct spec) 
     
    558562          (let ((index 0)) 
    559563            (while (< index len) 
    560               (bindat--pack-group (nth index (bindat-get-field struct field)) (nthcdr tail item)) 
     564              (bindat--pack-group 
     565               (nth index (bindat-get-field struct field)) 
     566               (nthcdr tail item)) 
    561567              (setq index (1+ index))))) 
    562568         ((eq type 'union) 
     
    578584(defun bindat-pack (spec struct &optional raw-data pos) 
    579585  "Return binary data packed according to SPEC for structured data STRUCT. 
    580 Optional third arg RAW-DATA is a pre-allocated string or vector to unpack into. 
    581 Optional fourth arg POS is the starting offset into RAW-DATA. 
    582 Note: The result is a multibyte string; use `string-make-unibyte' on it 
    583 to make it unibyte if necessary." 
     586Optional third arg RAW-DATA is a pre-allocated unibyte string or vector to 
     587pack into.  Optional fourth arg POS is the starting offset into RAW-DATA." 
     588  (when (multibyte-string-p raw-data) 
     589    (error "Pre-allocated string is multibyte")) 
    584590  (let ((no-return raw-data)) 
    585591    (unless pos (setq pos 0)) 
    586     (unless raw-data (setq raw-data (make-vector (+ pos (bindat-length spec struct)) 0))) 
     592    (unless raw-data 
     593      (setq raw-data (make-vector (+ pos (bindat-length spec struct)) 0))) 
    587594    (bindat--pack-group struct spec) 
    588595    (if no-return nil (concat raw-data))))