emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#39634: closed (All keyowrds hash to the same value)


From: GNU bug Tracking System
Subject: bug#39634: closed (All keyowrds hash to the same value)
Date: Fri, 06 Mar 2020 16:20:02 +0000

Your message dated Fri, 06 Mar 2020 17:19:38 +0100
with message-id <address@hidden>
and subject line Re: bug#39634: All keyowrds hash to the same value
has caused the debbugs.gnu.org bug report #39634,
regarding All keyowrds hash to the same value
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden.)


-- 
39634: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=39634
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: All keyowrds hash to the same value Date: Sun, 16 Feb 2020 12:20:56 -0600
(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.

>From b380102564aad053f22586eb404e99c82635a3b0 Mon Sep 17 00:00:00 2001
From: Rob Browning <address@hidden>
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

-- 
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

--- End Message ---
--- Begin Message --- Subject: Re: bug#39634: All keyowrds hash to the same value Date: Fri, 06 Mar 2020 17:19:38 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
Andy Wingo <address@hidden> skribis:

> On Fri 06 Mar 2020 15:42, Ludovic Courtès <address@hidden> writes:
>
>> Andy Wingo <address@hidden> skribis:
>>
>>>>   variable,
>>>>   hashtable,
>>>>   fluid,
>>>>   dynamic_state,
>>>>   frame,
>>>>   atomic_box,
>>>>   program,
>>>>   vm_cont,
>>>>   weak_set,
>>>>   weak_table,
>>>>   port
>>>
>>> No equal? implementation, so should hashq() instead.
>>
>> Here’s a patch for these, let me know what you think!
>
> LGTM!

Pushed as c5d3b45c9f903cc9726b4bd7e3c13db56bafd587, thanks!

Ludo'.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]