lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 1414b7123ca46f7e133ee71400e8ed7f95187c47
parent 3563b3f51942da0cc0360394476b3910b51ebdd9
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Sun, 26 May 2013 10:44:59 -0300

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')

Diffstat:
Mlmathlib.c | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git 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);