Fixed the code style in *.c files to two spaces indentation and add a linter named funstx to Fun. (0.39.0)
This commit is contained in:
parent
33001a7ad2
commit
03b2532474
237 changed files with 17550 additions and 13911 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* This file is part of the Fun programming language.
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
|
|
@ -12,27 +12,30 @@
|
|||
/* JSON_PARSE */
|
||||
case OP_JSON_PARSE: {
|
||||
#ifdef FUN_WITH_JSON
|
||||
Value text = pop_value(vm);
|
||||
char *s = value_to_string_alloc(&text);
|
||||
free_value(text);
|
||||
if (!s) { push_value(vm, make_nil()); break; }
|
||||
struct json_tokener *tok = json_tokener_new();
|
||||
json_object *root = json_tokener_parse_ex(tok, s, (int)strlen(s));
|
||||
enum json_tokener_error jerr = json_tokener_get_error(tok);
|
||||
json_tokener_free(tok);
|
||||
free(s);
|
||||
if (jerr != json_tokener_success) {
|
||||
push_value(vm, make_nil());
|
||||
} else {
|
||||
Value v = json_to_fun(root);
|
||||
push_value(vm, v);
|
||||
json_object_put(root);
|
||||
}
|
||||
#else
|
||||
/* Fallback when JSON is disabled: consume arg, push Nil */
|
||||
Value drop = pop_value(vm);
|
||||
free_value(drop);
|
||||
Value text = pop_value(vm);
|
||||
char *s = value_to_string_alloc(&text);
|
||||
free_value(text);
|
||||
if (!s) {
|
||||
push_value(vm, make_nil());
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
struct json_tokener *tok = json_tokener_new();
|
||||
json_object *root = json_tokener_parse_ex(tok, s, (int)strlen(s));
|
||||
enum json_tokener_error jerr = json_tokener_get_error(tok);
|
||||
json_tokener_free(tok);
|
||||
free(s);
|
||||
if (jerr != json_tokener_success) {
|
||||
push_value(vm, make_nil());
|
||||
} else {
|
||||
Value v = json_to_fun(root);
|
||||
push_value(vm, v);
|
||||
json_object_put(root);
|
||||
}
|
||||
#else
|
||||
/* Fallback when JSON is disabled: consume arg, push Nil */
|
||||
Value drop = pop_value(vm);
|
||||
free_value(drop);
|
||||
push_value(vm, make_nil());
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue