This commit is contained in:
Nishi 2026-04-16 14:36:28 +09:00
commit a0c056ef61
3 changed files with 19 additions and 19 deletions

View file

@ -50,9 +50,9 @@ int main(int argc, char** argv) {
for(i = 1; i < argc; i++) {
xemil_t* h = xl_open_file(argv[i]);
h->param.new_text = 1;
h->param.do_xinclude = 1;
if(h != NULL) {
h->param.new_text = 1;
h->param.do_xinclude = 1;
printf("%s:\n", argv[i]);
if(xl_parse(h)) {
xl_node_t** r;

View file

@ -148,7 +148,7 @@ XLDECL int xl_parse(xemil_t* handle);
XLDECL void xl_close(xemil_t* handle);
XLDECL char* xl_get_attribute(xl_node_t* node, const char* key);
XLDECL void xl_free(xl_node_t* node);
XLDECL void xl_replace(xl_node_t* node, xl_node_t* new);
XLDECL void xl_replace(xl_node_t* node, xl_node_t* new_node);
XLDECL xl_node_t** xl_get_nodes(xl_node_t* node, const char* name); /* NULL-terminated */
XLDECL xl_node_t** xl_get_path(xl_node_t* node, const char* path); /* NULL-terminated */

View file

@ -630,19 +630,19 @@ void xl_free(xl_node_t* node) {
recursive_free(node);
}
void xl_replace(xl_node_t* node, xl_node_t* new) {
void xl_replace(xl_node_t* node, xl_node_t* new_node) {
xl_node_t* parent = node->parent;
xl_node_t* child;
if(new->parent != NULL&& new->parent->first_child == new) {
new->parent->first_child = new->next;
if(new->next->prev != NULL) new->next->prev = NULL;
if(new_node->parent != NULL&& new_node->parent->first_child == new_node) {
new_node->parent->first_child = new_node->next;
if(new_node->next->prev != NULL) new_node->next->prev = NULL;
}
if(new->parent != NULL) {
child = new->parent->first_child;
if(new_node->parent != NULL) {
child = new_node->parent->first_child;
while(child != NULL) {
if(child == new) {
if(child == new_node) {
if(child->prev != NULL) child->prev->next = child->next;
if(child->next != NULL) child->next->prev = child->prev;
}
@ -653,23 +653,23 @@ void xl_replace(xl_node_t* node, xl_node_t* new) {
child = parent->first_child;
if(child != NULL && child == node) {
parent->first_child = new;
parent->first_child = new_node;
new->parent = parent;
new->prev = NULL;
new->next = child->next;
new_node->parent = parent;
new_node->prev = NULL;
new_node->next = child->next;
child = child->next;
}
while(child != NULL) {
if(child == node) {
new->parent = parent;
new->next = child->next;
new->prev = child->prev;
new_node->parent = parent;
new_node->next = child->next;
new_node->prev = child->prev;
if(child->prev != NULL) child->prev->next = new;
if(child->next != NULL) child->next->prev = new;
if(child->prev != NULL) child->prev->next = new_node;
if(child->next != NULL) child->next->prev = new_node;
}
child = child->next;