fix some bug

This commit is contained in:
Nishi 2026-03-02 03:53:10 +09:00
commit d0f2fc6c1c
Signed by: nishi
GPG key ID: 27EF69B208EB9343
3 changed files with 16 additions and 2 deletions

View file

@ -81,6 +81,8 @@ XLDECL xemil_t* xl_open_file(const char* filename);
/* util.c */
XLDECL char* xl_util_trim(const char* str);
XLDECL char* xl_util_strdup(const char* str);
/* unicode.c */
XLDECL int xl_unicode_count(unsigned char c);

View file

@ -293,6 +293,8 @@ int xl_parse(xemil_t* handle) {
n->text = str;
if(strlen(n->text) == 0) {
xl_node_t* o = n;
free(n->text);
n->text = NULL;
@ -300,9 +302,9 @@ int xl_parse(xemil_t* handle) {
if(n->next != NULL) n->next->prev = n->prev;
n = n->next;
if(n != NULL) free(n->prev);
free(o);
if(n->prev == NULL) n->parent->first_child = n;
if(n != NULL && n->prev == NULL && n->parent != NULL) n->parent->first_child = n;
continue;
}
@ -480,6 +482,8 @@ int xl_parse(xemil_t* handle) {
if(last->type == XL_NODE_TEXT){
old = last->text;
}else{
last = NULL;
}
}
}else{

View file

@ -74,3 +74,11 @@ char* xl_util_trim(const char* str) {
return s;
}
char* xl_util_strdup(const char* str){
char* s = malloc(strlen(str) + 1);
strcpy(s, str);
return s;
}