From f81e080b24c722c62cdbc68aa7a1c8f3743fa440 Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Wed, 22 Mar 2000 20:48:18 +0000 Subject: [PATCH] Fixed some bugs that are due to the fact that SCM is a void* now. Cleaned up a macro definition. Thanks to Dale P. Smith for both of these patches. --- libguile/ChangeLog | 9 +++++++++ libguile/numbers.c | 22 ++++++++++++---------- libguile/numbers.h | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index f423a6f44..f16e30b49 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,12 @@ +2000-03-22 Dirk Herrmann + + * numbers.h (SCM_SETNUMDIGS): Use SCM_BIGSIZEFIELD macro for + shifting, not constant. Thanks to Dale P. Smith. + + * numbers.c (scm_sum, scm_difference): Don't test a SCM value + for being less than zero. Decode it to a C value first. Again, + thank you Dale. + 2000-03-22 Dirk Herrmann * numbers.h, ramap.c, struct.h, vectors.h: Don't use SCM2PTR for diff --git a/libguile/numbers.c b/libguile/numbers.c index 0ab8d9fb3..0c3861bea 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -1,5 +1,5 @@ -/* Copyright (C) 1995,1996,1997,1998, 1999, 2000 Free Software Foundation, Inc. - +/* Copyright (C) 1995,1996,1997,1998,1999,2000 Free Software Foundation, Inc. + * * 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 * the Free Software Foundation; either version 2, or (at your option) @@ -3426,16 +3426,17 @@ scm_sum (SCM x, SCM y) { intbig: { + long i = SCM_INUM (x); # ifndef SCM_DIGSTOOBIG - long z = scm_pseudolong (SCM_INUM (x)); + long z = scm_pseudolong (i); return scm_addbig ((SCM_BIGDIG *) & z, SCM_DIGSPERLONG, - (x < 0) ? SCM_BIGSIGNFLAG : 0, + (i < 0) ? SCM_BIGSIGNFLAG : 0, y, 0); # else /* SCM_DIGSTOOBIG */ SCM_BIGDIG zdigs[SCM_DIGSPERLONG]; - scm_longdigs (SCM_INUM (x), zdigs); - return scm_addbig (zdigs, SCM_DIGSPERLONG, (x < 0) ? SCM_BIGSIGNFLAG : 0, + scm_longdigs (i, zdigs); + return scm_addbig (zdigs, SCM_DIGSPERLONG, (i < 0) ? SCM_BIGSIGNFLAG : 0, y, 0); # endif /* SCM_DIGSTOOBIG */ } @@ -3580,15 +3581,16 @@ scm_difference (SCM x, SCM y) SCM_ASRTGO (SCM_NIMP (y), bady); if (SCM_BIGP (y)) { + long i = SCM_INUM (x); #ifndef SCM_DIGSTOOBIG - long z = scm_pseudolong (SCM_INUM (x)); + long z = scm_pseudolong (i); return scm_addbig ((SCM_BIGDIG *) & z, SCM_DIGSPERLONG, - (x < 0) ? SCM_BIGSIGNFLAG : 0, + (i < 0) ? SCM_BIGSIGNFLAG : 0, y, SCM_BIGSIGNFLAG); #else SCM_BIGDIG zdigs[SCM_DIGSPERLONG]; - scm_longdigs (SCM_INUM (x), zdigs); - return scm_addbig (zdigs, SCM_DIGSPERLONG, (x < 0) ? SCM_BIGSIGNFLAG : 0, + scm_longdigs (i, zdigs); + return scm_addbig (zdigs, SCM_DIGSPERLONG, (i < 0) ? SCM_BIGSIGNFLAG : 0, y, SCM_BIGSIGNFLAG); #endif } diff --git a/libguile/numbers.h b/libguile/numbers.h index 12fc10845..e6db92079 100644 --- a/libguile/numbers.h +++ b/libguile/numbers.h @@ -263,7 +263,7 @@ SCM_SETCAR (x, \ scm_tc16_big \ | ((sign) ? SCM_BIGSIGNFLAG : 0) \ - | (((v) + 0L) << 17)) \ + | (((v) + 0L) << SCM_BIGSIZEFIELD))