1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-11 16:20:19 +02:00

(scm_hashq, scm_hashv, scm_hash): Restrict to size>=1 rather

than size>=0, since 0<=hash<size cannot be satisfied for size==0, and
such a size causes divide-by-zeros in scm_hasher.
This commit is contained in:
Kevin Ryde 2004-07-09 22:45:53 +00:00
parent 5367ad9510
commit eee211fd6e

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1995,1996,1997, 2000, 2001 Free Software Foundation, Inc. /* Copyright (C) 1995,1996,1997, 2000, 2001, 2004 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -201,7 +201,7 @@ SCM_DEFINE (scm_hashq, "hashq", 2, 0, 0,
"different values, since @code{foo} will be garbage collected.") "different values, since @code{foo} will be garbage collected.")
#define FUNC_NAME s_scm_hashq #define FUNC_NAME s_scm_hashq
{ {
SCM_VALIDATE_INUM_MIN (2, size, 0); SCM_VALIDATE_INUM_MIN (2, size, 1);
return SCM_MAKINUM (scm_ihashq (key, SCM_INUM (size))); return SCM_MAKINUM (scm_ihashq (key, SCM_INUM (size)));
} }
#undef FUNC_NAME #undef FUNC_NAME
@ -237,7 +237,7 @@ SCM_DEFINE (scm_hashv, "hashv", 2, 0, 0,
"different values, since @code{foo} will be garbage collected.") "different values, since @code{foo} will be garbage collected.")
#define FUNC_NAME s_scm_hashv #define FUNC_NAME s_scm_hashv
{ {
SCM_VALIDATE_INUM_MIN (2, size, 0); SCM_VALIDATE_INUM_MIN (2, size, 1);
return SCM_MAKINUM (scm_ihashv (key, SCM_INUM (size))); return SCM_MAKINUM (scm_ihashv (key, SCM_INUM (size)));
} }
#undef FUNC_NAME #undef FUNC_NAME
@ -260,7 +260,7 @@ SCM_DEFINE (scm_hash, "hash", 2, 0, 0,
"integer in the range 0 to @var{size} - 1.") "integer in the range 0 to @var{size} - 1.")
#define FUNC_NAME s_scm_hash #define FUNC_NAME s_scm_hash
{ {
SCM_VALIDATE_INUM_MIN (2, size, 0); SCM_VALIDATE_INUM_MIN (2, size, 1);
return SCM_MAKINUM (scm_ihash (key, SCM_INUM (size))); return SCM_MAKINUM (scm_ihash (key, SCM_INUM (size)));
} }
#undef FUNC_NAME #undef FUNC_NAME