aboutsummaryrefslogtreecommitdiff
path: root/src/table.c
diff options
context:
space:
mode:
authorame <[email protected]>2023-12-18 13:55:13 -0600
committerame <[email protected]>2023-12-18 13:55:13 -0600
commit595fd25a80c569d104bc53cbfb9e46654134b4e1 (patch)
tree17506097f415d4bddcdf3566d3ce0de08ab9a377 /src/table.c
parentc691cc98e31e52982a79ffc10b8e91e8c700592b (diff)
config and io functions
Diffstat (limited to 'src/table.c')
-rw-r--r--src/table.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/table.c b/src/table.c
index 4e99cf1..6c3686a 100644
--- a/src/table.c
+++ b/src/table.c
@@ -1,10 +1,20 @@
#include "table.h"
#include <stdlib.h>
#include <string.h>
-
+#include <stdint.h>
+
+uint64_t i_len(lua_State* L, int pos){
+ uint64_t i = 0;
+ lua_pushnil(L);
+ for(;lua_next(L,pos) != 0;){
+ i += 1;
+ lua_pop(L,1);
+ }
+ return i;
+}
int l_len(lua_State* L) {
- luaL_checktype(L, 1, LUA_TTABLE);
- lua_pushnumber(L,lua_objlen(L,1));
+ luaL_checktype(L, 1, LUA_TTABLE);
+ lua_pushnumber(L,i_len(L,1));
return 1;
}
@@ -178,7 +188,7 @@ int l_split(lua_State* L){
size_t split_len = 0;
char* input = (char*)luaL_checklstring(L, 1, &input_len);
char* split = (char*)luaL_checklstring(L, 2, &split_len);
- size_t table_len = 0;
+ size_t table_len = 1;
lua_newtable(L);
size_t current_len = 0;