diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/lua/luaconf.h | 6 | ||||
-rw-r--r-- | apps/plugins/lua/rockaux.c | 49 |
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 @@ | |||
529 | @@ The luai_num* macros define the primitive operations over numbers. | 529 | @@ The luai_num* macros define the primitive operations over numbers. |
530 | */ | 530 | */ |
531 | #if defined(LUA_CORE) | 531 | #if defined(LUA_CORE) |
532 | #include <math.h> | 532 | extern long rb_pow(long, long); |
533 | #define luai_numadd(a,b) ((a)+(b)) | 533 | #define luai_numadd(a,b) ((a)+(b)) |
534 | #define luai_numsub(a,b) ((a)-(b)) | 534 | #define luai_numsub(a,b) ((a)-(b)) |
535 | #define luai_nummul(a,b) ((a)*(b)) | 535 | #define luai_nummul(a,b) ((a)*(b)) |
536 | #define luai_numdiv(a,b) ((a)/(b)) | 536 | #define luai_numdiv(a,b) ((a)/(b)) |
537 | #define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) | 537 | #define luai_nummod(a,b) ((a)%(b)) |
538 | #define luai_numpow(a,b) (pow(a,b)) | 538 | #define luai_numpow(a,b) (rb_pow(a,b)) |
539 | #define luai_numunm(a) (-(a)) | 539 | #define luai_numunm(a) (-(a)) |
540 | #define luai_numeq(a,b) ((a)==(b)) | 540 | #define luai_numeq(a,b) ((a)==(b)) |
541 | #define luai_numlt(a,b) ((a)<(b)) | 541 | #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; | |||
31 | char *strerror(int errnum) | 31 | char *strerror(int errnum) |
32 | { | 32 | { |
33 | (void) errnum; | 33 | (void) errnum; |
34 | 34 | ||
35 | DEBUGF("strerror()\n"); | 35 | DEBUGF("strerror(%d)\n", errnum); |
36 | 36 | ||
37 | return NULL; | 37 | return NULL; |
38 | } | 38 | } |
39 | 39 | ||
40 | long floor(long x) | 40 | long rb_pow(long x, long n) |
41 | { | 41 | { |
42 | (void) x; | 42 | long pow = 1; |
43 | 43 | unsigned long u; | |
44 | DEBUGF("floor()\n"); | ||
45 | |||
46 | return 0; | ||
47 | } | ||
48 | 44 | ||
49 | long pow(long x, long y) | 45 | if(n <= 0) |
50 | { | 46 | { |
51 | (void) x; | 47 | if(n == 0 || x == 1) |
52 | (void) y; | 48 | return 1; |
53 | 49 | ||
54 | DEBUGF("pow()\n"); | 50 | if(x != -1) |
55 | 51 | return x != 0 ? 1/x : 0; | |
56 | return 0; | 52 | |
53 | n = -n; | ||
54 | } | ||
55 | |||
56 | u = n; | ||
57 | while(1) | ||
58 | { | ||
59 | if(u & 01) | ||
60 | pow *= x; | ||
61 | |||
62 | if(u >>= 1) | ||
63 | x *= x; | ||
64 | else | ||
65 | break; | ||
66 | } | ||
67 | |||
68 | return pow; | ||
57 | } | 69 | } |
58 | 70 | ||
59 | int strcoll(const char * str1, const char * str2) | 71 | int strcoll(const char * str1, const char * str2) |
@@ -91,4 +103,3 @@ const char* get_current_path(lua_State *L, int level) | |||
91 | 103 | ||
92 | return NULL; | 104 | return NULL; |
93 | } | 105 | } |
94 | |||