]> git.eshelyaron.com Git - emacs.git/commit
Nonrecursive Lisp reader (bug#55676)
authorMattias Engdegård <mattiase@acm.org>
Tue, 24 May 2022 11:02:14 +0000 (13:02 +0200)
committerMattias Engdegård <mattiase@acm.org>
Mon, 30 May 2022 13:56:59 +0000 (15:56 +0200)
commitb903507b36c438653a02d7b6291e9744d5221e28
tree0d193f92c1ea66b9da0a966d430f7affaa125537
parent169797a3002fae1e86ee799475cd4f1b7ef9a3d1
Nonrecursive Lisp reader (bug#55676)

Restructure the reader to be nonrecursive so that it is not limited by
the C stack or crashes Emacs when reading deeply nested data.
This also improves performance.
A few minor bugs were fixed:

- (a .{NBSP}b) where {NBSP} is a non-breaking space (U+00A0) is now
  the dotted pair (a . b), not the 3-element list (a \. b), since U+00A0
  is treated as whitespace everywhere else.
- #_ with no symbol following is now equivalent to ## (empty interned
  symbol), not #: (empty uninterned symbol).

* src/alloc.c (garbage_collect): Call mark_lread.
* src/lread.c (readevalloop): Use read0 instead of read_list.
(stackbufsize): Increase to 1024, now that read0 isn't recursive.
(invalid_radix_integer): Buffer overflow check.
(read1, read_list, read_vector): Remove.
(read_char_literal, read_string_literal)
(hash_table_from_plist, record_from_list, vector_from_rev_list)
(bytecode_from_rev_list, char_table_from_rev_list)
(sub_char_table_from_rev_list, string_props_from_rev_list)
(read_bool_vector, skip_lazy_string, symbol_char_span)
(skip_space_and_comments)
(enum read_entry_type, struct read_stack_entry, struct read_stack)
(rdstack, mark_lread, read_stack_top, read_stack_pop)
(read_stack_empty_p, grow_read_stack, read_stack_push): New.
(read0): Rewrite to be nonrecursive.
* test/src/lread-tests.el (lread-deeply-nested, lread-misc): New tests.
src/alloc.c
src/lisp.h
src/lread.c
test/src/lread-tests.el