1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-27 16:51:06 -07:00

* src/fns.c (Flength): Fix char table length off-by-one bug.

This commit is contained in:
Mattias Engdegård 2025-07-11 16:26:54 +02:00
parent 8ff6e7fe58
commit 52b96d3a7e
2 changed files with 3 additions and 2 deletions

View file

@ -147,7 +147,7 @@ efficient. */)
else if (VECTORP (sequence))
val = ASIZE (sequence);
else if (CHAR_TABLE_P (sequence))
val = MAX_CHAR;
val = MAX_CHAR + 1;
else if (BOOL_VECTOR_P (sequence))
val = bool_vector_size (sequence);
else if (CLOSUREP (sequence) || RECORDP (sequence))

View file

@ -52,7 +52,8 @@
(should (= (length '(1 2 3)) 3))
(should (= (length '[1 2 3]) 3))
(should (= (length "foo") 3))
(should-error (length t)))
(should-error (length t))
(should (= (length (make-char-table 'fns-tests)) (1+ (max-char)))))
(ert-deftest fns-tests-safe-length ()
(should (= (safe-length '(1 2 3)) 3)))