diff options
| -rw-r--r-- | lmathlib.c | 14 | ||||
| -rw-r--r-- | lobject.h | 4 |
2 files changed, 9 insertions, 9 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmathlib.c,v 1.4 1997/11/04 15:27:53 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.5 1997/11/19 18:16:33 roberto Exp roberto $ |
| 3 | ** Lua standard mathematical library | 3 | ** Lua standard mathematical library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -13,7 +13,7 @@ | |||
| 13 | #include "lualib.h" | 13 | #include "lualib.h" |
| 14 | 14 | ||
| 15 | #ifndef PI | 15 | #ifndef PI |
| 16 | #define PI 3.14159265358979323846 | 16 | #define PI ((double)3.14159265358979323846) |
| 17 | #endif | 17 | #endif |
| 18 | 18 | ||
| 19 | 19 | ||
| @@ -24,13 +24,13 @@ | |||
| 24 | 24 | ||
| 25 | static double torad (void) | 25 | static double torad (void) |
| 26 | { | 26 | { |
| 27 | char *s = lua_getstring(lua_getglobal("_TRIGMODE")); | 27 | char *s = luaL_opt_string(2, "d"); |
| 28 | switch (*s) { | 28 | switch (*s) { |
| 29 | case 'd' : return PI/180.0; | 29 | case 'd' : return PI/180.0; |
| 30 | case 'r' : return 1.0; | 30 | case 'r' : return (double)1.0; |
| 31 | case 'g' : return PI/50.0; | 31 | case 'g' : return PI/50.0; |
| 32 | default: | 32 | default: |
| 33 | luaL_verror("invalid _TRIGMODE (`%.50s')", s); | 33 | luaL_arg_check(0, 2, "invalid mode"); |
| 34 | return 0; /* to avoid warnings */ | 34 | return 0; /* to avoid warnings */ |
| 35 | } | 35 | } |
| 36 | } | 36 | } |
| @@ -120,12 +120,12 @@ static void math_exp (void) | |||
| 120 | 120 | ||
| 121 | static void math_deg (void) | 121 | static void math_deg (void) |
| 122 | { | 122 | { |
| 123 | lua_pushnumber(luaL_check_number(1)*180./PI); | 123 | lua_pushnumber(luaL_check_number(1)*(180.0/PI)); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | static void math_rad (void) | 126 | static void math_rad (void) |
| 127 | { | 127 | { |
| 128 | lua_pushnumber(luaL_check_number(1)/180.*PI); | 128 | lua_pushnumber(luaL_check_number(1)*(PI/180.0)); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | 131 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.h,v 1.8 1997/11/03 20:45:23 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 1.9 1997/11/19 17:29:23 roberto Exp roberto $ |
| 3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -131,7 +131,7 @@ typedef struct LocVar { | |||
| 131 | #define fvalue(o) ((o)->value.f) | 131 | #define fvalue(o) ((o)->value.f) |
| 132 | #define tfvalue(o) ((o)->value.tf) | 132 | #define tfvalue(o) ((o)->value.tf) |
| 133 | 133 | ||
| 134 | #define protovalue(o) (&(o)->value.cl->consts[0]) | 134 | #define protovalue(o) ((o)->value.cl->consts) |
| 135 | 135 | ||
| 136 | /* | 136 | /* |
| 137 | ** Closures | 137 | ** Closures |
