1
0
Fork 0
forked from fun/fun

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:
Johannes Findeisen 2026-03-18 20:52:00 +01:00
commit 03b2532474
237 changed files with 17550 additions and 13911 deletions

View file

@ -12,15 +12,16 @@
/* OP_XML_NAME: pops node handle; pushes string */
case OP_XML_NAME: {
#ifdef FUN_WITH_XML2
Value vh = pop_value(vm);
int h = (vh.type == VAL_INT) ? (int)vh.i : 0;
xmlNodePtr n = xml_node_get(h);
free_value(vh);
const char *name = (n && n->name) ? (const char*)n->name : "";
push_value(vm, make_string(name));
Value vh = pop_value(vm);
int h = (vh.type == VAL_INT) ? (int)vh.i : 0;
xmlNodePtr n = xml_node_get(h);
free_value(vh);
const char *name = (n && n->name) ? (const char *)n->name : "";
push_value(vm, make_string(name));
#else
Value drop = pop_value(vm); free_value(drop);
push_value(vm, make_string(""));
Value drop = pop_value(vm);
free_value(drop);
push_value(vm, make_string(""));
#endif
break;
break;
}

View file

@ -12,23 +12,32 @@
/* OP_XML_PARSE: pops text string; pushes doc handle (>0) or 0 */
case OP_XML_PARSE: {
#ifdef FUN_WITH_XML2
static int xml_inited = 0;
if (!xml_inited) { xmlInitParser(); xml_inited = 1; }
Value vtext = pop_value(vm);
char *text = value_to_string_alloc(&vtext);
free_value(vtext);
if (!text) { push_value(vm, make_int(0)); break; }
xmlDocPtr doc = xmlReadMemory(text, (int)strlen(text), NULL, NULL, XML_PARSE_NONET);
free(text);
int h = 0;
if (doc) {
h = xml_doc_alloc(doc);
if (!h) { xmlFreeDoc(doc); }
}
push_value(vm, make_int(h));
#else
Value drop = pop_value(vm); free_value(drop);
static int xml_inited = 0;
if (!xml_inited) {
xmlInitParser();
xml_inited = 1;
}
Value vtext = pop_value(vm);
char *text = value_to_string_alloc(&vtext);
free_value(vtext);
if (!text) {
push_value(vm, make_int(0));
#endif
break;
}
xmlDocPtr doc = xmlReadMemory(text, (int)strlen(text), NULL, NULL, XML_PARSE_NONET);
free(text);
int h = 0;
if (doc) {
h = xml_doc_alloc(doc);
if (!h) {
xmlFreeDoc(doc);
}
}
push_value(vm, make_int(h));
#else
Value drop = pop_value(vm);
free_value(drop);
push_value(vm, make_int(0));
#endif
break;
}

View file

@ -12,19 +12,20 @@
/* OP_XML_ROOT: pops doc handle; pushes node handle (>0) or 0 */
case OP_XML_ROOT: {
#ifdef FUN_WITH_XML2
Value vh = pop_value(vm);
int h = (vh.type == VAL_INT) ? (int)vh.i : 0;
xmlDocPtr doc = xml_doc_get(h);
free_value(vh);
int nh = 0;
if (doc) {
xmlNodePtr root = xmlDocGetRootElement(doc);
if (root) nh = xml_node_alloc(root);
}
push_value(vm, make_int(nh));
Value vh = pop_value(vm);
int h = (vh.type == VAL_INT) ? (int)vh.i : 0;
xmlDocPtr doc = xml_doc_get(h);
free_value(vh);
int nh = 0;
if (doc) {
xmlNodePtr root = xmlDocGetRootElement(doc);
if (root) nh = xml_node_alloc(root);
}
push_value(vm, make_int(nh));
#else
Value drop = pop_value(vm); free_value(drop);
push_value(vm, make_int(0));
Value drop = pop_value(vm);
free_value(drop);
push_value(vm, make_int(0));
#endif
break;
break;
}

View file

@ -12,18 +12,25 @@
/* OP_XML_TEXT: pops node handle; pushes string (concatenate text node children) */
case OP_XML_TEXT: {
#ifdef FUN_WITH_XML2
Value vh = pop_value(vm);
int h = (vh.type == VAL_INT) ? (int)vh.i : 0;
xmlNodePtr n = xml_node_get(h);
free_value(vh);
if (!n) { push_value(vm, make_string("")); break; }
xmlChar *content = xmlNodeGetContent(n);
if (!content) { push_value(vm, make_string("")); break; }
push_value(vm, make_string((const char*)content));
xmlFree(content);
#else
Value drop = pop_value(vm); free_value(drop);
Value vh = pop_value(vm);
int h = (vh.type == VAL_INT) ? (int)vh.i : 0;
xmlNodePtr n = xml_node_get(h);
free_value(vh);
if (!n) {
push_value(vm, make_string(""));
#endif
break;
}
xmlChar *content = xmlNodeGetContent(n);
if (!content) {
push_value(vm, make_string(""));
break;
}
push_value(vm, make_string((const char *)content));
xmlFree(content);
#else
Value drop = pop_value(vm);
free_value(drop);
push_value(vm, make_string(""));
#endif
break;
}