From cebf3d62d915cb73ca5cc6b99e3fa006c4d0a15a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grabm=C3=BCller?= Date: Mon, 16 Jul 2001 15:47:02 +0000 Subject: [PATCH] * srfi-14.c: Allocate correct memory size for charsets (32 bytes), use this value for initializing and comparing charsets. (scm_char_set_hash): Use ``better'' hash algorithm which produces more values. --- srfi/ChangeLog | 7 +++++++ srfi/srfi-14.c | 12 +++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/srfi/ChangeLog b/srfi/ChangeLog index 8b467df17..8c2f2c936 100644 --- a/srfi/ChangeLog +++ b/srfi/ChangeLog @@ -1,3 +1,10 @@ +2001-07-16 Martin Grabmueller + + * srfi-14.c: Allocate correct memory size for charsets (32 bytes), + use this value for initializing and comparing charsets. + (scm_char_set_hash): Use ``better'' hash algorithm which produces + more values. + 2001-07-15 Gary Houston * srfi-14.c (scm_char_set_hash): recognise 0 instead of #f in the diff --git a/srfi/srfi-14.c b/srfi/srfi-14.c index 685ee89bc..878349158 100644 --- a/srfi/srfi-14.c +++ b/srfi/srfi-14.c @@ -94,8 +94,8 @@ make_char_set (const char * func_name) { long * p; - p = scm_must_malloc (SCM_CHARSET_SIZE, func_name); - memset (p, 0, SCM_CHARSET_SIZE); + p = scm_must_malloc (SCM_CHARSET_SIZE / sizeof (char), func_name); + memset (p, 0, SCM_CHARSET_SIZE / sizeof (char)); SCM_RETURN_NEWSMOB (scm_tc16_charset, p); } @@ -131,7 +131,8 @@ SCM_DEFINE (scm_char_set_eq, "char-set=", 0, 0, 1, csi_data = (long *) SCM_SMOB_DATA (csi); if (cs1_data == NULL) cs1_data = csi_data; - else if (memcmp (cs1_data, csi_data, SCM_CHARSET_SIZE) != 0) + else if (memcmp (cs1_data, csi_data, + SCM_CHARSET_SIZE / sizeof (char)) != 0) return SCM_BOOL_F; char_sets = SCM_CDR (char_sets); } @@ -204,7 +205,8 @@ SCM_DEFINE (scm_char_set_hash, "char-set-hash", 1, 1, 0, p = (long *) SCM_SMOB_DATA (cs); for (k = 0; k < SCM_CHARSET_SIZE / sizeof (long); k++) { - val = p[k] ^ val; + if (p[k] != 0) + val = p[k] + (val << 1); } return SCM_MAKINUM (val % bnd); } @@ -1368,7 +1370,7 @@ scm_c_init_srfi_14 (void) if (!initialized) { scm_tc16_charset = scm_make_smob_type ("character-set", - SCM_CHARSET_SIZE * sizeof (long)); + SCM_CHARSET_SIZE / sizeof (char)); scm_set_smob_free (scm_tc16_charset, charset_free); scm_set_smob_print (scm_tc16_charset, charset_print); initialized = 1;