| Index: third_party/libxml/runtest.c
|
| diff --git a/third_party/libxml/runtest.c b/third_party/libxml/runtest.c
|
| index b694d565caf10fedbc7566f2bf15b893c57d5a19..fa925c10534ae76e539783d04b062a4a03d902f9 100644
|
| --- a/third_party/libxml/runtest.c
|
| +++ b/third_party/libxml/runtest.c
|
| @@ -129,7 +129,7 @@ static int glob(const char *pattern, int flags,
|
| int len;
|
|
|
| if ((pattern == NULL) || (pglob == NULL)) return(-1);
|
| -
|
| +
|
| strncpy(directory, pattern, 499);
|
| for (len = strlen(directory);len >= 0;len--) {
|
| if (directory[len] == '/') {
|
| @@ -141,12 +141,12 @@ static int glob(const char *pattern, int flags,
|
| if (len <= 0)
|
| len = 0;
|
|
|
| -
|
| +
|
| ret = pglob;
|
| memset(ret, 0, sizeof(glob_t));
|
| -
|
| +
|
| hFind = FindFirstFileA(pattern, &FindFileData);
|
| - if (hFind == INVALID_HANDLE_VALUE)
|
| + if (hFind == INVALID_HANDLE_VALUE)
|
| return(0);
|
| nb_paths = 20;
|
| ret->gl_pathv = (char **) malloc(nb_paths * sizeof(char *));
|
| @@ -181,14 +181,14 @@ done:
|
| FindClose(hFind);
|
| return(0);
|
| }
|
| -
|
| +
|
|
|
|
|
| static void globfree(glob_t *pglob) {
|
| unsigned int i;
|
| if (pglob == NULL)
|
| return;
|
| -
|
| +
|
| for (i = 0;i < pglob->gl_pathc;i++) {
|
| if (pglob->gl_pathv[i] != NULL)
|
| 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
|
| * network downloads modifying tests.
|
| */
|
| -static xmlParserInputPtr
|
| +static xmlParserInputPtr
|
| testExternalEntityLoader(const char *URL, const char *ID,
|
| xmlParserCtxtPtr ctxt) {
|
| xmlParserInputPtr ret;
|
| @@ -234,7 +234,7 @@ testExternalEntityLoader(const char *URL, const char *ID,
|
| ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt);
|
| extraMemoryFromResolver += xmlMemUsed() - memused;
|
| }
|
| -
|
| +
|
| return(ret);
|
| }
|
|
|
| @@ -292,12 +292,12 @@ channel(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
|
| /**
|
| * xmlParserPrintFileContext:
|
| * @input: an xmlParserInputPtr input
|
| - *
|
| + *
|
| * Displays current context within the input content for error tracking
|
| */
|
|
|
| static void
|
| -xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
|
| +xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
|
| xmlGenericErrorFunc chanl, void *data ) {
|
| const xmlChar *cur, *base;
|
| unsigned int n, col; /* GCC warns if signed, because compared with sizeof() */
|
| @@ -313,8 +313,8 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
|
| }
|
| n = 0;
|
| /* search backwards for beginning-of-line (to max buff size) */
|
| - while ((n++ < (sizeof(content)-1)) && (cur > base) &&
|
| - (*(cur) != '\n') && (*(cur) != '\r'))
|
| + while ((n++ < (sizeof(content)-1)) && (cur > base) &&
|
| + (*(cur) != '\n') && (*(cur) != '\r'))
|
| cur--;
|
| if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
|
| /* calculate the error position in terms of the current position */
|
| @@ -323,8 +323,8 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
|
| n = 0;
|
| ctnt = content;
|
| /* copy selected text to our buffer */
|
| - while ((*cur != 0) && (*(cur) != '\n') &&
|
| - (*(cur) != '\r') && (n < sizeof(content)-1)) {
|
| + while ((*cur != 0) && (*(cur) != '\n') &&
|
| + (*(cur) != '\r') && (n < sizeof(content)-1)) {
|
| *ctnt++ = *cur++;
|
| n++;
|
| }
|
| @@ -573,7 +573,7 @@ static char *resultFilename(const char *filename, const char *out,
|
| (filename[4] == '/'))
|
| filename = &filename[5];
|
| *************/
|
| -
|
| +
|
| base = baseFilename(filename);
|
| if (suffix == NULL)
|
| suffix = ".tmp";
|
| @@ -650,7 +650,7 @@ static int compareFileMem(const char *filename, const char *mem, int size) {
|
| int idx = 0;
|
| struct stat info;
|
|
|
| - if (stat(filename, &info) < 0)
|
| + if (stat(filename, &info) < 0)
|
| return(-1);
|
| if (info.st_size != size)
|
| return(-1);
|
| @@ -661,7 +661,7 @@ static int compareFileMem(const char *filename, const char *mem, int size) {
|
| res = read(fd, bytes, 4096);
|
| if (res <= 0)
|
| break;
|
| - if (res + idx > size)
|
| + if (res + idx > size)
|
| break;
|
| if (memcmp(bytes, &mem[idx], res) != 0) {
|
| int ix;
|
| @@ -683,7 +683,7 @@ static int loadMem(const char *filename, const char **mem, int *size) {
|
| struct stat info;
|
| char *base;
|
| int siz = 0;
|
| - if (stat(filename, &info) < 0)
|
| + if (stat(filename, &info) < 0)
|
| return(-1);
|
| base = malloc(info.st_size + 1);
|
| if (base == NULL)
|
| @@ -893,7 +893,7 @@ resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xm
|
| return(NULL);
|
| /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
|
|
|
| -
|
| +
|
| fprintf(SAXdebug, "SAX.resolveEntity(");
|
| if (publicId != NULL)
|
| fprintf(SAXdebug, "%s", (char *)publicId);
|
| @@ -953,8 +953,8 @@ getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
|
| /**
|
| * entityDeclDebug:
|
| * @ctxt: An XML parser context
|
| - * @name: the entity name
|
| - * @type: the entity type
|
| + * @name: the entity name
|
| + * @type: the entity type
|
| * @publicId: The public ID of the entity
|
| * @systemId: The system ID of the entity
|
| * @content: the entity value (without processing).
|
| @@ -983,8 +983,8 @@ const xmlChar *nullstr = BAD_CAST "(null)";
|
| /**
|
| * attributeDeclDebug:
|
| * @ctxt: An XML parser context
|
| - * @name: the attribute name
|
| - * @type: the attribute type
|
| + * @name: the attribute name
|
| + * @type: the attribute type
|
| *
|
| * An attribute definition has been parsed
|
| */
|
| @@ -1008,8 +1008,8 @@ attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar * elem,
|
| /**
|
| * elementDeclDebug:
|
| * @ctxt: An XML parser context
|
| - * @name: the element name
|
| - * @type: the element type
|
| + * @name: the element name
|
| + * @type: the element type
|
| * @content: the element value (without processing).
|
| *
|
| * 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
|
| * @name: The entity name
|
| *
|
| - * called when an entity reference is detected.
|
| + * called when an entity reference is detected.
|
| */
|
| static void
|
| referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
|
| @@ -1431,7 +1431,7 @@ startElementNsDebug(void *ctx ATTRIBUTE_UNUSED,
|
| else
|
| fprintf(SAXdebug, ", '%s'", (char *) URI);
|
| fprintf(SAXdebug, ", %d", nb_namespaces);
|
| -
|
| +
|
| if (namespaces != NULL) {
|
| for (i = 0;i < nb_namespaces * 2;i++) {
|
| fprintf(SAXdebug, ", xmlns");
|
| @@ -1704,10 +1704,12 @@ saxParseTest(const char *filename, const char *result,
|
| if (compareFiles(temp, result)) {
|
| fprintf(stderr, "Got a difference for %s\n", filename);
|
| ret = 1;
|
| - } else
|
| - unlink(temp);
|
| - free(temp);
|
| -
|
| + }
|
| + if (temp != NULL) {
|
| + unlink(temp);
|
| + free(temp);
|
| + }
|
| +
|
| /* switch back to structured error handling */
|
| xmlSetGenericErrorFunc(NULL, NULL);
|
| xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler);
|
| @@ -1779,8 +1781,10 @@ oldParseTest(const char *filename, const char *result,
|
| }
|
| xmlFreeDoc(doc);
|
|
|
| - unlink(temp);
|
| - free(temp);
|
| + if (temp != NULL) {
|
| + unlink(temp);
|
| + free(temp);
|
| + }
|
| return(res);
|
| }
|
|
|
| @@ -1814,7 +1818,7 @@ pushParseTest(const char *filename, const char *result,
|
| fprintf(stderr, "Failed to load %s\n", filename);
|
| return(-1);
|
| }
|
| -
|
| +
|
| #ifdef LIBXML_HTML_ENABLED
|
| if (options & XML_PARSE_HTML)
|
| ctxt = htmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename,
|
| @@ -1911,7 +1915,7 @@ memParseTest(const char *filename, const char *result,
|
| fprintf(stderr, "Failed to load %s\n", filename);
|
| return(-1);
|
| }
|
| -
|
| +
|
| doc = xmlReadMemory(base, size, filename, NULL, 0);
|
| unloadMem(base);
|
| if (doc == NULL) {
|
| @@ -1980,8 +1984,10 @@ noentParseTest(const char *filename, const char *result,
|
| }
|
| xmlFreeDoc(doc);
|
|
|
| - unlink(temp);
|
| - free(temp);
|
| + if (temp != NULL) {
|
| + unlink(temp);
|
| + free(temp);
|
| + }
|
| return(res);
|
| }
|
|
|
| @@ -2076,8 +2082,8 @@ static void processNode(FILE *out, xmlTextReaderPtr reader) {
|
|
|
| value = xmlTextReaderConstValue(reader);
|
|
|
| -
|
| - fprintf(out, "%d %d %s %d %d",
|
| +
|
| + fprintf(out, "%d %d %s %d %d",
|
| xmlTextReaderDepth(reader),
|
| type,
|
| name,
|
| @@ -2120,8 +2126,10 @@ streamProcessTest(const char *filename, const char *result, const char *err,
|
| testErrorHandler(NULL, "Relax-NG schema %s failed to compile\n",
|
| rng);
|
| fclose(t);
|
| - unlink(temp);
|
| - free(temp);
|
| + if (temp != NULL) {
|
| + unlink(temp);
|
| + free(temp);
|
| + }
|
| return(0);
|
| }
|
| }
|
| @@ -2147,8 +2155,10 @@ streamProcessTest(const char *filename, const char *result, const char *err,
|
| if (t != NULL) {
|
| fclose(t);
|
| ret = compareFiles(temp, result);
|
| - unlink(temp);
|
| - free(temp);
|
| + if (temp != NULL) {
|
| + unlink(temp);
|
| + free(temp);
|
| + }
|
| if (ret) {
|
| fprintf(stderr, "Result for %s failed\n", filename);
|
| return(-1);
|
| @@ -2265,7 +2275,7 @@ static void
|
| testXPath(const char *str, int xptr, int expr) {
|
| xmlXPathObjectPtr res;
|
| xmlXPathContextPtr ctxt;
|
| -
|
| +
|
| nb_tests++;
|
| #if defined(LIBXML_XPTR_ENABLED)
|
| if (xptr) {
|
| @@ -2336,10 +2346,10 @@ xpathCommonTest(const char *filename, const char *result,
|
| while (fgets(expression, 4500, input) != NULL) {
|
| len = strlen(expression);
|
| len--;
|
| - while ((len >= 0) &&
|
| + while ((len >= 0) &&
|
| ((expression[len] == '\n') || (expression[len] == '\t') ||
|
| (expression[len] == '\r') || (expression[len] == ' '))) len--;
|
| - expression[len + 1] = 0;
|
| + expression[len + 1] = 0;
|
| if (len >= 0) {
|
| fprintf(xpathOutput,
|
| "\n========================\nExpression: %s\n",
|
| @@ -2357,8 +2367,10 @@ xpathCommonTest(const char *filename, const char *result,
|
| }
|
| }
|
|
|
| - unlink(temp);
|
| - free(temp);
|
| + if (temp != NULL) {
|
| + unlink(temp);
|
| + free(temp);
|
| + }
|
| return(ret);
|
| }
|
|
|
| @@ -2527,8 +2539,10 @@ xmlidDocTest(const char *filename,
|
| }
|
| }
|
|
|
| - unlink(temp);
|
| - free(temp);
|
| + if (temp != NULL) {
|
| + unlink(temp);
|
| + free(temp);
|
| + }
|
| xmlFreeDoc(xpathDocument);
|
|
|
| if (err != NULL) {
|
| @@ -2614,8 +2628,10 @@ uriCommonTest(const char *filename,
|
| if (f == NULL) {
|
| fprintf(stderr, "failed to open input file %s\n", filename);
|
| fclose(o);
|
| - unlink(temp);
|
| - free(temp);
|
| + if (temp != NULL) {
|
| + unlink(temp);
|
| + free(temp);
|
| + }
|
| return(-1);
|
| }
|
|
|
| @@ -2658,8 +2674,10 @@ uriCommonTest(const char *filename,
|
| }
|
| }
|
|
|
| - unlink(temp);
|
| - free(temp);
|
| + if (temp != NULL) {
|
| + unlink(temp);
|
| + free(temp);
|
| + }
|
| return(res);
|
| }
|
|
|
| @@ -2933,8 +2951,10 @@ schemasOneTest(const char *sch,
|
| ret = 1;
|
| }
|
| }
|
| - unlink(temp);
|
| - free(temp);
|
| + if (temp != NULL) {
|
| + unlink(temp);
|
| + free(temp);
|
| + }
|
|
|
| if ((validResult != 0) && (err != NULL)) {
|
| if (compareFileMem(err, testErrors, testErrorsSize)) {
|
| @@ -3100,14 +3120,17 @@ rngOneTest(const char *sch,
|
| filename);
|
| }
|
| fclose(schemasOutput);
|
| + ret = 0;
|
| if (result) {
|
| if (compareFiles(temp, result)) {
|
| fprintf(stderr, "Result for %s on %s failed\n", filename, sch);
|
| ret = 1;
|
| }
|
| }
|
| - unlink(temp);
|
| - free(temp);
|
| + if (temp != NULL) {
|
| + unlink(temp);
|
| + free(temp);
|
| + }
|
|
|
| if (err != NULL) {
|
| if (compareFileMem(err, testErrors, testErrorsSize)) {
|
| @@ -3142,7 +3165,7 @@ rngTest(const char *filename,
|
| const char *instance;
|
| xmlRelaxNGParserCtxtPtr ctxt;
|
| xmlRelaxNGPtr schemas;
|
| - int res = 0, len, ret;
|
| + int res = 0, len, ret = 0;
|
| char pattern[500];
|
| char prefix[500];
|
| char result[500];
|
| @@ -3207,7 +3230,7 @@ rngTest(const char *filename,
|
| globfree(&globbuf);
|
| xmlRelaxNGFree(schemas);
|
|
|
| - return(res);
|
| + return(ret);
|
| }
|
|
|
| #ifdef LIBXML_READER_ENABLED
|
| @@ -3217,7 +3240,7 @@ rngTest(const char *filename,
|
| * @result: the file with expected result
|
| * @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
|
| */
|
| @@ -3257,7 +3280,8 @@ rngStreamTest(const char *filename,
|
| * hack is also done in the Makefile
|
| */
|
| if ((!strcmp(prefix, "tutor10_1")) || (!strcmp(prefix, "tutor10_2")) ||
|
| - (!strcmp(prefix, "tutor3_2")) || (!strcmp(prefix, "307377")))
|
| + (!strcmp(prefix, "tutor3_2")) || (!strcmp(prefix, "307377")) ||
|
| + (!strcmp(prefix, "tutor8_2")))
|
| disable_err = 1;
|
|
|
| snprintf(pattern, 499, "./test/relaxng/%s_?.xml", prefix);
|
| @@ -3321,7 +3345,7 @@ static void patternNode(FILE *out, xmlTextReaderPtr reader,
|
|
|
| type = xmlTextReaderNodeType(reader);
|
| empty = xmlTextReaderIsEmptyElement(reader);
|
| -
|
| +
|
| if (type == XML_READER_TYPE_ELEMENT) {
|
| /* do the check only on element start */
|
| match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader));
|
| @@ -3353,9 +3377,9 @@ static void patternNode(FILE *out, xmlTextReaderPtr reader,
|
| " pattern %s node %s\n",
|
| pattern, path);
|
| }
|
| -
|
|
|
| - }
|
| +
|
| + }
|
| if ((type == XML_READER_TYPE_END_ELEMENT) ||
|
| ((type == XML_READER_TYPE_ELEMENT) && (empty))) {
|
| ret = xmlStreamPop(patstream);
|
| @@ -3376,7 +3400,7 @@ static void patternNode(FILE *out, xmlTextReaderPtr reader,
|
| * @result: the file with expected result
|
| * @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
|
| */
|
| @@ -3463,7 +3487,7 @@ patternTest(const char *filename,
|
| namespaces[j++] = ns->prefix;
|
| }
|
| namespaces[j++] = NULL;
|
| - namespaces[j++] = NULL;
|
| + namespaces[j] = NULL;
|
|
|
| patternc = xmlPatterncompile((const xmlChar *) str, doc->dict,
|
| 0, &namespaces[0]);
|
| @@ -3511,8 +3535,10 @@ patternTest(const char *filename,
|
| fprintf(stderr, "Result for %s failed\n", filename);
|
| ret = 1;
|
| }
|
| - unlink(temp);
|
| - free(temp);
|
| + if (temp != NULL) {
|
| + unlink(temp);
|
| + free(temp);
|
| + }
|
| return(ret);
|
| }
|
| #endif /* READER */
|
| @@ -3525,13 +3551,13 @@ patternTest(const char *filename,
|
| ************************************************************************/
|
| static xmlXPathObjectPtr
|
| load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
| - xmlXPathObjectPtr xpath;
|
| + xmlXPathObjectPtr xpath;
|
| xmlDocPtr doc;
|
| xmlChar *expr;
|
| - xmlXPathContextPtr ctx;
|
| + xmlXPathContextPtr ctx;
|
| xmlNodePtr node;
|
| xmlNsPtr ns;
|
| -
|
| +
|
| /*
|
| * load XPath expr as a file
|
| */
|
| @@ -3543,10 +3569,10 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
| fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
|
| return(NULL);
|
| }
|
| -
|
| +
|
| /*
|
| * Check the document is of the right kind
|
| - */
|
| + */
|
| if(xmlDocGetRootElement(doc) == NULL) {
|
| fprintf(stderr,"Error: empty document for file \"%s\"\n", filename);
|
| xmlFreeDoc(doc);
|
| @@ -3557,8 +3583,8 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
| while(node != NULL && !xmlStrEqual(node->name, (const xmlChar *)"XPath")) {
|
| node = node->next;
|
| }
|
| -
|
| - if(node == NULL) {
|
| +
|
| + if(node == NULL) {
|
| fprintf(stderr,"Error: XPath element expected in the file \"%s\"\n", filename);
|
| xmlFreeDoc(doc);
|
| return(NULL);
|
| @@ -3574,8 +3600,8 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
| ctx = xmlXPathNewContext(parent_doc);
|
| if(ctx == NULL) {
|
| fprintf(stderr,"Error: unable to create new context\n");
|
| - xmlFree(expr);
|
| - xmlFreeDoc(doc);
|
| + xmlFree(expr);
|
| + xmlFreeDoc(doc);
|
| return(NULL);
|
| }
|
|
|
| @@ -3586,31 +3612,31 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
| while(ns != NULL) {
|
| 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);
|
| - xmlFree(expr);
|
| - xmlXPathFreeContext(ctx);
|
| - xmlFreeDoc(doc);
|
| + xmlFree(expr);
|
| + xmlXPathFreeContext(ctx);
|
| + xmlFreeDoc(doc);
|
| return(NULL);
|
| }
|
| ns = ns->next;
|
| }
|
|
|
| - /*
|
| + /*
|
| * Evaluate xpath
|
| */
|
| xpath = xmlXPathEvalExpression(expr, ctx);
|
| if(xpath == NULL) {
|
| fprintf(stderr,"Error: unable to evaluate xpath expression\n");
|
| - xmlFree(expr);
|
| - xmlXPathFreeContext(ctx);
|
| - xmlFreeDoc(doc);
|
| +xmlFree(expr);
|
| + xmlXPathFreeContext(ctx);
|
| + xmlFreeDoc(doc);
|
| return(NULL);
|
| }
|
|
|
| /* print_xpath_nodes(xpath->nodesetval); */
|
|
|
| - xmlFree(expr);
|
| - xmlXPathFreeContext(ctx);
|
| - xmlFreeDoc(doc);
|
| + xmlFree(expr);
|
| + xmlXPathFreeContext(ctx);
|
| + xmlFreeDoc(doc);
|
| return(xpath);
|
| }
|
|
|
| @@ -3620,7 +3646,7 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
|
| #define xxx_growBufferReentrant() { \
|
| buffer_size *= 2; \
|
| buffer = (xmlChar **) \
|
| - xmlRealloc(buffer, buffer_size * sizeof(xmlChar*)); \
|
| + xmlRealloc(buffer, buffer_size * sizeof(xmlChar*)); \
|
| if (buffer == NULL) { \
|
| perror("realloc failed"); \
|
| return(NULL); \
|
| @@ -3642,7 +3668,6 @@ parse_list(xmlChar *str) {
|
| if((str[0] == '\'') && (str[len - 1] == '\'')) {
|
| str[len - 1] = '\0';
|
| str++;
|
| - len -= 2;
|
| }
|
| /*
|
| * allocate an translation buffer.
|
| @@ -3654,7 +3679,7 @@ parse_list(xmlChar *str) {
|
| return(NULL);
|
| }
|
| out = buffer;
|
| -
|
| +
|
| while(*str != '\0') {
|
| if (out - buffer > buffer_size - 10) {
|
| int indx = out - buffer;
|
| @@ -3670,12 +3695,12 @@ parse_list(xmlChar *str) {
|
| return buffer;
|
| }
|
|
|
| -static int
|
| -c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
|
| +static int
|
| +c14nRunTest(const char* xml_filename, int with_comments, int mode,
|
| const char* xpath_filename, const char *ns_filename,
|
| const char* result_file) {
|
| xmlDocPtr doc;
|
| - xmlXPathObjectPtr xpath = NULL;
|
| + xmlXPathObjectPtr xpath = NULL;
|
| xmlChar *result = NULL;
|
| int ret;
|
| xmlChar **inclusive_namespaces = NULL;
|
| @@ -3695,24 +3720,24 @@ c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
|
| fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_filename);
|
| return(-1);
|
| }
|
| -
|
| +
|
| /*
|
| * Check the document is of the right kind
|
| - */
|
| + */
|
| if(xmlDocGetRootElement(doc) == NULL) {
|
| fprintf(stderr,"Error: empty document for file \"%s\"\n", xml_filename);
|
| xmlFreeDoc(doc);
|
| return(-1);
|
| }
|
|
|
| - /*
|
| - * load xpath file if specified
|
| + /*
|
| + * load xpath file if specified
|
| */
|
| if(xpath_filename) {
|
| xpath = load_xpath_expr(doc, xpath_filename);
|
| if(xpath == NULL) {
|
| fprintf(stderr,"Error: unable to evaluate xpath expression\n");
|
| - xmlFreeDoc(doc);
|
| + xmlFreeDoc(doc);
|
| return(-1);
|
| }
|
| }
|
| @@ -3721,7 +3746,7 @@ c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
|
| if (loadMem(ns_filename, &nslist, &nssize)) {
|
| fprintf(stderr,"Error: unable to evaluate xpath expression\n");
|
| if(xpath != NULL) xmlXPathFreeObject(xpath);
|
| - xmlFreeDoc(doc);
|
| + xmlFreeDoc(doc);
|
| return(-1);
|
| }
|
| inclusive_namespaces = parse_list((xmlChar *) nslist);
|
| @@ -3729,16 +3754,17 @@ c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
|
|
|
| /*
|
| * Canonical form
|
| - */
|
| + */
|
| /* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename); */
|
| - ret = xmlC14NDocDumpMemory(doc,
|
| - (xpath) ? xpath->nodesetval : NULL,
|
| - exclusive, inclusive_namespaces,
|
| + ret = xmlC14NDocDumpMemory(doc,
|
| + (xpath) ? xpath->nodesetval : NULL,
|
| + mode, inclusive_namespaces,
|
| with_comments, &result);
|
| if (ret >= 0) {
|
| if(result != NULL) {
|
| if (compareFileMem(result_file, (const char *) result, ret)) {
|
| fprintf(stderr, "Result mismatch for %s\n", xml_filename);
|
| + fprintf(stderr, "RESULT:\n%s\n", (const char*)result);
|
| ret = -1;
|
| }
|
| }
|
| @@ -3746,21 +3772,21 @@ 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);
|
| ret = -1;
|
| }
|
| -
|
| +
|
| /*
|
| * Cleanup
|
| - */
|
| + */
|
| if (result != NULL) xmlFree(result);
|
| if(xpath != NULL) xmlXPathFreeObject(xpath);
|
| if (inclusive_namespaces != NULL) xmlFree(inclusive_namespaces);
|
| if (nslist != NULL) free((char *) nslist);
|
| - xmlFreeDoc(doc);
|
| + xmlFreeDoc(doc);
|
|
|
| return(ret);
|
| }
|
|
|
| static int
|
| -c14nCommonTest(const char *filename, int with_comments, int exclusive,
|
| +c14nCommonTest(const char *filename, int with_comments, int mode,
|
| const char *subdir) {
|
| char buf[500];
|
| char prefix[500];
|
| @@ -3793,7 +3819,7 @@ c14nCommonTest(const char *filename, int with_comments, int exclusive,
|
| }
|
|
|
| nb_tests++;
|
| - if (c14nRunTest(filename, with_comments, exclusive,
|
| + if (c14nRunTest(filename, with_comments, mode,
|
| xpath, ns, result) < 0)
|
| ret = 1;
|
|
|
| @@ -3808,21 +3834,28 @@ c14nWithCommentTest(const char *filename,
|
| const char *resul ATTRIBUTE_UNUSED,
|
| const char *err ATTRIBUTE_UNUSED,
|
| int options ATTRIBUTE_UNUSED) {
|
| - return(c14nCommonTest(filename, 1, 0, "with-comments"));
|
| + return(c14nCommonTest(filename, 1, XML_C14N_1_0, "with-comments"));
|
| }
|
| static int
|
| c14nWithoutCommentTest(const char *filename,
|
| const char *resul ATTRIBUTE_UNUSED,
|
| const char *err ATTRIBUTE_UNUSED,
|
| int options ATTRIBUTE_UNUSED) {
|
| - return(c14nCommonTest(filename, 0, 0, "without-comments"));
|
| + return(c14nCommonTest(filename, 0, XML_C14N_1_0, "without-comments"));
|
| }
|
| static int
|
| c14nExcWithoutCommentTest(const char *filename,
|
| const char *resul ATTRIBUTE_UNUSED,
|
| const char *err ATTRIBUTE_UNUSED,
|
| int options ATTRIBUTE_UNUSED) {
|
| - return(c14nCommonTest(filename, 0, 1, "exc-without-comments"));
|
| + return(c14nCommonTest(filename, 0, XML_C14N_EXCLUSIVE_1_0, "exc-without-comments"));
|
| +}
|
| +static int
|
| +c14n11WithoutCommentTest(const char *filename,
|
| + const char *resul ATTRIBUTE_UNUSED,
|
| + const char *err ATTRIBUTE_UNUSED,
|
| + int options ATTRIBUTE_UNUSED) {
|
| + return(c14nCommonTest(filename, 0, XML_C14N_1_1, "1-1-without-comments"));
|
| }
|
| #endif
|
| #if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) && defined (LIBXML_SAX1_ENABLED)
|
| @@ -3903,7 +3936,7 @@ thread_specific_data(void *private_data)
|
| return ((void *) Okay);
|
| }
|
|
|
| -#if defined(linux) || defined(solaris)
|
| +#if defined(linux) || defined(__sun) || defined(__APPLE_CC__)
|
|
|
| #include <pthread.h>
|
|
|
| @@ -3917,7 +3950,7 @@ testThread(void)
|
| void *results[MAX_ARGC];
|
| int ret;
|
| int res = 0;
|
| -
|
| +
|
| xmlInitParser();
|
|
|
| for (repeat = 0; repeat < 500; repeat++) {
|
| @@ -3993,7 +4026,7 @@ testThread(void)
|
| DWORD useless;
|
|
|
| tid[i] = CreateThread(NULL, 0,
|
| - win32_thread_specific_data,
|
| + win32_thread_specific_data,
|
| (void *) testfiles[i], 0,
|
| &useless);
|
| if (tid[i] == NULL) {
|
| @@ -4091,7 +4124,7 @@ testThread(void)
|
| return (-1);
|
| }
|
| #endif
|
| -static int
|
| +static int
|
| threadsTest(const char *filename ATTRIBUTE_UNUSED,
|
| const char *resul ATTRIBUTE_UNUSED,
|
| const char *err ATTRIBUTE_UNUSED,
|
| @@ -4183,19 +4216,23 @@ testDesc testDescriptions[] = {
|
| errParseTest, "./test/XInclude/docs/*", "result/XInclude/", "", NULL,
|
| /* Ignore errors at this point ".err", */
|
| XML_PARSE_XINCLUDE },
|
| +#ifdef LIBXML_READER_ENABLED
|
| { "XInclude xmlReader regression tests",
|
| streamParseTest, "./test/XInclude/docs/*", "result/XInclude/", ".rdr",
|
| /* Ignore errors at this point ".err", */
|
| NULL, XML_PARSE_XINCLUDE },
|
| +#endif
|
| { "XInclude regression tests stripping include nodes" ,
|
| errParseTest, "./test/XInclude/docs/*", "result/XInclude/", "", NULL,
|
| /* Ignore errors at this point ".err", */
|
| XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE },
|
| +#ifdef LIBXML_READER_ENABLED
|
| { "XInclude xmlReader regression tests stripping include nodes",
|
| streamParseTest, "./test/XInclude/docs/*", "result/XInclude/", ".rdr",
|
| /* Ignore errors at this point ".err", */
|
| NULL, XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE },
|
| #endif
|
| +#endif
|
| #ifdef LIBXML_XPATH_ENABLED
|
| #ifdef LIBXML_DEBUG_ENABLED
|
| { "XPath expressions regression tests" ,
|
| @@ -4253,6 +4290,9 @@ testDesc testDescriptions[] = {
|
| { "C14N exclusive without comments regression tests" ,
|
| c14nExcWithoutCommentTest, "./test/c14n/exc-without-comments/*.xml", NULL, NULL, NULL,
|
| 0 },
|
| + { "C14N 1.1 without comments regression tests" ,
|
| + c14n11WithoutCommentTest, "./test/c14n/1-1-without-comments/*.xml", NULL, NULL, NULL,
|
| + 0 },
|
| #endif
|
| #if defined(LIBXML_THREAD_ENABLED) && defined(LIBXML_CATALOG_ENABLED) && defined(LIBXML_SAX1_ENABLED)
|
| { "Catalog and Threads regression tests" ,
|
| @@ -4388,7 +4428,6 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
|
|
|
| initializeLibxml2();
|
|
|
| -
|
| for (a = 1; a < argc;a++) {
|
| if (!strcmp(argv[a], "-v"))
|
| verbose = 1;
|
|
|