1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-30 22:43:14 +03:00

fixing compilation bug with some options disabled as well as

* debugXML.c testHTML.c tree.c doc/examples/*.c
  include/libxml/xmlsave.h: fixing compilation bug with some options
  disabled as well as --with-minimum should fix #134695
Daniel
This commit is contained in:
Daniel Veillard
2004-03-04 15:59:36 +00:00
parent cccd4a0524
commit 2156d4387b
13 changed files with 178 additions and 76 deletions

View File

@ -1,3 +1,9 @@
Thu Mar 4 16:57:50 CET 2004 Daniel Veillard <daniel@veillard.com>
* debugXML.c testHTML.c tree.c doc/examples/*.c
include/libxml/xmlsave.h: fixing compilation bug with some options
disabled as well as --with-minimum should fix #134695
Thu Mar 4 15:00:45 CET 2004 Daniel Veillard <daniel@veillard.com> Thu Mar 4 15:00:45 CET 2004 Daniel Veillard <daniel@veillard.com>
* xmlcatalog.c: allow fallback to URI lookup when SYSTEM fails, * xmlcatalog.c: allow fallback to URI lookup when SYSTEM fails,

View File

@ -1538,6 +1538,7 @@ xmlShellBase(xmlShellCtxtPtr ctxt,
return (0); return (0);
} }
#ifdef XML_TREE_ENABLED
/** /**
* xmlShellSetBase: * xmlShellSetBase:
* @ctxt: the shell context * @ctxt: the shell context
@ -1558,6 +1559,7 @@ xmlShellSetBase(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
xmlNodeSetBase(node, (xmlChar*) arg); xmlNodeSetBase(node, (xmlChar*) arg);
return (0); return (0);
} }
#endif
/** /**
* xmlShellGrep: * xmlShellGrep:
@ -2306,8 +2308,10 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlXPathFreeObject(list); xmlXPathFreeObject(list);
} }
#endif /* LIBXML_XPATH_ENABLED */ #endif /* LIBXML_XPATH_ENABLED */
#ifdef LIBXML_TREE_ENABLED
} else if (!strcmp(command, "setbase")) { } else if (!strcmp(command, "setbase")) {
xmlShellSetBase(ctxt, arg, ctxt->node, NULL); xmlShellSetBase(ctxt, arg, ctxt->node, NULL);
#endif
} else if ((!strcmp(command, "ls")) || (!strcmp(command, "dir"))) { } else if ((!strcmp(command, "ls")) || (!strcmp(command, "dir"))) {
int dir = (!strcmp(command, "dir")); int dir = (!strcmp(command, "dir"));

View File

@ -18,6 +18,7 @@
#include <libxml/xinclude.h> #include <libxml/xinclude.h>
#include <libxml/xmlIO.h> #include <libxml/xmlIO.h>
#ifdef LIBXML_XINCLUDE_ENABLED
static const char *result = "<list><people>a</people><people>b</people></list>"; static const char *result = "<list><people>a</people><people>b</people></list>";
static const char *cur = NULL; static const char *cur = NULL;
static int rlen; static int rlen;
@ -125,6 +126,7 @@ int main(void) {
fprintf(stderr, "failed to parse the including file\n"); fprintf(stderr, "failed to parse the including file\n");
exit(1); exit(1);
} }
/* /*
* apply the XInclude process, this should trigger the I/O just * apply the XInclude process, this should trigger the I/O just
* registered. * registered.
@ -133,10 +135,14 @@ int main(void) {
fprintf(stderr, "XInclude processing failed\n"); fprintf(stderr, "XInclude processing failed\n");
exit(1); exit(1);
} }
#ifdef LIBXML_OUTPUT_ENABLED
/* /*
* save the output for checking to stdout * save the output for checking to stdout
*/ */
xmlDocDump(stdout, doc); xmlDocDump(stdout, doc);
#endif
/* /*
* Free the document * Free the document
*/ */
@ -152,3 +158,9 @@ int main(void) {
xmlMemoryDump(); xmlMemoryDump();
return(0); return(0);
} }
#else
int main(void) {
fprintf(stderr, "XInclude support not compiled in\n");
exit(1);
}
#endif

View File

@ -14,6 +14,8 @@
#include <stdio.h> #include <stdio.h>
#include <libxml/xmlreader.h> #include <libxml/xmlreader.h>
#ifdef LIBXML_READER_ENABLED
/** /**
* processNode: * processNode:
* @reader: the xmlReader * @reader: the xmlReader
@ -96,3 +98,10 @@ int main(int argc, char **argv) {
xmlMemoryDump(); xmlMemoryDump();
return(0); return(0);
} }
#else
int main(void) {
fprintf(stderr, "XInclude support not compiled in\n");
exit(1);
}
#endif

View File

@ -15,6 +15,8 @@
#include <stdio.h> #include <stdio.h>
#include <libxml/xmlreader.h> #include <libxml/xmlreader.h>
#ifdef LIBXML_READER_ENABLED
/** /**
* processNode: * processNode:
* @reader: the xmlReader * @reader: the xmlReader
@ -111,3 +113,10 @@ int main(int argc, char **argv) {
xmlMemoryDump(); xmlMemoryDump();
return(0); return(0);
} }
#else
int main(void) {
fprintf(stderr, "XInclude support not compiled in\n");
exit(1);
}
#endif

View File

@ -15,6 +15,8 @@
#include <stdio.h> #include <stdio.h>
#include <libxml/xmlreader.h> #include <libxml/xmlreader.h>
#ifdef LIBXML_READER_ENABLED
/** /**
* streamFile: * streamFile:
* @filename: the file name to parse * @filename: the file name to parse
@ -108,3 +110,10 @@ int main(int argc, char **argv) {
xmlMemoryDump(); xmlMemoryDump();
return(0); return(0);
} }
#else
int main(void) {
fprintf(stderr, "XInclude support not compiled in\n");
exit(1);
}
#endif

View File

@ -16,6 +16,8 @@
#include <libxml/encoding.h> #include <libxml/encoding.h>
#include <libxml/xmlwriter.h> #include <libxml/xmlwriter.h>
#if defined(LIBXML_WRITER_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
#define MY_ENCODING "ISO-8859-1" #define MY_ENCODING "ISO-8859-1"
void testXmlwriterFilename(const char *uri); void testXmlwriterFilename(const char *uri);
@ -1187,3 +1189,10 @@ ConvertInput(const char *in, const char *encoding)
return out; return out;
} }
#else
int main(void) {
fprintf(stderr, "Writer or output support not compiled in\n");
exit(1);
}
#endif

View File

@ -13,6 +13,8 @@
#include <libxml/parser.h> #include <libxml/parser.h>
#include <libxml/tree.h> #include <libxml/tree.h>
#ifdef LIBXML_TREE_ENABLED
/* /*
*To compile this file using gcc you can type *To compile this file using gcc you can type
*gcc `xml2-config --cflags --libs` -o xmlexample libxml2-example.c *gcc `xml2-config --cflags --libs` -o xmlexample libxml2-example.c
@ -84,3 +86,9 @@ main(int argc, char **argv)
return 0; return 0;
} }
#else
int main(void) {
fprintf(stderr, "Tree support not compiled in\n");
exit(1);
}
#endif

View File

@ -12,6 +12,8 @@
#include <libxml/parser.h> #include <libxml/parser.h>
#include <libxml/tree.h> #include <libxml/tree.h>
#ifdef LIBXML_TREE_ENABLED
/* /*
*To compile this file using gcc you can type *To compile this file using gcc you can type
*gcc `xml2-config --cflags --libs` -o tree2 tree2.c *gcc `xml2-config --cflags --libs` -o tree2 tree2.c
@ -108,3 +110,9 @@ main(int argc, char **argv)
xmlMemoryDump(); xmlMemoryDump();
return(0); return(0);
} }
#else
int main(void) {
fprintf(stderr, "tree support not compiled in\n");
exit(1);
}
#endif

View File

@ -17,6 +17,9 @@
#include <libxml/xpath.h> #include <libxml/xpath.h>
#include <libxml/xpathInternals.h> #include <libxml/xpathInternals.h>
#ifdef LIBXML_XPATH_ENABLED
void usage(const char *name); void usage(const char *name);
int execute_xpath_expression(const char* filename, const xmlChar* xpathExpr, const xmlChar* nsList); int execute_xpath_expression(const char* filename, const xmlChar* xpathExpr, const xmlChar* nsList);
int register_namespaces(xmlXPathContextPtr xpathCtx, const xmlChar* nsList); int register_namespaces(xmlXPathContextPtr xpathCtx, const xmlChar* nsList);
@ -238,3 +241,9 @@ print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output) {
} }
} }
#else
int main(void) {
fprintf(stderr, "XPath support not compiled in\n");
exit(1);
}
#endif

View File

@ -14,6 +14,7 @@
#include <libxml/tree.h> #include <libxml/tree.h>
#include <libxml/xmlIO.h> #include <libxml/xmlIO.h>
#ifdef LIBXML_OUTPUT_ENABLED
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -54,6 +55,7 @@ XMLPUBFUN int XMLCALL
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* LIBXML_OUTPUT_ENABLED */
#endif /* __XML_XMLSAVE_H__ */ #endif /* __XML_XMLSAVE_H__ */

View File

@ -704,7 +704,7 @@ parseSAXFile(char *filename) {
static void static void
parseAndPrintFile(char *filename) { parseAndPrintFile(char *filename) {
htmlDocPtr doc = NULL, tmp; htmlDocPtr doc = NULL;
/* /*
* build an HTML tree from a string; * build an HTML tree from a string;
@ -745,14 +745,18 @@ parseAndPrintFile(char *filename) {
"Could not parse %s\n", filename); "Could not parse %s\n", filename);
} }
#ifdef LIBXML_TREE_ENABLED
/* /*
* test intermediate copy if needed. * test intermediate copy if needed.
*/ */
if (copy) { if (copy) {
htmlDocPtr tmp;
tmp = doc; tmp = doc;
doc = xmlCopyDoc(doc, 1); doc = xmlCopyDoc(doc, 1);
xmlFreeDoc(tmp); xmlFreeDoc(tmp);
} }
#endif
#ifdef LIBXML_OUTPUT_ENABLED #ifdef LIBXML_OUTPUT_ENABLED
/* /*

163
tree.c
View File

@ -321,7 +321,6 @@ xmlSplitQName3(const xmlChar *name, int *len) {
return(&name[l+1]); return(&name[l+1]);
} }
#ifdef LIBXML_TREE_ENABLED
/************************************************************************ /************************************************************************
* * * *
* Check Name, NCName and QName strings * * Check Name, NCName and QName strings *
@ -330,6 +329,7 @@ xmlSplitQName3(const xmlChar *name, int *len) {
#define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l) #define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l)
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
/** /**
* xmlValidateNCName: * xmlValidateNCName:
* @value: the value to check * @value: the value to check
@ -398,7 +398,9 @@ try_complex:
return(0); return(0);
} }
#endif
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
/** /**
* xmlValidateQName: * xmlValidateQName:
* @value: the value to check * @value: the value to check
@ -1669,7 +1671,7 @@ xmlNodeListGetRawString(xmlDocPtr doc, xmlNodePtr list, int inLine)
} }
#endif /* LIBXML_TREE_ENABLED */ #endif /* LIBXML_TREE_ENABLED */
#ifdef LIBXML_TREE_ENABLED #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED)
/** /**
* xmlNewProp: * xmlNewProp:
* @node: the holding node * @node: the holding node
@ -2716,7 +2718,7 @@ xmlSetListDoc(xmlNodePtr list, xmlDocPtr doc) {
} }
} }
#ifdef LIBXML_TREE_ENABLED #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
/** /**
* xmlNewChild: * xmlNewChild:
* @parent: the parent node * @parent: the parent node
@ -2874,7 +2876,7 @@ xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
return(elem); return(elem);
} }
#ifdef LIBXML_TREE_ENABLED #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED)
/** /**
* xmlAddPrevSibling: * xmlAddPrevSibling:
* @cur: the child node * @cur: the child node
@ -3427,7 +3429,7 @@ xmlUnlinkNode(xmlNodePtr cur) {
cur->next = cur->prev = NULL; cur->next = cur->prev = NULL;
} }
#ifdef LIBXML_TREE_ENABLED #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
/** /**
* xmlReplaceNode: * xmlReplaceNode:
* @old: the old node * @old: the old node
@ -3933,7 +3935,7 @@ xmlNodePtr xmlCopyNodeList(const xmlNodePtr node) {
return(ret); return(ret);
} }
#ifdef LIBXML_TREE_ENABLED #if defined(LIBXML_TREE_ENABLED)
/** /**
* xmlCopyDtd: * xmlCopyDtd:
* @dtd: the dtd * @dtd: the dtd
@ -4018,7 +4020,9 @@ xmlCopyDtd(xmlDtdPtr dtd) {
return(ret); return(ret);
} }
#endif
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
/** /**
* xmlCopyDoc: * xmlCopyDoc:
* @doc: the document * @doc: the document
@ -4047,11 +4051,13 @@ xmlCopyDoc(xmlDocPtr doc, int recursive) {
ret->last = NULL; ret->last = NULL;
ret->children = NULL; ret->children = NULL;
#ifdef LIBXML_TREE_ENABLED
if (doc->intSubset != NULL) { if (doc->intSubset != NULL) {
ret->intSubset = xmlCopyDtd(doc->intSubset); ret->intSubset = xmlCopyDtd(doc->intSubset);
xmlSetTreeDoc((xmlNodePtr)ret->intSubset, ret); xmlSetTreeDoc((xmlNodePtr)ret->intSubset, ret);
ret->intSubset->parent = ret; ret->intSubset->parent = ret;
} }
#endif
if (doc->oldNs != NULL) if (doc->oldNs != NULL)
ret->oldNs = xmlCopyNamespaceList(doc->oldNs); ret->oldNs = xmlCopyNamespaceList(doc->oldNs);
if (doc->children != NULL) { if (doc->children != NULL) {
@ -4107,7 +4113,7 @@ xmlGetLineNo(xmlNodePtr node)
return result; return result;
} }
#ifdef LIBXML_TREE_ENABLED #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
/** /**
* xmlGetNodePath: * xmlGetNodePath:
* @node: a node * @node: a node
@ -4348,7 +4354,7 @@ xmlDocGetRootElement(xmlDocPtr doc) {
return(ret); return(ret);
} }
#ifdef LIBXML_TREE_ENABLED #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
/** /**
* xmlDocSetRootElement: * xmlDocSetRootElement:
* @doc: the document * @doc: the document
@ -4387,7 +4393,9 @@ xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root) {
} }
return(old); return(old);
} }
#endif
#if defined(LIBXML_TREE_ENABLED)
/** /**
* xmlNodeSetLang: * xmlNodeSetLang:
* @cur: the node being changed * @cur: the node being changed
@ -4588,7 +4596,9 @@ xmlNodeSetName(xmlNodePtr cur, const xmlChar *name) {
if (cur->name != NULL) xmlFree((xmlChar *) cur->name); if (cur->name != NULL) xmlFree((xmlChar *) cur->name);
cur->name = xmlStrdup(name); cur->name = xmlStrdup(name);
} }
#endif
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
/** /**
* xmlNodeSetBase: * xmlNodeSetBase:
* @cur: the node being changed * @cur: the node being changed
@ -5245,7 +5255,7 @@ xmlTextMerge(xmlNodePtr first, xmlNodePtr second) {
return(first); return(first);
} }
#ifdef LIBXML_TREE_ENABLED #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED)
/** /**
* xmlGetNsList: * xmlGetNsList:
* @doc: the document * @doc: the document
@ -6121,7 +6131,75 @@ xmlGetNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace) {
return(NULL); return(NULL);
} }
#ifdef LIBXML_TREE_ENABLED #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
/**
* xmlUnsetProp:
* @node: the node
* @name: the attribute name
*
* Remove an attribute carried by a node.
* Returns 0 if successful, -1 if not found
*/
int
xmlUnsetProp(xmlNodePtr node, const xmlChar *name) {
xmlAttrPtr prop, prev = NULL;;
if ((node == NULL) || (name == NULL))
return(-1);
prop = node->properties;
while (prop != NULL) {
if ((xmlStrEqual(prop->name, name)) &&
(prop->ns == NULL)) {
if (prev == NULL)
node->properties = prop->next;
else
prev->next = prop->next;
xmlFreeProp(prop);
return(0);
}
prev = prop;
prop = prop->next;
}
return(-1);
}
/**
* xmlUnsetNsProp:
* @node: the node
* @ns: the namespace definition
* @name: the attribute name
*
* Remove an attribute carried by a node.
* Returns 0 if successful, -1 if not found
*/
int
xmlUnsetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name) {
xmlAttrPtr prop = node->properties, prev = NULL;;
if ((node == NULL) || (name == NULL))
return(-1);
if (ns == NULL)
return(xmlUnsetProp(node, name));
if (ns->href == NULL)
return(-1);
while (prop != NULL) {
if ((xmlStrEqual(prop->name, name)) &&
(prop->ns != NULL) && (xmlStrEqual(prop->ns->href, ns->href))) {
if (prev == NULL)
node->properties = prop->next;
else
prev->next = prop->next;
xmlFreeProp(prop);
return(0);
}
prev = prop;
prop = prop->next;
}
return(-1);
}
#endif
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED)
/** /**
* xmlSetProp: * xmlSetProp:
* @node: the node * @node: the node
@ -6175,37 +6253,6 @@ xmlSetProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
return(prop); return(prop);
} }
/**
* xmlUnsetProp:
* @node: the node
* @name: the attribute name
*
* Remove an attribute carried by a node.
* Returns 0 if successful, -1 if not found
*/
int
xmlUnsetProp(xmlNodePtr node, const xmlChar *name) {
xmlAttrPtr prop, prev = NULL;;
if ((node == NULL) || (name == NULL))
return(-1);
prop = node->properties;
while (prop != NULL) {
if ((xmlStrEqual(prop->name, name)) &&
(prop->ns == NULL)) {
if (prev == NULL)
node->properties = prop->next;
else
prev->next = prop->next;
xmlFreeProp(prop);
return(0);
}
prev = prop;
prop = prop->next;
}
return(-1);
}
/** /**
* xmlSetNsProp: * xmlSetNsProp:
* @node: the node * @node: the node
@ -6269,40 +6316,6 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
return(prop); return(prop);
} }
/**
* xmlUnsetNsProp:
* @node: the node
* @ns: the namespace definition
* @name: the attribute name
*
* Remove an attribute carried by a node.
* Returns 0 if successful, -1 if not found
*/
int
xmlUnsetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name) {
xmlAttrPtr prop = node->properties, prev = NULL;;
if ((node == NULL) || (name == NULL))
return(-1);
if (ns == NULL)
return(xmlUnsetProp(node, name));
if (ns->href == NULL)
return(-1);
while (prop != NULL) {
if ((xmlStrEqual(prop->name, name)) &&
(prop->ns != NULL) && (xmlStrEqual(prop->ns->href, ns->href))) {
if (prev == NULL)
node->properties = prop->next;
else
prev->next = prop->next;
xmlFreeProp(prop);
return(0);
}
prev = prop;
prop = prop->next;
}
return(-1);
}
#endif /* LIBXML_TREE_ENABLED */ #endif /* LIBXML_TREE_ENABLED */
/** /**