unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ari Roponen <ari.roponen@gmail.com>
To: 13345@debbugs.gnu.org
Subject: bug#13345: 24.2.91; Wrong assumption in a hash table example + fix
Date: Thu, 03 Jan 2013 14:01:17 +0200	[thread overview]
Message-ID: <87lica79wy.fsf@arirop.lan> (raw)


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@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@gnu.org-20130103063325-sx99hs1usiuqlxvb
Windowing system distributor `Fedora Project', version 11.0.11300000
System Description:	Fedora release 18 (Spherical Cow)

-- 
Ari Roponen





             reply	other threads:[~2013-01-03 12:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-03 12:01 Ari Roponen [this message]
2013-01-03 18:41 ` bug#13345: 24.2.91; Wrong assumption in a hash table example + fix Glenn Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lica79wy.fsf@arirop.lan \
    --to=ari.roponen@gmail.com \
    --cc=13345@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).