GNU bug report logs -
#38892
28.0.50: Hash table printing oddities
Previous Next
Reported by: Pip Cet <pipcet <at> gmail.com>
Date: Fri, 3 Jan 2020 12:15:02 UTC
Severity: normal
Tags: fixed
Found in version 28.0.50
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
The hash table printing code has some oddities: it will print extra
spaces sometimes, won't print as many elements as requested under all
circumstances, and behave oddly for empty hash tables when
print-length is 0.
Currently, this code will result in extra spaces in the hash table output:
(let ((h (make-hash-table)))
(puthash 1 2 h)
(puthash 2 3 h)
(remhash 1 h)
(format "%S" h))
(let ((h (make-hash-table)))
(let ((print-length 0))
(format "%S" h)))
In the latter case, the output actually includes "data ( ...)", though
"data ()" would be shorter and more accurate.
Also, the current code contains an oddity that would make it print
fewer than print-length hash cells in the data list:
(let ((h (make-hash-table)))
(dotimes (i 100)
(puthash i i h))
(dotimes (i 99)
(remhash i h))
(let ((print-length 1))
(format "%S" h)))
will produce "data ( ...)", when it should produce "data (99 99)".
Proposed patch attached.
[0001-Fix-hash-table-printing.patch (text/x-patch, attachment)]
This bug report was last modified 4 years and 304 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.