summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/lua/luaconf.h6
-rw-r--r--apps/plugins/lua/rockaux.c49
2 files changed, 33 insertions, 22 deletions
diff --git a/apps/plugins/lua/luaconf.h b/apps/plugins/lua/luaconf.h
index 478ea14530..109e680a17 100644
--- a/apps/plugins/lua/luaconf.h
+++ b/apps/plugins/lua/luaconf.h
@@ -529,13 +529,13 @@
@@ The luai_num* macros define the primitive operations over numbers.
*/
#if defined(LUA_CORE)
-#include <math.h>
+extern long rb_pow(long, long);
#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_nummod(a,b) ((a) - floor((a)/(b))*(b))
-#define luai_numpow(a,b) (pow(a,b))
+#define luai_nummod(a,b) ((a)%(b))
+#define luai_numpow(a,b) (rb_pow(a,b))
#define luai_numunm(a) (-(a))
#define luai_numeq(a,b) ((a)==(b))
#define luai_numlt(a,b) ((a)<(b))
diff --git a/apps/plugins/lua/rockaux.c b/apps/plugins/lua/rockaux.c
index 95f2ab169b..ea95f232ab 100644
--- a/apps/plugins/lua/rockaux.c
+++ b/apps/plugins/lua/rockaux.c
@@ -31,29 +31,41 @@ int errno = 0;
char *strerror(int errnum)
{
(void) errnum;
-
- DEBUGF("strerror()\n");
-
+
+ DEBUGF("strerror(%d)\n", errnum);
+
return NULL;
}
-long floor(long x)
+long rb_pow(long x, long n)
{
- (void) x;
-
- DEBUGF("floor()\n");
-
- return 0;
-}
+ long pow = 1;
+ unsigned long u;
-long pow(long x, long y)
-{
- (void) x;
- (void) y;
-
- DEBUGF("pow()\n");
-
- return 0;
+ if(n <= 0)
+ {
+ if(n == 0 || x == 1)
+ return 1;
+
+ if(x != -1)
+ return x != 0 ? 1/x : 0;
+
+ n = -n;
+ }
+
+ u = n;
+ while(1)
+ {
+ if(u & 01)
+ pow *= x;
+
+ if(u >>= 1)
+ x *= x;
+ else
+ break;
+ }
+
+ return pow;
}
int strcoll(const char * str1, const char * str2)
@@ -91,4 +103,3 @@ const char* get_current_path(lua_State *L, int level)
return NULL;
}
-