GNU bug report logs - #13345
24.2.91; Wrong assumption in a hash table example + fix

Previous Next

Package: emacs;

Reported by: Ari Roponen <ari.roponen <at> gmail.com>

Date: Thu, 3 Jan 2013 12:04:02 UTC

Severity: minor

Found in version 24.2.91

Fixed in version 24.2.92

Done: Glenn Morris <rgm <at> gnu.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 13345 in the body.
You can then email your comments to 13345 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#13345; Package emacs. (Thu, 03 Jan 2013 12:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ari Roponen <ari.roponen <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 03 Jan 2013 12:04:02 GMT) Full text and rfc822 format available.

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

From: Ari Roponen <ari.roponen <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.2.91; Wrong assumption in a hash table example + fix
Date: Thu, 03 Jan 2013 14:01:17 +0200
In file doc/lispref/hash.texi, there is an example:

    @example
    (defun case-fold-string= (a b)
      (compare-strings a nil nil b nil nil t))
    (defun case-fold-string-hash (a)
      (sxhash (upcase a)))

    (define-hash-table-test 'case-fold
      'case-fold-string= 'case-fold-string-hash)

    (make-hash-table :test 'case-fold)
    @end example

The documentation of `define-hash-table-test' says:

    The function @var{test-fn} should accept two arguments, two keys, and
    return non-@code{nil} if they are considered ``the same''.

In the above example, the test function returns always non-nil, because
it assumes `compare-strings' returns nil for differing strings. The
patch below fixes this wrong assumption.


2013-01-03  Ari Roponen  <ari.roponen <at> gmail.com>  (tiny change)

	* hash.texi (Defining Hash): Fix example.


=== modified file 'doc/lispref/hash.texi'
--- doc/lispref/hash.texi	2013-01-01 09:11:05 +0000
+++ doc/lispref/hash.texi	2013-01-03 10:50:19 +0000
@@ -293,7 +293,7 @@
 
 @example
 (defun case-fold-string= (a b)
-  (compare-strings a nil nil b nil nil t))
+  (eq t (compare-strings a nil nil b nil nil t)))
 (defun case-fold-string-hash (a)
   (sxhash (upcase a)))
 


In GNU Emacs 24.2.91.9 (x86_64-unknown-linux-gnu, GTK+ Version 3.7.2)
 of 2013-01-03 on arirop
Bzr revision: 111125 rgm <at> gnu.org-20130103063325-sx99hs1usiuqlxvb
Windowing system distributor `Fedora Project', version 11.0.11300000
System Description:	Fedora release 18 (Spherical Cow)

-- 
Ari Roponen




Reply sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Thu, 03 Jan 2013 18:42:01 GMT) Full text and rfc822 format available.

Notification sent to Ari Roponen <ari.roponen <at> gmail.com>:
bug acknowledged by developer. (Thu, 03 Jan 2013 18:42:02 GMT) Full text and rfc822 format available.

Message #10 received at 13345-done <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 13345-done <at> debbugs.gnu.org
Subject: Re: bug#13345: 24.2.91; Wrong assumption in a hash table example + fix
Date: Thu, 03 Jan 2013 13:41:30 -0500
Version: 24.2.92

Thanks, applied.
You have a few tiny changes now. Please consider completing a copyright
assignment if you expect to contribute more (forgive me if I already
mentioned this).




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 01 Feb 2013 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 91 days ago.

Previous Next


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