[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#38892: 28.0.50: Hash table printing oddities
From: |
Pip Cet |
Subject: |
bug#38892: 28.0.50: Hash table printing oddities |
Date: |
Fri, 3 Jan 2020 12:13:28 +0000 |
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
Description: Text Data
- bug#38892: 28.0.50: Hash table printing oddities,
Pip Cet <=