From unknown Fri Sep 05 11:00:51 2025 X-Loop: help-debbugs@gnu.org Subject: bug#13345: 24.2.91; Wrong assumption in a hash table example + fix Resent-From: Ari Roponen Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 03 Jan 2013 12:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13345 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 13345@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.135721461525621 (code B ref -1); Thu, 03 Jan 2013 12:04:02 +0000 Received: (at submit) by debbugs.gnu.org; 3 Jan 2013 12:03:35 +0000 Received: from localhost ([127.0.0.1]:41207 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TqjWH-0006fA-DO for submit@debbugs.gnu.org; Thu, 03 Jan 2013 07:03:34 -0500 Received: from eggs.gnu.org ([208.118.235.92]:37480) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TqjWF-0006f3-4F for submit@debbugs.gnu.org; Thu, 03 Jan 2013 07:03:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TqjVb-0000Em-S1 for submit@debbugs.gnu.org; Thu, 03 Jan 2013 07:03:30 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:36483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqjVb-0000Eg-Mw for submit@debbugs.gnu.org; Thu, 03 Jan 2013 07:02:51 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqjUx-0000VE-Lh for bug-gnu-emacs@gnu.org; Thu, 03 Jan 2013 07:02:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TqjUI-0008S4-1S for bug-gnu-emacs@gnu.org; Thu, 03 Jan 2013 07:02:11 -0500 Received: from mail-la0-f50.google.com ([209.85.215.50]:64222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqjUH-0008Rs-QX for bug-gnu-emacs@gnu.org; Thu, 03 Jan 2013 07:01:29 -0500 Received: by mail-la0-f50.google.com with SMTP id fs13so7557889lab.23 for ; Thu, 03 Jan 2013 04:01:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:date:message-id:mime-version :content-type; bh=LmSuYEzDABL5c7y5b+egEe52PYOKt8hJc3K7SLJz84c=; b=pDl6RaHCqHLnARUYBRAoTNgQqxG/l16y+OyDhEmRfCettaKLyiBMWlNBOKRQDYHIBs kenznYV3zLMxvyaR6CVlr/1KOmSqrD3qCcZtkpGWL45KpAF0YXyts57d2gWDm+rCGgwN jexlrFV+CdF98sxixDjMpzUbGr2p40Ok9mBrXwLn1XXEG+BQtc3AUlvK1H4IEAFZZdb5 ThOGFqHT9EBIrHFZQaMB7U3fTtmWINbYo1st39ISK4PnXgaivisZpav5rYxZ2mc/PpeL wbFipmajR01l3SUmCczbrE2FvlVX7IwlcxWIbuPdW4sG4dYAMbjzOMnSuowOVM3EKk/O g2OQ== X-Received: by 10.112.10.3 with SMTP id e3mr20151868lbb.33.1357214488319; Thu, 03 Jan 2013 04:01:28 -0800 (PST) Received: from arirop.lan (dsl-jklbrasgw1-54fb0b-115.dhcp.inet.fi. [84.251.11.115]) by mx.google.com with ESMTPS id sj3sm18339059lab.2.2013.01.03.04.01.24 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Jan 2013 04:01:25 -0800 (PST) From: Ari Roponen Date: Thu, 03 Jan 2013 14:01:17 +0200 Message-ID: <87lica79wy.fsf@arirop.lan> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -3.4 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) 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 (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 From unknown Fri Sep 05 11:00:51 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.428 (Entity 5.428) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Ari Roponen Subject: bug#13345: closed (Re: bug#13345: 24.2.91; Wrong assumption in a hash table example + fix) Message-ID: References: <3mfw2if6sl.fsf@fencepost.gnu.org> <87lica79wy.fsf@arirop.lan> X-Gnu-PR-Message: they-closed 13345 X-Gnu-PR-Package: emacs Reply-To: 13345@debbugs.gnu.org Date: Thu, 03 Jan 2013 18:42:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1357238522-10255-1" This is a multi-part message in MIME format... ------------=_1357238522-10255-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #13345: 24.2.91; Wrong assumption in a hash table example + fix which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 13345@debbugs.gnu.org. --=20 13345: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D13345 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1357238522-10255-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 13345-done) by debbugs.gnu.org; 3 Jan 2013 18:41:37 +0000 Received: from localhost ([127.0.0.1]:41896 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TqpjU-0002eh-1X for submit@debbugs.gnu.org; Thu, 03 Jan 2013 13:41:36 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:55455) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TqpjR-0002eY-UE for 13345-done@debbugs.gnu.org; Thu, 03 Jan 2013 13:41:35 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1TqpjO-0000yR-K1; Thu, 03 Jan 2013 13:41:30 -0500 From: Glenn Morris To: 13345-done@debbugs.gnu.org Subject: Re: bug#13345: 24.2.91; Wrong assumption in a hash table example + fix References: <87lica79wy.fsf@arirop.lan> X-Spook: illuminati ASDIC Iran defense information warfare X-Ran: 9hT6^KtNL9G}n:9_%%yBA^-mjFv,~phixG)LV`9U>uBOJyhZ7f^mtv% (Ari Roponen's message of "Thu, 03 Jan 2013 14:01:17 +0200") Message-ID: <3mfw2if6sl.fsf@fencepost.gnu.org> User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: 13345-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.0 (-----) 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). ------------=_1357238522-10255-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 3 Jan 2013 12:03:35 +0000 Received: from localhost ([127.0.0.1]:41207 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TqjWH-0006fA-DO for submit@debbugs.gnu.org; Thu, 03 Jan 2013 07:03:34 -0500 Received: from eggs.gnu.org ([208.118.235.92]:37480) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TqjWF-0006f3-4F for submit@debbugs.gnu.org; Thu, 03 Jan 2013 07:03:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TqjVb-0000Em-S1 for submit@debbugs.gnu.org; Thu, 03 Jan 2013 07:03:30 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:36483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqjVb-0000Eg-Mw for submit@debbugs.gnu.org; Thu, 03 Jan 2013 07:02:51 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqjUx-0000VE-Lh for bug-gnu-emacs@gnu.org; Thu, 03 Jan 2013 07:02:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TqjUI-0008S4-1S for bug-gnu-emacs@gnu.org; Thu, 03 Jan 2013 07:02:11 -0500 Received: from mail-la0-f50.google.com ([209.85.215.50]:64222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqjUH-0008Rs-QX for bug-gnu-emacs@gnu.org; Thu, 03 Jan 2013 07:01:29 -0500 Received: by mail-la0-f50.google.com with SMTP id fs13so7557889lab.23 for ; Thu, 03 Jan 2013 04:01:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:date:message-id:mime-version :content-type; bh=LmSuYEzDABL5c7y5b+egEe52PYOKt8hJc3K7SLJz84c=; b=pDl6RaHCqHLnARUYBRAoTNgQqxG/l16y+OyDhEmRfCettaKLyiBMWlNBOKRQDYHIBs kenznYV3zLMxvyaR6CVlr/1KOmSqrD3qCcZtkpGWL45KpAF0YXyts57d2gWDm+rCGgwN jexlrFV+CdF98sxixDjMpzUbGr2p40Ok9mBrXwLn1XXEG+BQtc3AUlvK1H4IEAFZZdb5 ThOGFqHT9EBIrHFZQaMB7U3fTtmWINbYo1st39ISK4PnXgaivisZpav5rYxZ2mc/PpeL wbFipmajR01l3SUmCczbrE2FvlVX7IwlcxWIbuPdW4sG4dYAMbjzOMnSuowOVM3EKk/O g2OQ== X-Received: by 10.112.10.3 with SMTP id e3mr20151868lbb.33.1357214488319; Thu, 03 Jan 2013 04:01:28 -0800 (PST) Received: from arirop.lan (dsl-jklbrasgw1-54fb0b-115.dhcp.inet.fi. [84.251.11.115]) by mx.google.com with ESMTPS id sj3sm18339059lab.2.2013.01.03.04.01.24 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Jan 2013 04:01:25 -0800 (PST) From: Ari Roponen To: bug-gnu-emacs@gnu.org Subject: 24.2.91; Wrong assumption in a hash table example + fix Date: Thu, 03 Jan 2013 14:01:17 +0200 Message-ID: <87lica79wy.fsf@arirop.lan> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) 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 (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 ------------=_1357238522-10255-1--