mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-26 00:37:43 +03:00
applied patch from Aswin to fix tree skipping fixed a comment and added a
* xmlreader.c: applied patch from Aswin to fix tree skipping * include/libxml/entities.h entities.c: fixed a comment and added a new xmlNewEntity() entry point * runtest.c: be less verbose * tree.c: space and tabs cleanups daniel svn path=/trunk/; revision=3774
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
Mon Aug 25 16:52:53 CEST 2008 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* xmlreader.c: applied patch from Aswin to fix tree skipping
|
||||||
|
* include/libxml/entities.h entities.c: fixed a comment and
|
||||||
|
added a new xmlNewEntity() entry point
|
||||||
|
* runtest.c: be less verbose
|
||||||
|
* tree.c: space and tabs cleanups
|
||||||
|
|
||||||
Mon Aug 25 10:56:30 CEST 2008 Daniel Veillard <daniel@veillard.com>
|
Mon Aug 25 10:56:30 CEST 2008 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* include/libxml/entities.h entities.c SAX2.c parser.c: rework
|
* include/libxml/entities.h entities.c SAX2.c parser.c: rework
|
||||||
|
|||||||
122
entities.c
122
entities.c
@@ -139,45 +139,19 @@ xmlFreeEntity(xmlEntityPtr entity)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xmlAddEntity : register a new entity for an entities table.
|
* xmlCreateEntity:
|
||||||
|
*
|
||||||
|
* internal routine doing the entity node strutures allocations
|
||||||
*/
|
*/
|
||||||
static xmlEntityPtr
|
static xmlEntityPtr
|
||||||
xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
|
xmlCreateEntity(xmlDictPtr dict, const xmlChar *name, int type,
|
||||||
const xmlChar *ExternalID, const xmlChar *SystemID,
|
const xmlChar *ExternalID, const xmlChar *SystemID,
|
||||||
const xmlChar *content) {
|
const xmlChar *content) {
|
||||||
xmlDictPtr dict = NULL;
|
|
||||||
xmlEntitiesTablePtr table = NULL;
|
|
||||||
xmlEntityPtr ret;
|
xmlEntityPtr ret;
|
||||||
|
|
||||||
if (name == NULL)
|
|
||||||
return(NULL);
|
|
||||||
if (dtd == NULL)
|
|
||||||
return(NULL);
|
|
||||||
if (dtd->doc != NULL)
|
|
||||||
dict = dtd->doc->dict;
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case XML_INTERNAL_GENERAL_ENTITY:
|
|
||||||
case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
|
|
||||||
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
|
|
||||||
if (dtd->entities == NULL)
|
|
||||||
dtd->entities = xmlHashCreateDict(0, dict);
|
|
||||||
table = dtd->entities;
|
|
||||||
break;
|
|
||||||
case XML_INTERNAL_PARAMETER_ENTITY:
|
|
||||||
case XML_EXTERNAL_PARAMETER_ENTITY:
|
|
||||||
if (dtd->pentities == NULL)
|
|
||||||
dtd->pentities = xmlHashCreateDict(0, dict);
|
|
||||||
table = dtd->pentities;
|
|
||||||
break;
|
|
||||||
case XML_INTERNAL_PREDEFINED_ENTITY:
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
if (table == NULL)
|
|
||||||
return(NULL);
|
|
||||||
ret = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));
|
ret = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xmlEntitiesErrMemory("xmlAddEntity:: malloc failed");
|
xmlEntitiesErrMemory("xmlCreateEntity: malloc failed");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, sizeof(xmlEntity));
|
memset(ret, 0, sizeof(xmlEntity));
|
||||||
@@ -216,6 +190,50 @@ xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
|
|||||||
the defining entity */
|
the defining entity */
|
||||||
ret->orig = NULL;
|
ret->orig = NULL;
|
||||||
ret->owner = 0;
|
ret->owner = 0;
|
||||||
|
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* xmlAddEntity : register a new entity for an entities table.
|
||||||
|
*/
|
||||||
|
static xmlEntityPtr
|
||||||
|
xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
|
||||||
|
const xmlChar *ExternalID, const xmlChar *SystemID,
|
||||||
|
const xmlChar *content) {
|
||||||
|
xmlDictPtr dict = NULL;
|
||||||
|
xmlEntitiesTablePtr table = NULL;
|
||||||
|
xmlEntityPtr ret;
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
return(NULL);
|
||||||
|
if (dtd == NULL)
|
||||||
|
return(NULL);
|
||||||
|
if (dtd->doc != NULL)
|
||||||
|
dict = dtd->doc->dict;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case XML_INTERNAL_GENERAL_ENTITY:
|
||||||
|
case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
|
||||||
|
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
|
||||||
|
if (dtd->entities == NULL)
|
||||||
|
dtd->entities = xmlHashCreateDict(0, dict);
|
||||||
|
table = dtd->entities;
|
||||||
|
break;
|
||||||
|
case XML_INTERNAL_PARAMETER_ENTITY:
|
||||||
|
case XML_EXTERNAL_PARAMETER_ENTITY:
|
||||||
|
if (dtd->pentities == NULL)
|
||||||
|
dtd->pentities = xmlHashCreateDict(0, dict);
|
||||||
|
table = dtd->pentities;
|
||||||
|
break;
|
||||||
|
case XML_INTERNAL_PREDEFINED_ENTITY:
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
if (table == NULL)
|
||||||
|
return(NULL);
|
||||||
|
ret = xmlCreateEntity(dict, name, type, ExternalID, SystemID, content);
|
||||||
|
if (ret == NULL)
|
||||||
|
return(NULL);
|
||||||
ret->doc = dtd->doc;
|
ret->doc = dtd->doc;
|
||||||
|
|
||||||
if (xmlHashAddEntry(table, name, ret)) {
|
if (xmlHashAddEntry(table, name, ret)) {
|
||||||
@@ -362,6 +380,44 @@ xmlAddDocEntity(xmlDocPtr doc, const xmlChar *name, int type,
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlNewEntity:
|
||||||
|
* @doc: the document
|
||||||
|
* @name: the entity name
|
||||||
|
* @type: the entity type XML_xxx_yyy_ENTITY
|
||||||
|
* @ExternalID: the entity external ID if available
|
||||||
|
* @SystemID: the entity system ID if available
|
||||||
|
* @content: the entity content
|
||||||
|
*
|
||||||
|
* Create a new entity, this differs from xmlAddDocEntity() that if
|
||||||
|
* the document is NULL or has no internal subset defined, then an
|
||||||
|
* unlinked entity structure will be returned, it is then the responsability
|
||||||
|
* of the caller to link it to the document later or free it when not needed
|
||||||
|
* anymore.
|
||||||
|
*
|
||||||
|
* Returns a pointer to the entity or NULL in case of error
|
||||||
|
*/
|
||||||
|
xmlEntityPtr
|
||||||
|
xmlNewEntity(xmlDocPtr doc, const xmlChar *name, int type,
|
||||||
|
const xmlChar *ExternalID, const xmlChar *SystemID,
|
||||||
|
const xmlChar *content) {
|
||||||
|
xmlEntityPtr ret;
|
||||||
|
xmlDictPtr dict;
|
||||||
|
|
||||||
|
if ((doc != NULL) && (doc->intSubset != NULL)) {
|
||||||
|
return(xmlAddDocEntity(doc, name, type, ExternalID, SystemID, content));
|
||||||
|
}
|
||||||
|
if (doc != NULL)
|
||||||
|
dict = doc->dict;
|
||||||
|
else
|
||||||
|
dict = NULL;
|
||||||
|
ret = xmlCreateEntity(dict, name, type, ExternalID, SystemID, content);
|
||||||
|
if (ret == NULL)
|
||||||
|
return(NULL);
|
||||||
|
ret->doc = doc;
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlGetEntityFromTable:
|
* xmlGetEntityFromTable:
|
||||||
* @table: an entity table
|
* @table: an entity table
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ struct _xmlEntity {
|
|||||||
const xmlChar *URI; /* the full URI as computed */
|
const xmlChar *URI; /* the full URI as computed */
|
||||||
int owner; /* does the entity own the childrens */
|
int owner; /* does the entity own the childrens */
|
||||||
int checked; /* was the entity content checked */
|
int checked; /* was the entity content checked */
|
||||||
|
/* this is also used to count entites
|
||||||
|
* references done from that entity */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -72,9 +74,17 @@ typedef xmlEntitiesTable *xmlEntitiesTablePtr;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LIBXML_LEGACY_ENABLED
|
#ifdef LIBXML_LEGACY_ENABLED
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlInitializePredefinedEntities (void);
|
xmlInitializePredefinedEntities (void);
|
||||||
#endif /* LIBXML_LEGACY_ENABLED */
|
#endif /* LIBXML_LEGACY_ENABLED */
|
||||||
|
|
||||||
|
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||||
|
xmlNewEntity (xmlDocPtr doc,
|
||||||
|
const xmlChar *name,
|
||||||
|
int type,
|
||||||
|
const xmlChar *ExternalID,
|
||||||
|
const xmlChar *SystemID,
|
||||||
|
const xmlChar *content);
|
||||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||||
xmlAddDocEntity (xmlDocPtr doc,
|
xmlAddDocEntity (xmlDocPtr doc,
|
||||||
const xmlChar *name,
|
const xmlChar *name,
|
||||||
@@ -82,53 +92,53 @@ XMLPUBFUN xmlEntityPtr XMLCALL
|
|||||||
const xmlChar *ExternalID,
|
const xmlChar *ExternalID,
|
||||||
const xmlChar *SystemID,
|
const xmlChar *SystemID,
|
||||||
const xmlChar *content);
|
const xmlChar *content);
|
||||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||||
xmlAddDtdEntity (xmlDocPtr doc,
|
xmlAddDtdEntity (xmlDocPtr doc,
|
||||||
const xmlChar *name,
|
const xmlChar *name,
|
||||||
int type,
|
int type,
|
||||||
const xmlChar *ExternalID,
|
const xmlChar *ExternalID,
|
||||||
const xmlChar *SystemID,
|
const xmlChar *SystemID,
|
||||||
const xmlChar *content);
|
const xmlChar *content);
|
||||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||||
xmlGetPredefinedEntity (const xmlChar *name);
|
xmlGetPredefinedEntity (const xmlChar *name);
|
||||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||||
xmlGetDocEntity (xmlDocPtr doc,
|
xmlGetDocEntity (xmlDocPtr doc,
|
||||||
const xmlChar *name);
|
const xmlChar *name);
|
||||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||||
xmlGetDtdEntity (xmlDocPtr doc,
|
xmlGetDtdEntity (xmlDocPtr doc,
|
||||||
const xmlChar *name);
|
const xmlChar *name);
|
||||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||||
xmlGetParameterEntity (xmlDocPtr doc,
|
xmlGetParameterEntity (xmlDocPtr doc,
|
||||||
const xmlChar *name);
|
const xmlChar *name);
|
||||||
#ifdef LIBXML_LEGACY_ENABLED
|
#ifdef LIBXML_LEGACY_ENABLED
|
||||||
XMLPUBFUN const xmlChar * XMLCALL
|
XMLPUBFUN const xmlChar * XMLCALL
|
||||||
xmlEncodeEntities (xmlDocPtr doc,
|
xmlEncodeEntities (xmlDocPtr doc,
|
||||||
const xmlChar *input);
|
const xmlChar *input);
|
||||||
#endif /* LIBXML_LEGACY_ENABLED */
|
#endif /* LIBXML_LEGACY_ENABLED */
|
||||||
XMLPUBFUN xmlChar * XMLCALL
|
XMLPUBFUN xmlChar * XMLCALL
|
||||||
xmlEncodeEntitiesReentrant(xmlDocPtr doc,
|
xmlEncodeEntitiesReentrant(xmlDocPtr doc,
|
||||||
const xmlChar *input);
|
const xmlChar *input);
|
||||||
XMLPUBFUN xmlChar * XMLCALL
|
XMLPUBFUN xmlChar * XMLCALL
|
||||||
xmlEncodeSpecialChars (xmlDocPtr doc,
|
xmlEncodeSpecialChars (xmlDocPtr doc,
|
||||||
const xmlChar *input);
|
const xmlChar *input);
|
||||||
XMLPUBFUN xmlEntitiesTablePtr XMLCALL
|
XMLPUBFUN xmlEntitiesTablePtr XMLCALL
|
||||||
xmlCreateEntitiesTable (void);
|
xmlCreateEntitiesTable (void);
|
||||||
#ifdef LIBXML_TREE_ENABLED
|
#ifdef LIBXML_TREE_ENABLED
|
||||||
XMLPUBFUN xmlEntitiesTablePtr XMLCALL
|
XMLPUBFUN xmlEntitiesTablePtr XMLCALL
|
||||||
xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
|
xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
|
||||||
#endif /* LIBXML_TREE_ENABLED */
|
#endif /* LIBXML_TREE_ENABLED */
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
|
xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
#ifdef LIBXML_OUTPUT_ENABLED
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlDumpEntitiesTable (xmlBufferPtr buf,
|
xmlDumpEntitiesTable (xmlBufferPtr buf,
|
||||||
xmlEntitiesTablePtr table);
|
xmlEntitiesTablePtr table);
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlDumpEntityDecl (xmlBufferPtr buf,
|
xmlDumpEntityDecl (xmlBufferPtr buf,
|
||||||
xmlEntityPtr ent);
|
xmlEntityPtr ent);
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||||
#ifdef LIBXML_LEGACY_ENABLED
|
#ifdef LIBXML_LEGACY_ENABLED
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlCleanupPredefinedEntities(void);
|
xmlCleanupPredefinedEntities(void);
|
||||||
#endif /* LIBXML_LEGACY_ENABLED */
|
#endif /* LIBXML_LEGACY_ENABLED */
|
||||||
|
|
||||||
|
|||||||
159
runtest.c
159
runtest.c
@@ -129,7 +129,7 @@ static int glob(const char *pattern, int flags,
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
if ((pattern == NULL) || (pglob == NULL)) return(-1);
|
if ((pattern == NULL) || (pglob == NULL)) return(-1);
|
||||||
|
|
||||||
strncpy(directory, pattern, 499);
|
strncpy(directory, pattern, 499);
|
||||||
for (len = strlen(directory);len >= 0;len--) {
|
for (len = strlen(directory);len >= 0;len--) {
|
||||||
if (directory[len] == '/') {
|
if (directory[len] == '/') {
|
||||||
@@ -141,12 +141,12 @@ static int glob(const char *pattern, int flags,
|
|||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
|
|
||||||
ret = pglob;
|
ret = pglob;
|
||||||
memset(ret, 0, sizeof(glob_t));
|
memset(ret, 0, sizeof(glob_t));
|
||||||
|
|
||||||
hFind = FindFirstFileA(pattern, &FindFileData);
|
hFind = FindFirstFileA(pattern, &FindFileData);
|
||||||
if (hFind == INVALID_HANDLE_VALUE)
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
return(0);
|
return(0);
|
||||||
nb_paths = 20;
|
nb_paths = 20;
|
||||||
ret->gl_pathv = (char **) malloc(nb_paths * sizeof(char *));
|
ret->gl_pathv = (char **) malloc(nb_paths * sizeof(char *));
|
||||||
@@ -181,14 +181,14 @@ done:
|
|||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void globfree(glob_t *pglob) {
|
static void globfree(glob_t *pglob) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
if (pglob == NULL)
|
if (pglob == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0;i < pglob->gl_pathc;i++) {
|
for (i = 0;i < pglob->gl_pathc;i++) {
|
||||||
if (pglob->gl_pathv[i] != NULL)
|
if (pglob->gl_pathv[i] != NULL)
|
||||||
free(pglob->gl_pathv[i]);
|
free(pglob->gl_pathv[i]);
|
||||||
@@ -222,7 +222,7 @@ fatalError(void) {
|
|||||||
* which is shared to the current running test. We also don't want to have
|
* which is shared to the current running test. We also don't want to have
|
||||||
* network downloads modifying tests.
|
* network downloads modifying tests.
|
||||||
*/
|
*/
|
||||||
static xmlParserInputPtr
|
static xmlParserInputPtr
|
||||||
testExternalEntityLoader(const char *URL, const char *ID,
|
testExternalEntityLoader(const char *URL, const char *ID,
|
||||||
xmlParserCtxtPtr ctxt) {
|
xmlParserCtxtPtr ctxt) {
|
||||||
xmlParserInputPtr ret;
|
xmlParserInputPtr ret;
|
||||||
@@ -234,7 +234,7 @@ testExternalEntityLoader(const char *URL, const char *ID,
|
|||||||
ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt);
|
ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt);
|
||||||
extraMemoryFromResolver += xmlMemUsed() - memused;
|
extraMemoryFromResolver += xmlMemUsed() - memused;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,12 +292,12 @@ channel(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
|
|||||||
/**
|
/**
|
||||||
* xmlParserPrintFileContext:
|
* xmlParserPrintFileContext:
|
||||||
* @input: an xmlParserInputPtr input
|
* @input: an xmlParserInputPtr input
|
||||||
*
|
*
|
||||||
* Displays current context within the input content for error tracking
|
* Displays current context within the input content for error tracking
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
|
xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
|
||||||
xmlGenericErrorFunc chanl, void *data ) {
|
xmlGenericErrorFunc chanl, void *data ) {
|
||||||
const xmlChar *cur, *base;
|
const xmlChar *cur, *base;
|
||||||
unsigned int n, col; /* GCC warns if signed, because compared with sizeof() */
|
unsigned int n, col; /* GCC warns if signed, because compared with sizeof() */
|
||||||
@@ -313,8 +313,8 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
|
|||||||
}
|
}
|
||||||
n = 0;
|
n = 0;
|
||||||
/* search backwards for beginning-of-line (to max buff size) */
|
/* search backwards for beginning-of-line (to max buff size) */
|
||||||
while ((n++ < (sizeof(content)-1)) && (cur > base) &&
|
while ((n++ < (sizeof(content)-1)) && (cur > base) &&
|
||||||
(*(cur) != '\n') && (*(cur) != '\r'))
|
(*(cur) != '\n') && (*(cur) != '\r'))
|
||||||
cur--;
|
cur--;
|
||||||
if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
|
if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
|
||||||
/* calculate the error position in terms of the current position */
|
/* calculate the error position in terms of the current position */
|
||||||
@@ -323,8 +323,8 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
|
|||||||
n = 0;
|
n = 0;
|
||||||
ctnt = content;
|
ctnt = content;
|
||||||
/* copy selected text to our buffer */
|
/* copy selected text to our buffer */
|
||||||
while ((*cur != 0) && (*(cur) != '\n') &&
|
while ((*cur != 0) && (*(cur) != '\n') &&
|
||||||
(*(cur) != '\r') && (n < sizeof(content)-1)) {
|
(*(cur) != '\r') && (n < sizeof(content)-1)) {
|
||||||
*ctnt++ = *cur++;
|
*ctnt++ = *cur++;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
@@ -573,7 +573,7 @@ static char *resultFilename(const char *filename, const char *out,
|
|||||||
(filename[4] == '/'))
|
(filename[4] == '/'))
|
||||||
filename = &filename[5];
|
filename = &filename[5];
|
||||||
*************/
|
*************/
|
||||||
|
|
||||||
base = baseFilename(filename);
|
base = baseFilename(filename);
|
||||||
if (suffix == NULL)
|
if (suffix == NULL)
|
||||||
suffix = ".tmp";
|
suffix = ".tmp";
|
||||||
@@ -650,7 +650,7 @@ static int compareFileMem(const char *filename, const char *mem, int size) {
|
|||||||
int idx = 0;
|
int idx = 0;
|
||||||
struct stat info;
|
struct stat info;
|
||||||
|
|
||||||
if (stat(filename, &info) < 0)
|
if (stat(filename, &info) < 0)
|
||||||
return(-1);
|
return(-1);
|
||||||
if (info.st_size != size)
|
if (info.st_size != size)
|
||||||
return(-1);
|
return(-1);
|
||||||
@@ -661,7 +661,7 @@ static int compareFileMem(const char *filename, const char *mem, int size) {
|
|||||||
res = read(fd, bytes, 4096);
|
res = read(fd, bytes, 4096);
|
||||||
if (res <= 0)
|
if (res <= 0)
|
||||||
break;
|
break;
|
||||||
if (res + idx > size)
|
if (res + idx > size)
|
||||||
break;
|
break;
|
||||||
if (memcmp(bytes, &mem[idx], res) != 0) {
|
if (memcmp(bytes, &mem[idx], res) != 0) {
|
||||||
int ix;
|
int ix;
|
||||||
@@ -683,7 +683,7 @@ static int loadMem(const char *filename, const char **mem, int *size) {
|
|||||||
struct stat info;
|
struct stat info;
|
||||||
char *base;
|
char *base;
|
||||||
int siz = 0;
|
int siz = 0;
|
||||||
if (stat(filename, &info) < 0)
|
if (stat(filename, &info) < 0)
|
||||||
return(-1);
|
return(-1);
|
||||||
base = malloc(info.st_size + 1);
|
base = malloc(info.st_size + 1);
|
||||||
if (base == NULL)
|
if (base == NULL)
|
||||||
@@ -893,7 +893,7 @@ resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xm
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
|
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
|
||||||
|
|
||||||
|
|
||||||
fprintf(SAXdebug, "SAX.resolveEntity(");
|
fprintf(SAXdebug, "SAX.resolveEntity(");
|
||||||
if (publicId != NULL)
|
if (publicId != NULL)
|
||||||
fprintf(SAXdebug, "%s", (char *)publicId);
|
fprintf(SAXdebug, "%s", (char *)publicId);
|
||||||
@@ -953,8 +953,8 @@ getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
|
|||||||
/**
|
/**
|
||||||
* entityDeclDebug:
|
* entityDeclDebug:
|
||||||
* @ctxt: An XML parser context
|
* @ctxt: An XML parser context
|
||||||
* @name: the entity name
|
* @name: the entity name
|
||||||
* @type: the entity type
|
* @type: the entity type
|
||||||
* @publicId: The public ID of the entity
|
* @publicId: The public ID of the entity
|
||||||
* @systemId: The system ID of the entity
|
* @systemId: The system ID of the entity
|
||||||
* @content: the entity value (without processing).
|
* @content: the entity value (without processing).
|
||||||
@@ -983,8 +983,8 @@ const xmlChar *nullstr = BAD_CAST "(null)";
|
|||||||
/**
|
/**
|
||||||
* attributeDeclDebug:
|
* attributeDeclDebug:
|
||||||
* @ctxt: An XML parser context
|
* @ctxt: An XML parser context
|
||||||
* @name: the attribute name
|
* @name: the attribute name
|
||||||
* @type: the attribute type
|
* @type: the attribute type
|
||||||
*
|
*
|
||||||
* An attribute definition has been parsed
|
* An attribute definition has been parsed
|
||||||
*/
|
*/
|
||||||
@@ -1008,8 +1008,8 @@ attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar * elem,
|
|||||||
/**
|
/**
|
||||||
* elementDeclDebug:
|
* elementDeclDebug:
|
||||||
* @ctxt: An XML parser context
|
* @ctxt: An XML parser context
|
||||||
* @name: the element name
|
* @name: the element name
|
||||||
* @type: the element type
|
* @type: the element type
|
||||||
* @content: the element value (without processing).
|
* @content: the element value (without processing).
|
||||||
*
|
*
|
||||||
* An element definition has been parsed
|
* An element definition has been parsed
|
||||||
@@ -1195,7 +1195,7 @@ charactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
|
|||||||
* @ctxt: An XML parser context
|
* @ctxt: An XML parser context
|
||||||
* @name: The entity name
|
* @name: The entity name
|
||||||
*
|
*
|
||||||
* called when an entity reference is detected.
|
* called when an entity reference is detected.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
|
referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
|
||||||
@@ -1431,7 +1431,7 @@ startElementNsDebug(void *ctx ATTRIBUTE_UNUSED,
|
|||||||
else
|
else
|
||||||
fprintf(SAXdebug, ", '%s'", (char *) URI);
|
fprintf(SAXdebug, ", '%s'", (char *) URI);
|
||||||
fprintf(SAXdebug, ", %d", nb_namespaces);
|
fprintf(SAXdebug, ", %d", nb_namespaces);
|
||||||
|
|
||||||
if (namespaces != NULL) {
|
if (namespaces != NULL) {
|
||||||
for (i = 0;i < nb_namespaces * 2;i++) {
|
for (i = 0;i < nb_namespaces * 2;i++) {
|
||||||
fprintf(SAXdebug, ", xmlns");
|
fprintf(SAXdebug, ", xmlns");
|
||||||
@@ -1707,7 +1707,7 @@ saxParseTest(const char *filename, const char *result,
|
|||||||
} else
|
} else
|
||||||
unlink(temp);
|
unlink(temp);
|
||||||
free(temp);
|
free(temp);
|
||||||
|
|
||||||
/* switch back to structured error handling */
|
/* switch back to structured error handling */
|
||||||
xmlSetGenericErrorFunc(NULL, NULL);
|
xmlSetGenericErrorFunc(NULL, NULL);
|
||||||
xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler);
|
xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler);
|
||||||
@@ -1814,7 +1814,7 @@ pushParseTest(const char *filename, const char *result,
|
|||||||
fprintf(stderr, "Failed to load %s\n", filename);
|
fprintf(stderr, "Failed to load %s\n", filename);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LIBXML_HTML_ENABLED
|
#ifdef LIBXML_HTML_ENABLED
|
||||||
if (options & XML_PARSE_HTML)
|
if (options & XML_PARSE_HTML)
|
||||||
ctxt = htmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename,
|
ctxt = htmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename,
|
||||||
@@ -1911,7 +1911,7 @@ memParseTest(const char *filename, const char *result,
|
|||||||
fprintf(stderr, "Failed to load %s\n", filename);
|
fprintf(stderr, "Failed to load %s\n", filename);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
doc = xmlReadMemory(base, size, filename, NULL, 0);
|
doc = xmlReadMemory(base, size, filename, NULL, 0);
|
||||||
unloadMem(base);
|
unloadMem(base);
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
@@ -2076,8 +2076,8 @@ static void processNode(FILE *out, xmlTextReaderPtr reader) {
|
|||||||
|
|
||||||
value = xmlTextReaderConstValue(reader);
|
value = xmlTextReaderConstValue(reader);
|
||||||
|
|
||||||
|
|
||||||
fprintf(out, "%d %d %s %d %d",
|
fprintf(out, "%d %d %s %d %d",
|
||||||
xmlTextReaderDepth(reader),
|
xmlTextReaderDepth(reader),
|
||||||
type,
|
type,
|
||||||
name,
|
name,
|
||||||
@@ -2265,7 +2265,7 @@ static void
|
|||||||
testXPath(const char *str, int xptr, int expr) {
|
testXPath(const char *str, int xptr, int expr) {
|
||||||
xmlXPathObjectPtr res;
|
xmlXPathObjectPtr res;
|
||||||
xmlXPathContextPtr ctxt;
|
xmlXPathContextPtr ctxt;
|
||||||
|
|
||||||
nb_tests++;
|
nb_tests++;
|
||||||
#if defined(LIBXML_XPTR_ENABLED)
|
#if defined(LIBXML_XPTR_ENABLED)
|
||||||
if (xptr) {
|
if (xptr) {
|
||||||
@@ -2336,10 +2336,10 @@ xpathCommonTest(const char *filename, const char *result,
|
|||||||
while (fgets(expression, 4500, input) != NULL) {
|
while (fgets(expression, 4500, input) != NULL) {
|
||||||
len = strlen(expression);
|
len = strlen(expression);
|
||||||
len--;
|
len--;
|
||||||
while ((len >= 0) &&
|
while ((len >= 0) &&
|
||||||
((expression[len] == '\n') || (expression[len] == '\t') ||
|
((expression[len] == '\n') || (expression[len] == '\t') ||
|
||||||
(expression[len] == '\r') || (expression[len] == ' '))) len--;
|
(expression[len] == '\r') || (expression[len] == ' '))) len--;
|
||||||
expression[len + 1] = 0;
|
expression[len + 1] = 0;
|
||||||
if (len >= 0) {
|
if (len >= 0) {
|
||||||
fprintf(xpathOutput,
|
fprintf(xpathOutput,
|
||||||
"\n========================\nExpression: %s\n",
|
"\n========================\nExpression: %s\n",
|
||||||
@@ -3217,7 +3217,7 @@ rngTest(const char *filename,
|
|||||||
* @result: the file with expected result
|
* @result: the file with expected result
|
||||||
* @err: the file with error messages
|
* @err: the file with error messages
|
||||||
*
|
*
|
||||||
* Parse a set of files with streaming, applying an RNG schemas
|
* Parse a set of files with streaming, applying an RNG schemas
|
||||||
*
|
*
|
||||||
* Returns 0 in case of success, an error code otherwise
|
* Returns 0 in case of success, an error code otherwise
|
||||||
*/
|
*/
|
||||||
@@ -3257,7 +3257,7 @@ rngStreamTest(const char *filename,
|
|||||||
* hack is also done in the Makefile
|
* hack is also done in the Makefile
|
||||||
*/
|
*/
|
||||||
if ((!strcmp(prefix, "tutor10_1")) || (!strcmp(prefix, "tutor10_2")) ||
|
if ((!strcmp(prefix, "tutor10_1")) || (!strcmp(prefix, "tutor10_2")) ||
|
||||||
(!strcmp(prefix, "tutor3_2")) || (!strcmp(prefix, "307377")))
|
(!strcmp(prefix, "tutor3_2")) || (!strcmp(prefix, "307377")))
|
||||||
disable_err = 1;
|
disable_err = 1;
|
||||||
|
|
||||||
snprintf(pattern, 499, "./test/relaxng/%s_?.xml", prefix);
|
snprintf(pattern, 499, "./test/relaxng/%s_?.xml", prefix);
|
||||||
@@ -3321,7 +3321,7 @@ static void patternNode(FILE *out, xmlTextReaderPtr reader,
|
|||||||
|
|
||||||
type = xmlTextReaderNodeType(reader);
|
type = xmlTextReaderNodeType(reader);
|
||||||
empty = xmlTextReaderIsEmptyElement(reader);
|
empty = xmlTextReaderIsEmptyElement(reader);
|
||||||
|
|
||||||
if (type == XML_READER_TYPE_ELEMENT) {
|
if (type == XML_READER_TYPE_ELEMENT) {
|
||||||
/* do the check only on element start */
|
/* do the check only on element start */
|
||||||
match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader));
|
match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader));
|
||||||
@@ -3353,9 +3353,9 @@ static void patternNode(FILE *out, xmlTextReaderPtr reader,
|
|||||||
" pattern %s node %s\n",
|
" pattern %s node %s\n",
|
||||||
pattern, path);
|
pattern, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
}
|
||||||
if ((type == XML_READER_TYPE_END_ELEMENT) ||
|
if ((type == XML_READER_TYPE_END_ELEMENT) ||
|
||||||
((type == XML_READER_TYPE_ELEMENT) && (empty))) {
|
((type == XML_READER_TYPE_ELEMENT) && (empty))) {
|
||||||
ret = xmlStreamPop(patstream);
|
ret = xmlStreamPop(patstream);
|
||||||
@@ -3376,7 +3376,7 @@ static void patternNode(FILE *out, xmlTextReaderPtr reader,
|
|||||||
* @result: the file with expected result
|
* @result: the file with expected result
|
||||||
* @err: the file with error messages
|
* @err: the file with error messages
|
||||||
*
|
*
|
||||||
* Parse a set of files with streaming, applying an RNG schemas
|
* Parse a set of files with streaming, applying an RNG schemas
|
||||||
*
|
*
|
||||||
* Returns 0 in case of success, an error code otherwise
|
* Returns 0 in case of success, an error code otherwise
|
||||||
*/
|
*/
|
||||||
@@ -3525,13 +3525,13 @@ patternTest(const char *filename,
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
static xmlXPathObjectPtr
|
static xmlXPathObjectPtr
|
||||||
load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
||||||
xmlXPathObjectPtr xpath;
|
xmlXPathObjectPtr xpath;
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
xmlChar *expr;
|
xmlChar *expr;
|
||||||
xmlXPathContextPtr ctx;
|
xmlXPathContextPtr ctx;
|
||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
xmlNsPtr ns;
|
xmlNsPtr ns;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* load XPath expr as a file
|
* load XPath expr as a file
|
||||||
*/
|
*/
|
||||||
@@ -3543,10 +3543,10 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
|||||||
fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
|
fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check the document is of the right kind
|
* Check the document is of the right kind
|
||||||
*/
|
*/
|
||||||
if(xmlDocGetRootElement(doc) == NULL) {
|
if(xmlDocGetRootElement(doc) == NULL) {
|
||||||
fprintf(stderr,"Error: empty document for file \"%s\"\n", filename);
|
fprintf(stderr,"Error: empty document for file \"%s\"\n", filename);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
@@ -3557,8 +3557,8 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
|||||||
while(node != NULL && !xmlStrEqual(node->name, (const xmlChar *)"XPath")) {
|
while(node != NULL && !xmlStrEqual(node->name, (const xmlChar *)"XPath")) {
|
||||||
node = node->next;
|
node = node->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(node == NULL) {
|
if(node == NULL) {
|
||||||
fprintf(stderr,"Error: XPath element expected in the file \"%s\"\n", filename);
|
fprintf(stderr,"Error: XPath element expected in the file \"%s\"\n", filename);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@@ -3574,8 +3574,8 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
|||||||
ctx = xmlXPathNewContext(parent_doc);
|
ctx = xmlXPathNewContext(parent_doc);
|
||||||
if(ctx == NULL) {
|
if(ctx == NULL) {
|
||||||
fprintf(stderr,"Error: unable to create new context\n");
|
fprintf(stderr,"Error: unable to create new context\n");
|
||||||
xmlFree(expr);
|
xmlFree(expr);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3586,31 +3586,31 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
|||||||
while(ns != NULL) {
|
while(ns != NULL) {
|
||||||
if(xmlXPathRegisterNs(ctx, ns->prefix, ns->href) != 0) {
|
if(xmlXPathRegisterNs(ctx, ns->prefix, ns->href) != 0) {
|
||||||
fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", ns->prefix, ns->href);
|
fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", ns->prefix, ns->href);
|
||||||
xmlFree(expr);
|
xmlFree(expr);
|
||||||
xmlXPathFreeContext(ctx);
|
xmlXPathFreeContext(ctx);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
ns = ns->next;
|
ns = ns->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Evaluate xpath
|
* Evaluate xpath
|
||||||
*/
|
*/
|
||||||
xpath = xmlXPathEvalExpression(expr, ctx);
|
xpath = xmlXPathEvalExpression(expr, ctx);
|
||||||
if(xpath == NULL) {
|
if(xpath == NULL) {
|
||||||
fprintf(stderr,"Error: unable to evaluate xpath expression\n");
|
fprintf(stderr,"Error: unable to evaluate xpath expression\n");
|
||||||
xmlFree(expr);
|
xmlFree(expr);
|
||||||
xmlXPathFreeContext(ctx);
|
xmlXPathFreeContext(ctx);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print_xpath_nodes(xpath->nodesetval); */
|
/* print_xpath_nodes(xpath->nodesetval); */
|
||||||
|
|
||||||
xmlFree(expr);
|
xmlFree(expr);
|
||||||
xmlXPathFreeContext(ctx);
|
xmlXPathFreeContext(ctx);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
return(xpath);
|
return(xpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3620,7 +3620,7 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
|||||||
#define xxx_growBufferReentrant() { \
|
#define xxx_growBufferReentrant() { \
|
||||||
buffer_size *= 2; \
|
buffer_size *= 2; \
|
||||||
buffer = (xmlChar **) \
|
buffer = (xmlChar **) \
|
||||||
xmlRealloc(buffer, buffer_size * sizeof(xmlChar*)); \
|
xmlRealloc(buffer, buffer_size * sizeof(xmlChar*)); \
|
||||||
if (buffer == NULL) { \
|
if (buffer == NULL) { \
|
||||||
perror("realloc failed"); \
|
perror("realloc failed"); \
|
||||||
return(NULL); \
|
return(NULL); \
|
||||||
@@ -3654,7 +3654,7 @@ parse_list(xmlChar *str) {
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
out = buffer;
|
out = buffer;
|
||||||
|
|
||||||
while(*str != '\0') {
|
while(*str != '\0') {
|
||||||
if (out - buffer > buffer_size - 10) {
|
if (out - buffer > buffer_size - 10) {
|
||||||
int indx = out - buffer;
|
int indx = out - buffer;
|
||||||
@@ -3670,12 +3670,12 @@ parse_list(xmlChar *str) {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
|
c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
|
||||||
const char* xpath_filename, const char *ns_filename,
|
const char* xpath_filename, const char *ns_filename,
|
||||||
const char* result_file) {
|
const char* result_file) {
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
xmlXPathObjectPtr xpath = NULL;
|
xmlXPathObjectPtr xpath = NULL;
|
||||||
xmlChar *result = NULL;
|
xmlChar *result = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
xmlChar **inclusive_namespaces = NULL;
|
xmlChar **inclusive_namespaces = NULL;
|
||||||
@@ -3695,24 +3695,24 @@ c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
|
|||||||
fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_filename);
|
fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_filename);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check the document is of the right kind
|
* Check the document is of the right kind
|
||||||
*/
|
*/
|
||||||
if(xmlDocGetRootElement(doc) == NULL) {
|
if(xmlDocGetRootElement(doc) == NULL) {
|
||||||
fprintf(stderr,"Error: empty document for file \"%s\"\n", xml_filename);
|
fprintf(stderr,"Error: empty document for file \"%s\"\n", xml_filename);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* load xpath file if specified
|
* load xpath file if specified
|
||||||
*/
|
*/
|
||||||
if(xpath_filename) {
|
if(xpath_filename) {
|
||||||
xpath = load_xpath_expr(doc, xpath_filename);
|
xpath = load_xpath_expr(doc, xpath_filename);
|
||||||
if(xpath == NULL) {
|
if(xpath == NULL) {
|
||||||
fprintf(stderr,"Error: unable to evaluate xpath expression\n");
|
fprintf(stderr,"Error: unable to evaluate xpath expression\n");
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3721,7 +3721,7 @@ c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
|
|||||||
if (loadMem(ns_filename, &nslist, &nssize)) {
|
if (loadMem(ns_filename, &nslist, &nssize)) {
|
||||||
fprintf(stderr,"Error: unable to evaluate xpath expression\n");
|
fprintf(stderr,"Error: unable to evaluate xpath expression\n");
|
||||||
if(xpath != NULL) xmlXPathFreeObject(xpath);
|
if(xpath != NULL) xmlXPathFreeObject(xpath);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
inclusive_namespaces = parse_list((xmlChar *) nslist);
|
inclusive_namespaces = parse_list((xmlChar *) nslist);
|
||||||
@@ -3729,10 +3729,10 @@ c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Canonical form
|
* Canonical form
|
||||||
*/
|
*/
|
||||||
/* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename); */
|
/* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename); */
|
||||||
ret = xmlC14NDocDumpMemory(doc,
|
ret = xmlC14NDocDumpMemory(doc,
|
||||||
(xpath) ? xpath->nodesetval : NULL,
|
(xpath) ? xpath->nodesetval : NULL,
|
||||||
exclusive, inclusive_namespaces,
|
exclusive, inclusive_namespaces,
|
||||||
with_comments, &result);
|
with_comments, &result);
|
||||||
if (ret >= 0) {
|
if (ret >= 0) {
|
||||||
@@ -3746,15 +3746,15 @@ c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
|
|||||||
fprintf(stderr,"Error: failed to canonicalize XML file \"%s\" (ret=%d)\n", xml_filename, ret);
|
fprintf(stderr,"Error: failed to canonicalize XML file \"%s\" (ret=%d)\n", xml_filename, ret);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cleanup
|
* Cleanup
|
||||||
*/
|
*/
|
||||||
if (result != NULL) xmlFree(result);
|
if (result != NULL) xmlFree(result);
|
||||||
if(xpath != NULL) xmlXPathFreeObject(xpath);
|
if(xpath != NULL) xmlXPathFreeObject(xpath);
|
||||||
if (inclusive_namespaces != NULL) xmlFree(inclusive_namespaces);
|
if (inclusive_namespaces != NULL) xmlFree(inclusive_namespaces);
|
||||||
if (nslist != NULL) free((char *) nslist);
|
if (nslist != NULL) free((char *) nslist);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
@@ -3917,7 +3917,7 @@ testThread(void)
|
|||||||
void *results[MAX_ARGC];
|
void *results[MAX_ARGC];
|
||||||
int ret;
|
int ret;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
xmlInitParser();
|
xmlInitParser();
|
||||||
|
|
||||||
for (repeat = 0; repeat < 500; repeat++) {
|
for (repeat = 0; repeat < 500; repeat++) {
|
||||||
@@ -3993,7 +3993,7 @@ testThread(void)
|
|||||||
DWORD useless;
|
DWORD useless;
|
||||||
|
|
||||||
tid[i] = CreateThread(NULL, 0,
|
tid[i] = CreateThread(NULL, 0,
|
||||||
win32_thread_specific_data,
|
win32_thread_specific_data,
|
||||||
(void *) testfiles[i], 0,
|
(void *) testfiles[i], 0,
|
||||||
&useless);
|
&useless);
|
||||||
if (tid[i] == NULL) {
|
if (tid[i] == NULL) {
|
||||||
@@ -4091,7 +4091,7 @@ testThread(void)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
static int
|
static int
|
||||||
threadsTest(const char *filename ATTRIBUTE_UNUSED,
|
threadsTest(const char *filename ATTRIBUTE_UNUSED,
|
||||||
const char *resul ATTRIBUTE_UNUSED,
|
const char *resul ATTRIBUTE_UNUSED,
|
||||||
const char *err ATTRIBUTE_UNUSED,
|
const char *err ATTRIBUTE_UNUSED,
|
||||||
@@ -4392,7 +4392,6 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
|
|||||||
|
|
||||||
initializeLibxml2();
|
initializeLibxml2();
|
||||||
|
|
||||||
|
|
||||||
for (a = 1; a < argc;a++) {
|
for (a = 1; a < argc;a++) {
|
||||||
if (!strcmp(argv[a], "-v"))
|
if (!strcmp(argv[a], "-v"))
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
|
|||||||
26
runxmlconf.c
26
runxmlconf.c
@@ -446,22 +446,27 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xmlconfTestCases(xmlDocPtr doc, xmlNodePtr cur) {
|
xmlconfTestCases(xmlDocPtr doc, xmlNodePtr cur, int level) {
|
||||||
xmlChar *profile;
|
xmlChar *profile;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int tests = 0;
|
int tests = 0;
|
||||||
|
int output = 0;
|
||||||
|
|
||||||
profile = xmlGetProp(cur, BAD_CAST "PROFILE");
|
if (level == 1) {
|
||||||
if (profile != NULL) {
|
profile = xmlGetProp(cur, BAD_CAST "PROFILE");
|
||||||
printf("Test cases: %s\n", (char *) profile);
|
if (profile != NULL) {
|
||||||
xmlFree(profile);
|
output = 1;
|
||||||
|
level++;
|
||||||
|
printf("Test cases: %s\n", (char *) profile);
|
||||||
|
xmlFree(profile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cur = cur->children;
|
cur = cur->children;
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
/* look only at elements we ignore everything else */
|
/* look only at elements we ignore everything else */
|
||||||
if (cur->type == XML_ELEMENT_NODE) {
|
if (cur->type == XML_ELEMENT_NODE) {
|
||||||
if (xmlStrEqual(cur->name, BAD_CAST "TESTCASES")) {
|
if (xmlStrEqual(cur->name, BAD_CAST "TESTCASES")) {
|
||||||
ret += xmlconfTestCases(doc, cur);
|
ret += xmlconfTestCases(doc, cur, level);
|
||||||
} else if (xmlStrEqual(cur->name, BAD_CAST "TEST")) {
|
} else if (xmlStrEqual(cur->name, BAD_CAST "TEST")) {
|
||||||
if (xmlconfTestItem(doc, cur) >= 0)
|
if (xmlconfTestItem(doc, cur) >= 0)
|
||||||
ret++;
|
ret++;
|
||||||
@@ -472,8 +477,10 @@ xmlconfTestCases(xmlDocPtr doc, xmlNodePtr cur) {
|
|||||||
}
|
}
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
if (tests > 0)
|
if (output == 1) {
|
||||||
printf("Test cases: %d tests\n", tests);
|
if (tests > 0)
|
||||||
|
printf("Test cases: %d tests\n", tests);
|
||||||
|
}
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,7 +500,7 @@ xmlconfTestSuite(xmlDocPtr doc, xmlNodePtr cur) {
|
|||||||
/* look only at elements we ignore everything else */
|
/* look only at elements we ignore everything else */
|
||||||
if (cur->type == XML_ELEMENT_NODE) {
|
if (cur->type == XML_ELEMENT_NODE) {
|
||||||
if (xmlStrEqual(cur->name, BAD_CAST "TESTCASES")) {
|
if (xmlStrEqual(cur->name, BAD_CAST "TESTCASES")) {
|
||||||
ret += xmlconfTestCases(doc, cur);
|
ret += xmlconfTestCases(doc, cur, 1);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Unhandled element %s\n", (char *)cur->name);
|
fprintf(stderr, "Unhandled element %s\n", (char *)cur->name);
|
||||||
}
|
}
|
||||||
@@ -584,6 +591,7 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
|
|||||||
ret = 1;
|
ret = 1;
|
||||||
printf("Total %d tests, %d errors, %d leaks\n",
|
printf("Total %d tests, %d errors, %d leaks\n",
|
||||||
nb_tests, nb_errors, nb_leaks);
|
nb_tests, nb_errors, nb_leaks);
|
||||||
|
printf("See %s for detailed output\n", LOGFILE);
|
||||||
}
|
}
|
||||||
xmlXPathFreeContext(ctxtXPath);
|
xmlXPathFreeContext(ctxtXPath);
|
||||||
xmlCleanupParser();
|
xmlCleanupParser();
|
||||||
|
|||||||
18
xmlreader.c
18
xmlreader.c
@@ -1847,17 +1847,22 @@ xmlTextReaderNextTree(xmlTextReaderPtr reader)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (reader->state != XML_TEXTREADER_BACKTRACK) {
|
if (reader->state != XML_TEXTREADER_BACKTRACK) {
|
||||||
if (reader->node->children != 0) {
|
/* Here removed traversal to child, because we want to skip the subtree,
|
||||||
reader->node = reader->node->children;
|
replace with traversal to sibling to skip subtree */
|
||||||
reader->depth++;
|
if (reader->node->next != 0) {
|
||||||
|
reader->node = reader->node->next;// Move to sibling if present,skipping sub-tree
|
||||||
|
//reader->depth++;
|
||||||
reader->state = XML_TEXTREADER_START;
|
reader->state = XML_TEXTREADER_START;
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if reader->node->next is NULL mean no subtree for current node,
|
||||||
|
so need to move to sibling of parent node if present */
|
||||||
if ((reader->node->type == XML_ELEMENT_NODE) ||
|
if ((reader->node->type == XML_ELEMENT_NODE) ||
|
||||||
(reader->node->type == XML_ATTRIBUTE_NODE)) {
|
(reader->node->type == XML_ATTRIBUTE_NODE)) {
|
||||||
reader->state = XML_TEXTREADER_BACKTRACK;
|
reader->state = XML_TEXTREADER_BACKTRACK;
|
||||||
return(1);
|
xmlTextReaderRead(reader);// This will move to parent if present
|
||||||
|
//return(xmlTextReaderReadTree(reader));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1876,7 +1881,8 @@ xmlTextReaderNextTree(xmlTextReaderPtr reader)
|
|||||||
reader->node = reader->node->parent;
|
reader->node = reader->node->parent;
|
||||||
reader->depth--;
|
reader->depth--;
|
||||||
reader->state = XML_TEXTREADER_BACKTRACK;
|
reader->state = XML_TEXTREADER_BACKTRACK;
|
||||||
return(1);
|
xmlTextReaderNextTree(reader); //Repeat process to move to sibling of parent node if present
|
||||||
|
//return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
reader->state = XML_TEXTREADER_END;
|
reader->state = XML_TEXTREADER_END;
|
||||||
|
|||||||
Reference in New Issue
Block a user