aboutsummaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorame <[email protected]>2024-02-15 13:23:49 -0600
committerame <[email protected]>2024-02-15 13:23:49 -0600
commit40262c59e7aafe4fc09c413fcee65b617e8cfddd (patch)
treefc9de080dc2155c2bc5563ee521c688c88ba2055 /src/io.c
parent0b28025b0b69266905a9f6235c7476bb799eea37 (diff)
fixes
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/io.c b/src/io.c
index 5eb9de8..674c081 100644
--- a/src/io.c
+++ b/src/io.c
@@ -113,6 +113,7 @@ void i_pprint(lua_State* L, int indent, int skip_indent){
printf(" '%s'"color_gray": "color_reset, lua_tostring(L,-2));
} else {
if(!skip) print_indentation(indent + 1);
+ //printf(" '%i'"color_gray": "color_reset, luaL_checknumber(L,-2));
}
int tuwu = lua_gettop(L);
i_pprint(L,indent+1,1);
@@ -161,7 +162,7 @@ enum json_state {
#define push() \
if(is_array){\
- lua_pushinteger(L, i);\
+ lua_pushinteger(L, iter_count);\
} else {\
char kbuf[key->len];\
memset(kbuf, 0, key->len);\
@@ -198,14 +199,22 @@ void json_parse(lua_State* L, str* raw){
int last_idx = lua_gettop(L);
int is_array = raw->c[0] == '[';
int i = 1;
+ int iter_count = 1;
+ int escape_next = 0;
for(i = 1; i != raw->len - 1; i++){
topush[0] = *(raw->c + i);
if(state == normal && (topush[0] == ' ' || topush[0] == '\n' || topush[0] <= 10)) continue;
+ if(escape_next > 0) escape_next--;
switch(topush[0]){
+ case '\\':
+ escape_next = 2;
+ break;
case '"':
+ if(escape_next == 1) break;
case '{': case '}':
case '[': case ']':
+
if(last == '{' && topush[0] == '}' || last == '[' && topush[0] == ']') token_depth--;
if((last == '\0' || last == '"' && topush[0] == '"'
@@ -228,6 +237,7 @@ void json_parse(lua_State* L, str* raw){
str_clear(key);
str_clear(value);
count = 0;
+ iter_count++;
continue;
}
break;
@@ -238,6 +248,7 @@ void json_parse(lua_State* L, str* raw){
}
break;
}
+ //if(escape_next == 2) continue;
if(last == '{' && topush[0] == '{' || last == '[' && topush[0] == '[') token_depth++;
if(count == 0 && !is_array) str_push(key, topush);