diff options
| author | lneto <lneto@NetBSD.org> | 2014-07-19 17:11:52 +0000 |
|---|---|---|
| committer | lneto <lneto@NetBSD.org> | 2014-07-19 17:11:52 +0000 |
| commit | 140dbe04e39612eeffbfc48970206f504d1ac6eb (patch) | |
| tree | ed33335486c58c99c630c7717ca5413fc8572280 /external/mit/lua | |
| parent | 4f74f463135be4d0b65d12be5db64b794aa459a5 (diff) | |
lua(4): preventing division by zero
* note: we should raise an error instead of return INTMAX_MAX
Diffstat (limited to 'external/mit/lua')
| -rw-r--r-- | external/mit/lua/dist/src/luaconf.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/external/mit/lua/dist/src/luaconf.h b/external/mit/lua/dist/src/luaconf.h index 0a7a09fed80..0ea1df98d2e 100644 --- a/external/mit/lua/dist/src/luaconf.h +++ b/external/mit/lua/dist/src/luaconf.h @@ -1,4 +1,4 @@ -/* $NetBSD: luaconf.h,v 1.7 2014/03/26 22:03:26 christos Exp $ */ +/* $NetBSD: luaconf.h,v 1.8 2014/07/19 17:11:52 lneto Exp $ */ /* ** Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ @@ -553,10 +553,13 @@ */ #if defined(LUA_CORE) #ifdef _KERNEL +/* XXX: we should raise an error instead of return INTMAX_MAX */ +#define luai_numdiv(a,b) ((b) != 0 ? (a)/(b) : INTMAX_MAX) #define luai_nummod(a,b) ((a)%(b)) #define luai_numpow(a,b) luai_nummul(a,b) #else #include <math.h> +#define luai_numdiv(a,b) ((a)/(b)) #define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) #define luai_numpow(a,b) (pow(a,b)) #endif @@ -564,7 +567,6 @@ #define luai_numadd(a,b) ((a)+(b)) #define luai_numsub(a,b) ((a)-(b)) #define luai_nummul(a,b) ((a)*(b)) -#define luai_numdiv(a,b) ((a)/(b)) #define luai_numunm(a) (-(a)) #define luai_numeq(a,b) ((a)==(b)) #define luai_numlt(a,b) ((a)<(b)) |
