This commit is contained in:
Nishi 2026-03-09 23:23:15 +09:00
commit 3b7633c2cb
Signed by: nishi
GPG key ID: 27EF69B208EB9343
3 changed files with 17 additions and 12 deletions

View file

@ -14,6 +14,7 @@ typedef struct xl_driver xl_driver_t;
typedef struct xemil xemil_t;
typedef struct xl_node xl_node_t;
typedef struct xl_attribute xl_attribute_t;
typedef struct xl_param xl_param_t;
#define XL_SKIPPABLE(x) (((x) == ' ') || ((x) == '\t') || ((x) == '\n') || ((x) == '\r'))
@ -53,15 +54,20 @@ struct xl_node {
xl_node_t* next;
};
struct xl_param {
int new_text;
int do_xinclude;
};
struct xemil {
xl_driver_t* driver;
void* drv_opaque;
void* drv_arg;
int new_text;
int do_xinclude;
char* path;
xl_node_t* pre;
xl_node_t* root;
xl_param_t param;
};
#ifdef __cplusplus

View file

@ -12,8 +12,8 @@ xemil_t* xl_open(xl_driver_t* driver, void* arg) {
handle->path = NULL;
handle->new_text = 0;
handle->do_xinclude = 0;
handle->param.new_text = 0;
handle->param.do_xinclude = 0;
if(!handle->driver->open(handle)) {
free(handle);
@ -213,7 +213,7 @@ int xl_parse(xemil_t* handle) {
char* text;
xl_node_t* last;
if(handle->new_text) {
if(handle->param.new_text) {
old = NULL;
last = current->first_child;
@ -241,7 +241,7 @@ int xl_parse(xemil_t* handle) {
text[strlen(text) - 2] = 0;
}
if(handle->new_text) {
if(handle->param.new_text) {
if(last == NULL) {
xl_node_t* n;
@ -289,7 +289,7 @@ int xl_parse(xemil_t* handle) {
nest_level--;
if(handle->new_text) {
if(handle->param.new_text) {
xl_node_t* n = current->first_child;
if(current->text != NULL) free(current->text);
@ -493,7 +493,7 @@ int xl_parse(xemil_t* handle) {
char* old;
xl_node_t* last;
if(handle->new_text) {
if(handle->param.new_text) {
old = NULL;
last = current->first_child;
@ -529,7 +529,7 @@ int xl_parse(xemil_t* handle) {
text[new] = 0;
}
if(handle->new_text) {
if(handle->param.new_text) {
if(last == NULL) {
xl_node_t* n;
@ -563,7 +563,7 @@ int xl_parse(xemil_t* handle) {
CLEANUP;
if(handle->do_xinclude) {
if(handle->param.do_xinclude) {
xl_xinclude_scan(handle, handle->root);
}

View file

@ -21,8 +21,7 @@ void xl_xinclude_scan(xemil_t* handle, xl_node_t* node) {
if(xpointer == NULL) xpointer = "element(/)";
if((new = xl_open_file(href)) != NULL) {
new->do_xinclude = 1;
new->new_text = handle->new_text;
new->param = handle->param;
if(xl_parse(new) && new->root != NULL) {
xl_node_t** nodes;
if((nodes = xl_xpointer(new->root, xpointer)) != NULL) {