Signal also an arithmetic error when dividing by a floating point 0

This commit is contained in:
jjgarcia 2003-12-19 13:00:29 +00:00
parent 9157c73a9e
commit 0772b295cc
6 changed files with 10 additions and 14 deletions

View file

@ -9,7 +9,7 @@ VPATH = @srcdir@
#
TRUE_CC = @CC@
CC = @ECL_CC@
CFLAGS = -c -I../h -I$(srcdir) -I$(HDIR) @BOEHM_HEADERS@ @CFLAGS@ @ECL_CFLAGS@
CFLAGS = -c -I$(srcdir) -I$(HDIR) -I../h @BOEHM_HEADERS@ @CFLAGS@ @ECL_CFLAGS@
SHELL = /bin/sh
RM = @RM@

View file

@ -229,9 +229,10 @@ FEtype_error_symbol(cl_object obj)
}
void
FEdivision_by_zero(void)
FEdivision_by_zero(cl_object x, cl_object y)
{
cl_error(3, @'division-by-zero', @':operation', @'/');
cl_error(3, @'division-by-zero', @':operation', @'/',
@':operands', cl_list(2, x, y));
}
/*************************************

View file

@ -584,13 +584,13 @@ number_divide(cl_object x, cl_object y)
{
cl_object z, z1, z2;
if (number_zerop(y))
FEdivision_by_zero(x, y);
switch (type_of(x)) {
case t_fixnum:
case t_bignum:
switch (type_of(y)) {
case t_fixnum:
if (y == MAKE_FIXNUM(0))
FEdivision_by_zero();
case t_bignum:
if (number_minusp(y) == TRUE) {
x = number_negate(x);
@ -614,8 +614,6 @@ number_divide(cl_object x, cl_object y)
case t_ratio:
switch (type_of(y)) {
case t_fixnum:
if (y == MAKE_FIXNUM(0))
FEdivision_by_zero();
case t_bignum:
z = number_times(x->ratio.den, y);
z = make_ratio(x->ratio.num, z);
@ -637,8 +635,6 @@ number_divide(cl_object x, cl_object y)
case t_shortfloat:
switch (type_of(y)) {
case t_fixnum:
if (y == MAKE_FIXNUM(0))
FEdivision_by_zero();
return make_shortfloat(sf(x) / fix(y));
case t_bignum:
case t_ratio:
@ -655,8 +651,6 @@ number_divide(cl_object x, cl_object y)
case t_longfloat:
switch (type_of(y)) {
case t_fixnum:
if (y == MAKE_FIXNUM(0))
FEdivision_by_zero();
return make_longfloat(lf(x) / fix(y));
case t_bignum:
case t_ratio:
@ -706,7 +700,7 @@ integer_divide(cl_object x, cl_object y)
if (tx == t_fixnum) {
if (ty == t_fixnum) {
if (y == MAKE_FIXNUM(0))
FEdivision_by_zero();
FEdivision_by_zero(x, y);
return MAKE_FIXNUM(fix(x) / fix(y));
}
if (ty == t_bignum) {

View file

@ -88,7 +88,7 @@ make_ratio(cl_object num, cl_object den)
/* INV: the arguments NUM & DEN are integers */
if (den == MAKE_FIXNUM(0))
FEdivision_by_zero();
FEdivision_by_zero(num, den);
if (num == MAKE_FIXNUM(0) || den == MAKE_FIXNUM(1))
return(num);
if (number_minusp(den)) {

View file

@ -1285,6 +1285,7 @@ cl_symbols[] = {
{KEY_ "OBJECT", KEYWORD, NULL, -1, OBJNULL},
{KEY_ "OFFSET", KEYWORD, NULL, -1, OBJNULL},
{KEY_ "OPERATION", KEYWORD, NULL, -1, OBJNULL},
{KEY_ "OPERANDS", KEYWORD, NULL, -1, OBJNULL},
{KEY_ "OUTPUT", KEYWORD, NULL, -1, OBJNULL},
{KEY_ "OVERWRITE", KEYWORD, NULL, -1, OBJNULL},
{KEY_ "PACKAGE", KEYWORD, NULL, -1, OBJNULL},

View file

@ -1406,7 +1406,7 @@ extern void FEtype_error_stream(cl_object x) __attribute__((noreturn));
extern void FEcircular_list(cl_object x) __attribute__((noreturn));
extern void FEtype_error_index(cl_object seq, cl_object ndx) __attribute__((noreturn));
extern void FEtype_error_string(cl_object x) __attribute__((noreturn));
extern void FEdivision_by_zero(void) __attribute__((noreturn));
extern void FEdivision_by_zero(cl_object x, cl_object y) __attribute__((noreturn));
/* unixfsys.c */