*** empty log message ***

This commit is contained in:
hyung-hwan 2005-09-21 12:04:05 +00:00
parent 3edaeb4f9f
commit d41d43a23c
3 changed files with 23 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: error.c,v 1.1 2005-09-19 12:04:00 bacon Exp $
* $Id: error.c,v 1.2 2005-09-21 12:04:05 bacon Exp $
*/
#include <xp/lsp/lsp.h>
@ -26,7 +26,8 @@ static const xp_char_t* __errstr[] =
XP_TEXT("bad symbol"),
XP_TEXT("undefined symbol"),
XP_TEXT("empty body"),
XP_TEXT("bad value")
XP_TEXT("bad value"),
XP_TEXT("divide by zero")
};
int xp_lsp_error (xp_lsp_t* lsp, xp_char_t* buf, xp_size_t size)

View File

@ -1,5 +1,5 @@
/*
* $Id: lsp.h,v 1.16 2005-09-20 14:38:39 bacon Exp $
* $Id: lsp.h,v 1.17 2005-09-21 12:04:05 bacon Exp $
*/
#ifndef _XP_LSP_LSP_H_
@ -39,7 +39,8 @@ enum
XP_LSP_ERR_BAD_SYMBOL,
XP_LSP_ERR_UNDEF_SYMBOL,
XP_LSP_ERR_EMPTY_BODY,
XP_LSP_ERR_BAD_VALUE
XP_LSP_ERR_BAD_VALUE,
XP_LSP_ERR_DIVIDE_BY_ZERO
};
/*

View File

@ -1,5 +1,5 @@
/*
* $Id: prim_math.c,v 1.4 2005-09-20 12:06:51 bacon Exp $
* $Id: prim_math.c,v 1.5 2005-09-21 12:04:05 bacon Exp $
*/
#include <xp/lsp/prim.h>
@ -225,8 +225,13 @@ xp_lsp_obj_t* xp_lsp_prim_divide (xp_lsp_t* lsp, xp_lsp_obj_t* args)
ivalue = XP_LSP_IVALUE(tmp);
}
else {
if (!realnum)
if (!realnum) {
if (XP_LSP_IVALUE(tmp) == 0) {
lsp->errnum = XP_LSP_ERR_DIVIDE_BY_ZERO;
return XP_NULL;
}
ivalue = ivalue / XP_LSP_IVALUE(tmp);
}
else
rvalue = rvalue / XP_LSP_IVALUE(tmp);
}
@ -286,6 +291,10 @@ xp_lsp_obj_t* xp_lsp_prim_modulus (xp_lsp_t* lsp, xp_lsp_obj_t* args)
ivalue = XP_LSP_IVALUE(tmp);
}
else {
if (XP_LSP_IVALUE(tmp) == 0) {
lsp->errnum = XP_LSP_ERR_DIVIDE_BY_ZERO;
return XP_NULL;
}
ivalue = ivalue % XP_LSP_IVALUE(tmp);
}
}
@ -294,7 +303,12 @@ xp_lsp_obj_t* xp_lsp_prim_modulus (xp_lsp_t* lsp, xp_lsp_obj_t* args)
ivalue = (xp_lsp_int_t)XP_LSP_RVALUE(tmp);
}
else {
ivalue = ivalue % (xp_lsp_int_t)XP_LSP_RVALUE(tmp);
xp_lsp_int_t tmpi = (xp_lsp_int_t)XP_LSP_RVALUE(tmp);
if (tmpi == 0) {
lsp->errnum = XP_LSP_ERR_DIVIDE_BY_ZERO;
return XP_NULL;
}
ivalue = ivalue % tmpi;
}
}
else {