Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/mit/lua/dist/src lua(4): preventing division by zero
details: https://anonhg.NetBSD.org/src/rev/b612a28e40f4
branches: trunk
changeset: 330726:b612a28e40f4
user: lneto <lneto%NetBSD.org@localhost>
date: Sat Jul 19 17:11:52 2014 +0000
description:
lua(4): preventing division by zero
* note: we should raise an error instead of return INTMAX_MAX
diffstat:
external/mit/lua/dist/src/luaconf.h | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diffs (31 lines):
diff -r 99c600685a6a -r b612a28e40f4 external/mit/lua/dist/src/luaconf.h
--- a/external/mit/lua/dist/src/luaconf.h Sat Jul 19 17:10:02 2014 +0000
+++ b/external/mit/lua/dist/src/luaconf.h Sat Jul 19 17:11:52 2014 +0000
@@ -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))
Home |
Main Index |
Thread Index |
Old Index