*** empty log message ***
This commit is contained in:
parent
3edaeb4f9f
commit
d41d43a23c
@ -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>
|
#include <xp/lsp/lsp.h>
|
||||||
@ -26,7 +26,8 @@ static const xp_char_t* __errstr[] =
|
|||||||
XP_TEXT("bad symbol"),
|
XP_TEXT("bad symbol"),
|
||||||
XP_TEXT("undefined symbol"),
|
XP_TEXT("undefined symbol"),
|
||||||
XP_TEXT("empty body"),
|
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)
|
int xp_lsp_error (xp_lsp_t* lsp, xp_char_t* buf, xp_size_t size)
|
||||||
|
@ -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_
|
#ifndef _XP_LSP_LSP_H_
|
||||||
@ -39,7 +39,8 @@ enum
|
|||||||
XP_LSP_ERR_BAD_SYMBOL,
|
XP_LSP_ERR_BAD_SYMBOL,
|
||||||
XP_LSP_ERR_UNDEF_SYMBOL,
|
XP_LSP_ERR_UNDEF_SYMBOL,
|
||||||
XP_LSP_ERR_EMPTY_BODY,
|
XP_LSP_ERR_EMPTY_BODY,
|
||||||
XP_LSP_ERR_BAD_VALUE
|
XP_LSP_ERR_BAD_VALUE,
|
||||||
|
XP_LSP_ERR_DIVIDE_BY_ZERO
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -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>
|
#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);
|
ivalue = XP_LSP_IVALUE(tmp);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
ivalue = ivalue / XP_LSP_IVALUE(tmp);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
rvalue = rvalue / XP_LSP_IVALUE(tmp);
|
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);
|
ivalue = XP_LSP_IVALUE(tmp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (XP_LSP_IVALUE(tmp) == 0) {
|
||||||
|
lsp->errnum = XP_LSP_ERR_DIVIDE_BY_ZERO;
|
||||||
|
return XP_NULL;
|
||||||
|
}
|
||||||
ivalue = ivalue % XP_LSP_IVALUE(tmp);
|
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);
|
ivalue = (xp_lsp_int_t)XP_LSP_RVALUE(tmp);
|
||||||
}
|
}
|
||||||
else {
|
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 {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user