summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/bindat.el
Commit message (Collapse)AuthorAge
* ; Add 2023 to copyright years.Eli Zaretskii2023-01-01
|
* Bindat (src, strz): Operate on vectors tooNacho Barrientos2022-10-21
| | | | | | | | | | Copyright-paperwork-exempt: yes * lisp/emacs-lisp/bindat.el (bindat--unpack-str, bindat--unpack-strz): Fix the non-string case. * test/lisp/emacs-lisp/bindat-tests.el (bindat-test--strz-array-unpack) (bindat-test--str-simple-array-unpack,bindat-test--str-combined-array-unpack): New tests.
* bindat (strz): Null terminate fixed-length strings if there is roomRichard Hansen2022-06-22
| | | | | | | | | * lisp/emacs-lisp/bindat.el (bindat--pack-strz): For fixed-length strz fields, explicitly write a null terminator after the packed string if there is room (bug#56048). * doc/lispref/processes.texi (Bindat Types): Update documentation. * test/lisp/emacs-lisp/bindat-tests.el (bindat-test--str-strz-prealloc): Update tests.
* ; bindat (strz): Move all pack logic to pack function (bug#56048)Richard Hansen2022-06-22
| | | | | | | | | | Motivation/rationale: * Improve code readability. Now `bindat--pack-strz` is used for all `strz` packing, not just variable-length `strz` packing. * Make it easier to change the behavior of fixed-length `strz` packing without also affecting the behavior of `str` packing. (A future commit will modify `strz` to write a null terminator if there is room.)
* bindat (strz): Write null terminator after variable length stringRichard Hansen2022-06-16
| | | | | | | | | * lisp/emacs-lisp/bindat.el (bindat--pack-strz): Explicitly write a null byte after packing a variable-length string to ensure proper termination when packing to a pre-allocated string. * doc/lispref/processes.texi (Bindat Types): Update documentation. * test/lisp/emacs-lisp/bindat-tests.el (bindat-test--str-strz-prealloc): Update tests.
* bindat (strz): Error on null byte if packing variable-length stringRichard Hansen2022-06-13
| | | | | | * lisp/emacs-lisp/bindat.el (strz): Signal an error if a null byte is encountered while packing a string to a variable-length strz field. * test/lisp/emacs-lisp/bindat-tests.el (strz): Add tests (bug#55938).
* bindat (str, strz): Reject non-ASCII, non-`eight-bit' charactersRichard Hansen2022-06-12
| | | | | | | | * 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.
* Bindat: Document `sint`; add `le` arg to `uint`; deprecate `uintr`Stefan Monnier2022-06-11
| | | | | | | | | | | | | | | * lisp/emacs-lisp/bindat.el (bindat--type) <uint>: Add `le` optional arg. (bindat--type) <uintr>: Delete method. (uintr): Re-define as a bindat-macro instead. (bindat-type): Update docstring accordingly. (bindat--primitives): Update. (sint): Simplify. * doc/lispref/processes.texi (Bindat Types): Update `uint`, add `sint`, and remove `uintr`. * test/lisp/emacs-lisp/bindat-tests.el (data-bindat-spec): Use the new `le` arg of `uint` instead of `uintr`.
* ; bindat (bindat--length-group): Fix indentationRichard Hansen2022-06-10
|
* ; bindat (strz): Consistent length type check, take twoRichard Hansen2022-06-10
| | | | | | | | | | | Commit 30ec4a7347b2944818c6fc469ae871374ce7caa4 is incorrect -- the length computation logic uses a simple nilness test, not `numberp'. The `numberp' case is just an optimization if `len' is a literal number; it does not affect the behavior. Revert that commit, add some comments to help future readers avoid the same mistake, and update the pack logic to use the same optimization as the length computation for consistency.
* bindat (strz): Fix wrong-type-argument error when unpackingRichard Hansen2022-06-01
| | | | | | | * lisp/emacs-lisp/bindat.el (strz): Fix (wrong-type-argument number-or-marker-p nil) error when unpacking a strz with unspecified (variable) length. * test/lisp/emacs-lisp/bindat-tests.el (strz): Mark test as passing.
* ; bindat (strz): Consistent length type checkRichard Hansen2022-06-01
| | | | | The strz length computation uses `numberp' to switch between fixed-length and variable-length modes, so packing should too.
* bindat (strz): Fix off-by-one bug in computed lengthRichard Hansen2022-06-01
| | | | | | * lisp/emacs-lisp/bindat.el (strz): Include null terminator when computing packed string length. * test/lisp/emacs-lisp/bindat-tests.el (strz): Mark tests as passing.
* (macroexp-warn-and-return): Fix bug#53618Stefan Monnier2022-02-19
| | | | | | | | | | | | | | | | * lisp/emacs-lisp/macroexp.el (macroexp-warn-and-return): Reorder arguments to preserve compatibility with that of Emacs-28. (macroexp--unfold-lambda, macroexp--expand-all): * lisp/emacs-lisp/pcase.el (pcase-compile-patterns, pcase--u1): * lisp/emacs-lisp/gv.el (gv-ref): * lisp/emacs-lisp/eieio.el (defclass): * lisp/emacs-lisp/eieio-core.el (eieio-oref, eieio-oref-default) (eieio-oset-default): * lisp/emacs-lisp/easy-mmode.el (define-minor-mode): * lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet, cl-defstruct): * lisp/emacs-lisp/cl-generic.el (cl-defmethod): * lisp/emacs-lisp/byte-run.el (defmacro, defun): * lisp/emacs-lisp/bindat.el (bindat--type): Adjust accordingly.
* Merge branch 'master' into scratch/correct-warning-posAlan Mackenzie2022-01-11
|\
| * ; Add 2022 to copyright years.Eli Zaretskii2022-01-01
| |
* | Several amendments to scratch/correct-warning-pos.Alan Mackenzie2021-12-01
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The position return by read-positioning-symbols is now the position in the buffer, rather than the offset from the start of a form, enabling warning positions in other parts of the buffer to be output. * src/lisp.h (lisp_h_EQ): Add XLI casts so that it compiles cleanly. * src/data.c (Fremove_pos_from_symbol): New DEFUN. * src/lread.c (readchar_count): renamed to readchar_offset. (read_internal_start) Initialize readchar_offset to the buffer's point when STREAM is a buffer. * lisp/emacs-lisp/bytecomp.el (byte-compile-warning-prefix): Amend to use OFFSET as a buffer position, not an offset from the start of a form. (byte-compile-warn): Remove symbol positions from any shape of ARGS, not just a symbol with position. * lisp/emacs-lisp/cconv.c (cconv-convert): In the :unused case, position the new IGNORE symbol with the VAR it has replaced. * lisp/emacs-lisp/macroexp.el (macroexp--warn-wrap, macroexp-warn-and-return): Add an extra position parameter to each. * lisp/emacs-lisp/bindat.el (bindat-type), lisp/emacs-lisp/byte-run.el (defmacro, defun), lisp/emacs-lisp/cconv.el (cconv--convert-func-body) (cconv-convert), lisp/emacs-lisp/cl-generic.el (cl-defmethod), lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet, cl-defstruct), lisp/emacs-lisp/easy-mmode.el (define-minor-mode), lisp/emacs-lisp/eieio-core.el (eieio-oref, eieio-oref-default) (eieio-oset-default), lisp/emacs-lisp/eieio.el (defclass), lisp/emacs-lisp/gv.el (gv-ref), lisp/emacs-lisp/macroexp.el (macroexp-macroexpand, macroexp--unfold-lambda, macroexp--expand-all), lisp/emacs-lisp/pcase.el (pcase-compile-patterns, pcase--u1): Add an extra position argument to each call of macroexp-warn-and-return.
* Evaluate eql specializersakater2021-08-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/cl-generic.el (cl-generic-generalizers): Evaluate forms that are eql specializers. Provide backward compatibility with a warning. * test/lisp/emacs-lisp/cl-generic-tests.el: Add a test. * lisp/emacs-lisp/bindat.el (bindat--type): Adhere to the new rule. * lisp/emacs-lisp/edebug.el (edebug--match-&-spec-op): Adhere to the new rule. * lisp/emacs-lisp/map.el (map-into): Adhere to the new rule. * lisp/emacs-lisp/radix-tree.el (map-into): Adhere to the new rule. * lisp/frame.el (cl-generic-define-context-rewriter): Adhere to the new rule. * lisp/gnus/gnus-search.el (gnus-search-transform-expression): Adhere to the new rule. * lisp/image/image-converter.el (image-converter--probe image-converter--convert): Adhere to the new rule. * lisp/mail/smtpmail.el (smtpmail-try-auth-method): Adhere to the new rule. * lisp/progmodes/elisp-mode.el (xref-backend-definitions) (xref-backend-apropos): Adhere to the new rule. * lisp/progmodes/etags.el (xref-backend-identifier-at-point) (xref-backend-identifier-completion-table) (xref-backend-identifier-completion-ignore-case) (xref-backend-definitions)(xref-backend-apropos): Adhere to the new rule. * test/lisp/emacs-lisp/checkdoc-tests.el (checkdoc-cl-defmethod-with-types-ok) (checkdoc-cl-defmethod-qualified-ok) (checkdoc-cl-defmethod-with-extra-qualifier-ok): Adhere to the new rule. * etc/NEWS: Describe the change.
* * lisp/emacs-lisp/bindat.el: Allow non-fixed size of `strz`Stefan Monnier2021-04-15
| | | | | | | | | (bindat--unpack-strz): Allow `len` to be nil. (bindat--pack-strz): New function. (bindat--type) <strz>: Make `len` arg optional. (bindat-type): Adjust debug spec and docstring accordingly. * doc/lispref/processes.texi (Bindat Types): Adjust accordingly.
* * lisp/emacs-lisp/bindat.el (bindat-struct): Fix Edebug defStefan Monnier2021-03-06
|
* Bindat: new macro-expansion based data layout languageStefan Monnier2021-03-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Thorough redesign of the Bindat system, which makes it possible to define new Bindat type forms, define recursive types, control the values returned when unpacking, freely mix arbitrary computations with type definitions, as well as support for arbitrary sized integers. This also reverts the recent addition of the `bindat-spec` macro and the support for 64bit integers in the old Bindat language since that is now considered obsolete anyway. * doc/lispref/processes.texi (Bindat Types): Rename from `Bindat Spec` and rewrite for the new sublanguage. (Bindat Functions): Adjust to the new terminology. (Bindat Computed Types): New node. * lisp/emacs-lisp/bindat.el (bindat--type): New type. (bindat--unpack-u64, bindat--unpack-u64r): Delete functions. (bindat--unpack-item, bindat--pack-item, bindat--fixed-length-alist): Revert addition of support for 64bit integers. (bindat--unpack-group, bindat--length-group, bindat--pack-group): Handle the new `bindat--type` values. (bindat-spec): Revert addition of this macro. (bindat--unpack-uint, bindat--unpack-uintr, bindat--pack-uint) (bindat--pack-uintr): New functions. (bindat-type, bindat-defmacro, bindat--pcase): New macros. (bindat-type): New Edebug elem. (bindat--type): New generic function. (bindat--primitives): New constant. (bindat--macroenv, bindat--op): New vars. (bindat--make-docstring, bindat--fun, bindat--makefun, bindat--toplevel): New functions. * test/lisp/emacs-lisp/bindat-tests.el: Use `bindat-type`. (ip): New Bindat type. (header-bindat-spec, data-bindat-spec, packet-bindat-spec): Adjust to new `bindat-type` macro. (bindat-test-unpack): Simplify now that the order of fields is preserved. (bindat-test--int-websocket-type, bindat-test--LEB128): New consts. (bindat-test--pack-val, bindat-test--sint, bindat-test--recursive): New tests.
* * lisp/emacs-lisp/bindat.el: Minor refactoringStefan Monnier2021-03-05
| | | | | | | | | | | | | | | | (bindat--unpack-str, bindat--unpack-strz, bindat--unpack-bits): New functions, extracted from `bindat--unpack-item`. (bindat--unpack-item): Use them. (bindat--align): New function. (bindat--unpack-group, bindat--length-group, bindat--pack-group): Use it. (bindat-get-field): Allow integers to index both lists (as returned by `repeat`) and vectors (as returned by `vec`). (bindat--pack-str, bindat--pack-bits): New functions, extracted from `bindat--pack-item`. (bindat--pack-item): Use them. * test/lisp/emacs-lisp/bindat-tests.el (struct-bindat): Place the fields in the order in which they appear in the structs.
* * lisp/emacs-lisp/bindat.el: Tweak example in commentStefan Monnier2021-02-18
| | | | Suggested by Kim Storm <storm@cua.dk>.
* * lisp/emacs-lisp/bindat.el: Add 64bit int supportStefan Monnier2021-02-15
| | | | | | | (bindat--unpack-u64, bindat--unpack-u64r, bindat--pack-u64) (bindat--pack-u64r): New functions. (bindat--unpack-item, bindat--pack-item): Use them. (bindat--fixed-length-alist): Add new types.
* * lisp/emacs-lisp/bindat.el: Clarify when field labels are optionalStefan Monnier2021-02-15
| | | | | | | | | | | | The fixes the doc and the Edebug spec, as well as a subtle issue in the code where a field whose name is (eval 'fill) was mistakenly considered as an anonymous field of type `fill`. (bindat--unpack-item, bindat--unpack-group, bindat--length-group) (bindat--pack-item, bindat--pack-group): Use dotimes, dolist, and pcase. (bindat--item-aux): New edebug elem. (bindat-item): Use it to fix the handling of optional fields. (bindat-format-vector): Use `mapconcat`.
* * lisp/emacs-lisp/bindat.el (bindat-spec): New macro.Stefan Monnier2021-02-15
| | | | | | | | | | | | | | It's basically an alias for `quote`, but it offers the advantage of providing Edebug support and opens the possibility of compiling the bindat spec to ELisp code. * doc/lispref/processes.texi (Bindat Spec): Document `bindat-spec`. (Bindat Functions): Tweak a few things to adjust to the state of the code. * test/lisp/emacs-lisp/bindat-tests.el: Use it. * test/lisp/emacs-lisp/edebug-tests.el (edebug-tests--read): New function. (edebug-tests--&rest-behavior): New test.
* * lisp/emacs-lisp/bindat.el: Expose the `struct` variable (bug#46534)Stefan Monnier2021-02-15
| | | | | (bindat--unpack-group, bindat--length-group, bindat--pack-group): Mark it as dynamically scoped.
* Use lexical-binding in all of `lisp/emacs-lisp`Stefan Monnier2021-01-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/bindat.el: Use lexical-binding. (bindat--unpack-group, bindat--length-group, bindat--pack-group): Declare `last` and `tag` as dyn-scoped. (bindat-unpack, bindat-pack): Bind `bindat-raw` and `bindat-idx` via `let` rather than via the formal arglist. * lisp/emacs-lisp/package-x.el: * lisp/emacs-lisp/generic.el: * lisp/emacs-lisp/eieio-opt.el: * lisp/emacs-lisp/derived.el: * lisp/emacs-lisp/crm.el: Use lexical-binding. * lisp/emacs-lisp/helper.el: Use lexical-binding. (Helper-help-map): Move initialization into declaration. * lisp/emacs-lisp/regi.el: Use lexical-binding. (regi-interpret): Remove unused var `tstart`. Declare `curframe`, `curentry` and `curline` as dyn-scoped. * lisp/emacs-lisp/shadow.el: Use lexical-binding. (load-path-shadows-find): Remove unused var `file`. Tighten a regexp, use `push`. * lisp/emacs-lisp/tcover-ses.el: Use lexical-binding. Require `ses`. Remove correspondingly redundant declarations. (ses--curcell-overlay): Declare. (ses-exercise): Use `dlet` and use a properly-prefixed var name. Fix name of `curcell-overlay` variable. * lisp/emacs-lisp/unsafep.el: Use lexical-binding. (unsafep): Bind `unsafep-vars` via `let` rather than via the formal arglist.
* Update copyright year to 2021Paul Eggert2021-01-01
| | | | Run "TZ=UTC0 admin/update-copyright".
* Revert "Use lexical-binding in bindat.el"Stefan Kangas2020-10-24
| | | | | | | | | This reverts commit a497b8e4a41e3223089654da4b36d0fdd51ce555. This conversion to lexical-binding broke the eval specification, documented in the ELisp manual. We will probably want to add tests for that before we can confidently convert this to lexical-binding. Problem reported by Mattias EngdegÄrd <mattiase@acm.org>.
* ; * lisp/emacs-lisp/bindat.el (bindat-unpack): Fix typo.Stefan Kangas2020-10-21
|
* Use lexical-binding in bindat.elStefan Kangas2020-10-21
| | | | | | | | | | * lisp/emacs-lisp/bindat.el: Use lexical-binding. (bindat-raw, bindat-idx, bindat-unpack, bindat-pack): Adjust for lexical-binding. (bindat--unpack-group, bindat--length-group): Fix byte-compiler warning about unused variables last and vlen. (bindat--unpack-group, bindat--length-group, bindat--pack-group) (bindat-format-vector): Quote function symbols as such.
* Add new tests to bindat-tests.elStefan Kangas2020-04-29
| | | | | | | * test/lisp/emacs-lisp/bindat-tests.el (bindat-test-format-vector) (bindat-test-vector-to-dec, bindat-test-vector-to-hex) (bindat-test-ip-to-string): New tests. * lisp/emacs-lisp/bindat.el (bindat-vector-to-hex): Fix typo.
* * lisp/emacs-lisp/bindat.el: Remove obsolete comment.Paul Eggert2020-01-04
|
* Update copyright year to 2020Paul Eggert2020-01-01
| | | | Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
* Fix byte compilation warning in bindat.elLars Ingebrigtsen2019-06-15
| | | | | | * lisp/emacs-lisp/bindat.el (bindat--unpack-item): Avoid a byte compilation warning by using unibyte-string instead of concat + string-make-unibyte.
* Merge from origin/emacs-26Paul Eggert2018-12-31
|\ | | | | | | | | | | 2fcf2df Fix copyright years by hand 26bed8b Update copyright year to 2019 2814292 Fix value of default frame height. (Bug#33921)
| * Update copyright year to 2019Paul Eggert2019-01-01
| | | | | | | | Run 'TZ=UTC0 admin/update-copyright $(git ls-files)'.
* | Audit use of lsh and fix glitchesPaul Eggert2018-08-21
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I audited use of lsh in the Lisp source code, and fixed the glitches that I found. While I was at it, I replaced uses of lsh with ash when either will do. Replacement is OK when either argument is known to be nonnegative, or when only the low-order bits of the result matter, and is a (minor) win since ash is a bit more solid than lsh nowadays, and is a bit faster. * lisp/calc/calc-ext.el (math-check-fixnum): Prefer most-positive-fixnum to (lsh -1 -1). * lisp/vc/vc-hg.el (vc-hg-state-fast): When testing fixnum width, prefer (zerop (ash most-positive-fixnum -32)) to (zerop (lsh -1 32)) (Bug#32485#11). * lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode): Tighten sanity-check for bytecode overflow, by checking that the result of (ash pc -8) is nonnegative. Formerly this check was not needed since lsh was used and the number overflowed differently. * lisp/net/dns.el (dns-write): Fix some obvious sign typos in shift counts. Evidently this part of the code has never been exercised. * lisp/progmodes/hideif.el (hif-shiftleft, hif-shiftright): * lisp/term/common-win.el (x-setup-function-keys): Simplify. * admin/unidata/unidata-gen.el, admin/unidata/uvs.el: * doc/lispref/keymaps.texi, doc/lispref/syntax.texi: * doc/misc/calc.texi, doc/misc/cl.texi, etc/NEWS.19: * lisp/arc-mode.el, lisp/calc/calc-bin.el, lisp/calc/calc-comb.el: * lisp/calc/calc-ext.el, lisp/calc/calc-math.el: * lisp/cedet/semantic/wisent/comp.el, lisp/composite.el: * lisp/disp-table.el, lisp/dos-fns.el, lisp/edmacro.el: * lisp/emacs-lisp/bindat.el, lisp/emacs-lisp/byte-opt.el: * lisp/emacs-lisp/bytecomp.el, lisp/emacs-lisp/cl-extra.el: * lisp/erc/erc-dcc.el, lisp/facemenu.el, lisp/gnus/message.el: * lisp/gnus/nndoc.el, lisp/gnus/nnmaildir.el, lisp/image.el: * lisp/international/ccl.el, lisp/international/fontset.el: * lisp/international/mule-cmds.el, lisp/international/mule.el: * lisp/json.el, lisp/mail/binhex.el, lisp/mail/rmail.el: * lisp/mail/uudecode.el, lisp/md4.el, lisp/net/dns.el: * lisp/net/ntlm.el, lisp/net/sasl.el, lisp/net/socks.el: * lisp/net/tramp.el, lisp/obsolete/levents.el: * lisp/obsolete/pgg-parse.el, lisp/org/org.el: * lisp/org/ox-publish.el, lisp/progmodes/cc-defs.el: * lisp/progmodes/ebnf2ps.el, lisp/progmodes/hideif.el: * lisp/ps-bdf.el, lisp/ps-print.el, lisp/simple.el: * lisp/tar-mode.el, lisp/term/common-win.el: * lisp/term/tty-colors.el, lisp/term/xterm.el, lisp/vc/vc-git.el: * lisp/vc/vc-hg.el, lisp/x-dnd.el, test/src/data-tests.el: Prefer ash to lsh when either will do.
* Update copyright year to 2018Paul Eggert2018-01-01
| | | | Run admin/update-copyright.
* Prefer HTTPS to FTP and HTTP in documentationPaul Eggert2017-09-13
| | | | | | | | | | | | | Most of this change is to boilerplate commentary such as license URLs. This change was prompted by ftp://ftp.gnu.org's going-away party, planned for November. Change these FTP URLs to https://ftp.gnu.org instead. Make similar changes for URLs to other organizations moving away from FTP. Also, change HTTP to HTTPS for URLs to gnu.org and fsf.org when this works, as this will further help defend against man-in-the-middle attacks (for this part I omitted the MS-DOS and MS-Windows sources and the test tarballs to keep the workload down). HTTPS is not fully working to lists.gnu.org so I left those URLs alone for now.
* Update copyright year to 2017Paul Eggert2016-12-31
| | | | Run admin/update-copyright.
* Update copyright year to 2016Paul Eggert2016-01-01
| | | | Run admin/update-copyright.
* Update copyright year to 2015Paul Eggert2015-01-01
| | | | Run admin/update-copyright.
* Update copyright year to 2014 by running admin/update-copyright.Paul Eggert2014-01-01
|
* Update copyright notices for 2013.Paul Eggert2013-01-01
|
* Add 2012 to FSF copyright years for Emacs filesGlenn Morris2012-01-05
|
* Convert consecutive FSF copyright years to ranges.Glenn Morris2011-01-24
|
* Nuke arch-tags.Glenn Morris2011-01-15
|
* Add 2011 to FSF/AIST copyright years.Glenn Morris2011-01-02
|