From 1414b7123ca46f7e133ee71400e8ed7f95187c47 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Sun, 26 May 2013 10:45:24 -0300 Subject: support for the case when 'l_mathop' does not conform to lua_Number (problem with pointers to lua_Number solved by a typedef selected automatically by 'l_mathop') --- lmathlib.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lmathlib.c b/lmathlib.c index 4eeaae9e..cc397fc2 100644 --- a/lmathlib.c +++ b/lmathlib.c @@ -1,5 +1,5 @@ /* -** $Id: lmathlib.c,v 1.84 2013/05/02 17:31:54 roberto Exp roberto $ +** $Id: lmathlib.c,v 1.85 2013/05/06 17:22:55 roberto Exp $ ** Standard mathematical library ** See Copyright Notice in lua.h */ @@ -22,6 +22,11 @@ #define RADIANS_PER_DEGREE ((lua_Number)(PI/180.0)) +/* types for lua_Number pointers subject to 'l_mathop' changes */ +typedef float l_pnumf; +typedef double l_pnum; +typedef long double l_pnuml; + static int math_abs (lua_State *L) { lua_pushnumber(L, l_mathop(fabs)(luaL_checknumber(L, 1))); @@ -96,7 +101,7 @@ static int math_fmod (lua_State *L) { } static int math_modf (lua_State *L) { - lua_Number ip; + l_mathop(l_pnum) ip; lua_Number fp = l_mathop(modf)(luaL_checknumber(L, 1), &ip); lua_pushnumber(L, ip); lua_pushnumber(L, fp); -- cgit v1.2.3-55-g6feb