From c42d03050ea0f96556e73e405e530b78bb85aba7 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Wed, 26 Jan 2011 02:56:20 -0500 Subject: [PATCH] Add case for fractions with differing SCM_CELL_TYPE to scm_equal_p * libguile/eq.c (scm_equal_p): Add a special case for fractions with differing SCM_CELL_TYPE, which might nonetheless be considered equal (due to the use of 0x10000 as a flag), to scm_equal_p. This code was already present in scm_eqv_p. (scm_eqv_p): Move comment (regarding special case for fractions) next to the corresponding code. --- libguile/eq.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libguile/eq.c b/libguile/eq.c index 7502559..dc548b8 100644 --- a/libguile/eq.c +++ b/libguile/eq.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1997,1998,2000,2001,2003, 2004, 2006, 2009, 2010 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,1998,2000,2001,2003, 2004, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -170,11 +170,6 @@ SCM scm_eqv_p (SCM x, SCM y) if (SCM_CELL_TYPE (x) != SCM_CELL_TYPE (y)) { - /* fractions use 0x10000 as a flag (at the suggestion of Marius Vollmer), - but this checks the entire type word, so fractions may be accidentally - flagged here as unequal. Perhaps I should use the 4th double_cell word? - */ - /* treat mixes of real and complex types specially */ if (SCM_INEXACTP (x)) { @@ -190,8 +185,13 @@ SCM scm_eqv_p (SCM x, SCM y) && SCM_COMPLEX_IMAG (x) == 0.0); } + /* fractions use 0x10000 as a flag (at the suggestion of Marius Vollmer), + but this checks the entire type word, so fractions may be accidentally + flagged here as unequal. Perhaps I should use the 4th double_cell word? + */ if (SCM_FRACTIONP (x) && SCM_FRACTIONP (y)) return scm_i_fraction_equalp (x, y); + return SCM_BOOL_F; } if (SCM_NUMP (x)) @@ -322,6 +322,13 @@ scm_equal_p (SCM x, SCM y) && SCM_COMPLEX_IMAG (x) == 0.0); } + /* fractions use 0x10000 as a flag (at the suggestion of Marius Vollmer), + but this checks the entire type word, so fractions may be accidentally + flagged here as unequal. Perhaps I should use the 4th double_cell word? + */ + if (SCM_FRACTIONP (x) && SCM_FRACTIONP (y)) + return scm_i_fraction_equalp (x, y); + /* Vectors can be equal to one-dimensional arrays. */ if (scm_is_array (x) && scm_is_array (y)) -- 1.5.6.5