From 34dc1a4d39f9c11628b0c9a2bb3c080d6df20983 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 28 May 2022 23:53:51 -0400 Subject: [PATCH 3/7] ; bindat (strz): Consistent length type check The strz length computation uses `numberp' to switch between fixed-length and variable-length modes, so packing should too. --- lisp/emacs-lisp/bindat.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lisp/emacs-lisp/bindat.el b/lisp/emacs-lisp/bindat.el index b236e47e5b..1a7ff625ee 100644 --- a/lisp/emacs-lisp/bindat.el +++ b/lisp/emacs-lisp/bindat.el @@ -693,13 +693,13 @@ bindat--type (t `(or ,len (1+ (length ,val))))))) (`(pack . ,args) (macroexp-let2 nil len len - `(if ,len - ;; Same as non-zero terminated strings since we don't actually add - ;; the terminating zero anyway (because we rely on the fact that - ;; `bindat-raw' was presumably initialized with all-zeroes before - ;; we started). - (bindat--pack-str ,len . ,args) - (bindat--pack-strz . ,args)))))) + (if (numberp len) + ;; Same as non-zero terminated strings since we don't actually add + ;; the terminating zero anyway (because we rely on the fact that + ;; `bindat-raw' was presumably initialized with all-zeroes before + ;; we started). + `(bindat--pack-str ,len . ,args) + `(bindat--pack-strz . ,args)))))) (cl-defmethod bindat--type (op (_ (eql 'bits)) len) (bindat--pcase op -- 2.36.1