From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Rob Browning Newsgroups: gmane.lisp.guile.bugs Subject: bug#39634: All keyowrds hash to the same value Date: Sun, 16 Feb 2020 12:20:56 -0600 Message-ID: <87wo8mcs1j.fsf@trouble.defaultvalue.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="101785"; mail-complaints-to="usenet@ciao.gmane.io" To: 39634@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Sun Feb 16 19:22:10 2020 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j3OYU-000QNM-CU for guile-bugs@m.gmane-mx.org; Sun, 16 Feb 2020 19:22:10 +0100 Original-Received: from localhost ([::1]:34978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3OYT-0005qj-E0 for guile-bugs@m.gmane-mx.org; Sun, 16 Feb 2020 13:22:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54473) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3OYN-0005qZ-U4 for bug-guile@gnu.org; Sun, 16 Feb 2020 13:22:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3OYM-0006I4-TJ for bug-guile@gnu.org; Sun, 16 Feb 2020 13:22:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59914) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j3OYM-0006Hq-Pf for bug-guile@gnu.org; Sun, 16 Feb 2020 13:22:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j3OYM-0003fJ-Ms for bug-guile@gnu.org; Sun, 16 Feb 2020 13:22:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Rob Browning Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 16 Feb 2020 18:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 39634 X-GNU-PR-Package: guile X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.158187726314004 (code B ref -1); Sun, 16 Feb 2020 18:22:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 Feb 2020 18:21:03 +0000 Original-Received: from localhost ([127.0.0.1]:37651 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j3OXO-0003do-Ku for submit@debbugs.gnu.org; Sun, 16 Feb 2020 13:21:02 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:36584) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j3OXM-0003d5-P6 for submit@debbugs.gnu.org; Sun, 16 Feb 2020 13:21:01 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54404) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3OXL-0005jh-ND for bug-guile@gnu.org; Sun, 16 Feb 2020 13:21:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3OXK-0004qS-Kw for bug-guile@gnu.org; Sun, 16 Feb 2020 13:20:59 -0500 Original-Received: from defaultvalue.org ([45.33.119.55]:59148) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1j3OXK-0004pX-EQ for bug-guile@gnu.org; Sun, 16 Feb 2020 13:20:58 -0500 Original-Received: from trouble.defaultvalue.org (localhost [127.0.0.1]) (Authenticated sender: rlb@defaultvalue.org) by defaultvalue.org (Postfix) with ESMTPSA id 912D2200FF for ; Sun, 16 Feb 2020 12:20:57 -0600 (CST) Original-Received: by trouble.defaultvalue.org (Postfix, from userid 1000) id CE91714E071; Sun, 16 Feb 2020 12:20:56 -0600 (CST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:9580 Archived-At: --=-=-= Content-Type: text/plain (hash #:x most-postive-fixnum) hashes to the same value for all keyowrds in at least 2.2 and 3.0. Here's one potential fix for 3.0, and I'd be happy to adjust it for 2.2 if needed. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Implement-hashing-for-keywords-i.e.-hash-x.patch Content-Description: 0001-Implement-hashing-for-keywords-i.e.-hash-x.patch >From b380102564aad053f22586eb404e99c82635a3b0 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sun, 16 Feb 2020 12:12:08 -0600 Subject: [PATCH 1/1] Implement hashing for keywords, i.e. (hash #:x ...) Add keyword handling to (hash ...). Previously it would just return the same value for all keywords. * libguile/hash.c (scm_raw_ihash): Add scm_tc7_keyword case. * libguile/keywords.h (SCM_I_KEYWORD_HASH): New macro. --- libguile/hash.c | 3 +++ libguile/keywords.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/libguile/hash.c b/libguile/hash.c index d6e93dae0..c51a794c9 100644 --- a/libguile/hash.c +++ b/libguile/hash.c @@ -35,6 +35,7 @@ #include "chars.h" #include "foreign.h" #include "gsubr.h" +#include "keywords.h" #include "numbers.h" #include "pairs.h" #include "ports.h" @@ -307,6 +308,8 @@ scm_raw_ihash (SCM obj, size_t depth) return scm_i_string_hash (obj); case scm_tc7_symbol: return scm_i_symbol_hash (obj); + case scm_tc7_keyword: + return SCM_I_KEYWORD_HASH (obj); case scm_tc7_pointer: return scm_raw_ihashq ((uintptr_t) SCM_POINTER_VALUE (obj)); case scm_tc7_wvect: diff --git a/libguile/keywords.h b/libguile/keywords.h index c8f480869..cb8598d8b 100644 --- a/libguile/keywords.h +++ b/libguile/keywords.h @@ -60,6 +60,8 @@ SCM_API void scm_c_bind_keyword_arguments (const char *subr, SCM rest, scm_t_keyword_arguments_flags flags, ...); +#define SCM_I_KEYWORD_HASH(x) scm_i_symbol_hash (SCM_CELL_OBJECT_1 (x)) + SCM_INTERNAL void scm_init_keywords (void); #endif /* SCM_KEYWORDS_H */ -- 2.24.1 --=-=-= Content-Type: text/plain -- Rob Browning rlb @defaultvalue.org and @debian.org GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4 --=-=-=--