From 0772b295cc22be96f304efc8fc80ade43ceeb05e Mon Sep 17 00:00:00 2001 From: jjgarcia Date: Fri, 19 Dec 2003 13:00:29 +0000 Subject: [PATCH] Signal also an arithmetic error when dividing by a floating point 0 --- src/c/Makefile.in | 2 +- src/c/error.d | 5 +++-- src/c/num_arith.d | 12 +++--------- src/c/number.d | 2 +- src/c/symbols_list.h | 1 + src/h/external.h | 2 +- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/c/Makefile.in b/src/c/Makefile.in index 00c7ece4b..b1fcf2001 100644 --- a/src/c/Makefile.in +++ b/src/c/Makefile.in @@ -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@ diff --git a/src/c/error.d b/src/c/error.d index 3b3ab471f..3c70e5642 100644 --- a/src/c/error.d +++ b/src/c/error.d @@ -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)); } /************************************* diff --git a/src/c/num_arith.d b/src/c/num_arith.d index 8e0a13b44..2f0c7300a 100644 --- a/src/c/num_arith.d +++ b/src/c/num_arith.d @@ -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) { diff --git a/src/c/number.d b/src/c/number.d index 4cbeece9c..58d537b7b 100644 --- a/src/c/number.d +++ b/src/c/number.d @@ -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)) { diff --git a/src/c/symbols_list.h b/src/c/symbols_list.h index 3483245be..072bd7934 100644 --- a/src/c/symbols_list.h +++ b/src/c/symbols_list.h @@ -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}, diff --git a/src/h/external.h b/src/h/external.h index 19e23e892..9775b2f99 100644 --- a/src/h/external.h +++ b/src/h/external.h @@ -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 */