lua

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

commit 39fd5bb9b04a6a7633ddf4aa838e4909a7a0abc8
parent 5482992dec286ca800ffab539b0f81eddaa2665b
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Fri, 28 Nov 1997 10:39:01 -0200

details

Diffstat:
Mlmathlib.c | 14+++++++-------
Mlobject.h | 4++--
2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/lmathlib.c b/lmathlib.c @@ -1,5 +1,5 @@ /* -** $Id: lmathlib.c,v 1.4 1997/11/04 15:27:53 roberto Exp roberto $ +** $Id: lmathlib.c,v 1.5 1997/11/19 18:16:33 roberto Exp roberto $ ** Lua standard mathematical library ** See Copyright Notice in lua.h */ @@ -13,7 +13,7 @@ #include "lualib.h" #ifndef PI -#define PI 3.14159265358979323846 +#define PI ((double)3.14159265358979323846) #endif @@ -24,13 +24,13 @@ static double torad (void) { - char *s = lua_getstring(lua_getglobal("_TRIGMODE")); + char *s = luaL_opt_string(2, "d"); switch (*s) { case 'd' : return PI/180.0; - case 'r' : return 1.0; + case 'r' : return (double)1.0; case 'g' : return PI/50.0; default: - luaL_verror("invalid _TRIGMODE (`%.50s')", s); + luaL_arg_check(0, 2, "invalid mode"); return 0; /* to avoid warnings */ } } @@ -120,12 +120,12 @@ static void math_exp (void) static void math_deg (void) { - lua_pushnumber(luaL_check_number(1)*180./PI); + lua_pushnumber(luaL_check_number(1)*(180.0/PI)); } static void math_rad (void) { - lua_pushnumber(luaL_check_number(1)/180.*PI); + lua_pushnumber(luaL_check_number(1)*(PI/180.0)); } diff --git a/lobject.h b/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 1.8 1997/11/03 20:45:23 roberto Exp roberto $ +** $Id: lobject.h,v 1.9 1997/11/19 17:29:23 roberto Exp roberto $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -131,7 +131,7 @@ typedef struct LocVar { #define fvalue(o) ((o)->value.f) #define tfvalue(o) ((o)->value.tf) -#define protovalue(o) (&(o)->value.cl->consts[0]) +#define protovalue(o) ((o)->value.cl->consts) /* ** Closures