GNU bug report logs - #38892
28.0.50: Hash table printing oddities

Previous Next

Package: emacs;

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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 38892 in the body.
You can then email your comments to 38892 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#38892; Package emacs. (Fri, 03 Jan 2020 12:15:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Pip Cet <pipcet <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 03 Jan 2020 12:15:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Pip Cet <pipcet <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50: Hash table printing oddities
Date: Fri, 3 Jan 2020 12:13:28 +0000
[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)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38892; Package emacs. (Sat, 11 Jan 2020 09:43:01 GMT) Full text and rfc822 format available.

Message #8 received at 38892 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Pip Cet <pipcet <at> gmail.com>
Cc: 38892 <at> debbugs.gnu.org
Subject: Re: bug#38892: 28.0.50: Hash table printing oddities
Date: Sat, 11 Jan 2020 11:42:09 +0200
> From: Pip Cet <pipcet <at> gmail.com>
> Date: Fri, 3 Jan 2020 12:13:28 +0000
> 
> Proposed patch attached.

Thanks.  Can you add a few tests to make sure this works as expected?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38892; Package emacs. (Sun, 20 Sep 2020 10:26:01 GMT) Full text and rfc822 format available.

Message #11 received at 38892 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 38892 <at> debbugs.gnu.org, Pip Cet <pipcet <at> gmail.com>
Subject: Re: bug#38892: 28.0.50: Hash table printing oddities
Date: Sun, 20 Sep 2020 12:24:54 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Proposed patch attached.
>
> Thanks.  Can you add a few tests to make sure this works as expected?

I've now applied Pip's patch and added the examples from the bug report
as tests.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 20 Sep 2020 10:26:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 38892 <at> debbugs.gnu.org and Pip Cet <pipcet <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 20 Sep 2020 10:26:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 18 Oct 2020 11:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 184 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.