From ec694545b7c5b3a4ef81796057d8aa0a38e6aa8d Mon Sep 17 00:00:00 2001
From: "p.kosyh@gmail.com"
Date: Thu, 28 Apr 2011 19:41:33 +0000
Subject: [PATCH] bit_mod added
---
src/sdl-instead/instead.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/sdl-instead/instead.c b/src/sdl-instead/instead.c
index da8e6c9..361840e 100644
--- a/src/sdl-instead/instead.c
+++ b/src/sdl-instead/instead.c
@@ -1460,6 +1460,16 @@ static int luaB_bit_div(lua_State *L) {
return 0;
}
+static int luaB_bit_mod(lua_State *L) {
+ unsigned int a = luaL_optnumber(L, 1, 0);
+ unsigned int b = luaL_optnumber(L, 2, 1);
+ if (b) {
+ lua_pushnumber(L, a % b);
+ return 1;
+ }
+ return 0;
+}
+
static const luaL_Reg base_funcs[] = {
{"doencfile", luaB_doencfile},
{"dofile", luaB_dofile},
@@ -1508,6 +1518,7 @@ static const luaL_Reg base_funcs[] = {
{"bit_shr", luaB_bit_shr},
{"bit_not", luaB_bit_not},
{"bit_div", luaB_bit_div},
+ {"bit_mod", luaB_bit_mod},
{NULL, NULL}
};