From b71379b796214f382b025ccf63cefe0419cd4e9d Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Mon, 9 Oct 2000 12:30:39 +0000 Subject: [PATCH] - moved xml-error.h to xmlerror.h: seems this allowed to bypass the automake bug where wrong dependancies were generated. - xpath.[ch]: worked on XPointer Daniel --- ChangeLog | 6 + HTMLparser.c | 4 +- HTMLtree.c | 2 +- Makefile.am | 40 +++--- SAX.c | 2 +- debugXML.c | 2 +- xml-error.h => include/libxml/xmlerror.h | 0 include/libxml/xpath.h | 13 +- nanoftp.c | 2 +- nanohttp.c | 2 +- parser.c | 22 ++-- parserInternals.c | 2 +- testHTML.c | 2 +- testSAX.c | 2 +- testXPath.c | 2 +- xmlerror.h | 156 +++++++++++++++++++++++ xpath.c | 70 +--------- xpath.h | 13 +- 18 files changed, 234 insertions(+), 108 deletions(-) rename xml-error.h => include/libxml/xmlerror.h (100%) create mode 100644 xmlerror.h diff --git a/ChangeLog b/ChangeLog index f9ea27d4..b0b1fbeb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Oct 9 14:28:56 CEST 2000 Daniel Veillard + + * moved xml-error.h to xmlerror.h: seems this allowed to bypass + the automake bug where wrong dependancies were generated. + * xpath.[ch]: worked on XPointer + Fri Oct 6 12:58:04 CEST 2000 Daniel Veillard * configure.in Makefile.am: 2.2.5, ship the include in an diff --git a/HTMLparser.c b/HTMLparser.c index c9814d56..9de8bdc3 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -12,7 +12,7 @@ #include "config.h" #endif -#include "xmlversion.h" +#include #ifdef LIBXML_HTML_ENABLED #include @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/HTMLtree.c b/HTMLtree.c index d09b67df..9ce68971 100644 --- a/HTMLtree.c +++ b/HTMLtree.c @@ -13,7 +13,7 @@ #include "config.h" #endif -#include "xmlversion.h" +#include #ifdef LIBXML_HTML_ENABLED #include diff --git a/Makefile.am b/Makefile.am index 13a0fd8f..5c98db04 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,28 +35,28 @@ libxml_la_SOURCES = \ nanohttp.c \ nanoftp.c -xmlincdir = $(srcdir)/include/libxml +xmlincdir = $(includedir)/libxml xmlinc_HEADERS = \ - $(xmlincdir)/SAX.h \ - $(xmlincdir)/entities.h \ - $(xmlincdir)/encoding.h \ - $(xmlincdir)/parser.h \ - $(xmlincdir)/parserInternals.h \ - $(xmlincdir)/xml-error.h \ - $(xmlincdir)/HTMLparser.h \ - $(xmlincdir)/HTMLtree.h \ - $(xmlincdir)/debugXML.h \ - $(xmlincdir)/tree.h \ - $(xmlincdir)/xpath.h \ - $(xmlincdir)/xmlIO.h \ - $(xmlincdir)/xmlmemory.h \ - $(xmlincdir)/nanohttp.h \ - $(xmlincdir)/nanoftp.h \ - $(xmlincdir)/uri.h \ - $(xmlincdir)/valid.h \ - $(xmlincdir)/xlink.h \ - $(xmlincdir)/xmlversion.h + include/libxml/SAX.h \ + include/libxml/entities.h \ + include/libxml/encoding.h \ + include/libxml/parser.h \ + include/libxml/parserInternals.h \ + include/libxml/xmlerror.h \ + include/libxml/HTMLparser.h \ + include/libxml/HTMLtree.h \ + include/libxml/debugXML.h \ + include/libxml/tree.h \ + include/libxml/xpath.h \ + include/libxml/xmlIO.h \ + include/libxml/xmlmemory.h \ + include/libxml/nanohttp.h \ + include/libxml/nanoftp.h \ + include/libxml/uri.h \ + include/libxml/valid.h \ + include/libxml/xlink.h \ + include/libxml/xmlversion.h DEPS = $(top_builddir)/libxml.la LDADDS = $(top_builddir)/libxml.la @Z_LIBS@ @M_LIBS@ diff --git a/SAX.c b/SAX.c index 99283e59..c53a10f8 100644 --- a/SAX.c +++ b/SAX.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/debugXML.c b/debugXML.c index 3b34c3e2..1f172683 100644 --- a/debugXML.c +++ b/debugXML.c @@ -13,7 +13,7 @@ #include "config.h" #endif -#include "xmlversion.h" +#include #ifdef LIBXML_DEBUG_ENABLED #include diff --git a/xml-error.h b/include/libxml/xmlerror.h similarity index 100% rename from xml-error.h rename to include/libxml/xmlerror.h diff --git a/include/libxml/xpath.h b/include/libxml/xpath.h index 7031c578..98455783 100644 --- a/include/libxml/xpath.h +++ b/include/libxml/xpath.h @@ -42,7 +42,11 @@ typedef enum { XPATH_INVALID_TYPE, XPATH_INVALID_ARITY, XPATH_INVALID_CTXT_SIZE, - XPATH_INVALID_CTXT_POSITION + XPATH_INVALID_CTXT_POSITION, + XPATH_MEMORY_ERROR, + XPTR_SYNTAX_ERROR, + XPTR_RESOURCE_ERROR, + XPTR_SUB_RESOURCE_ERROR } xmlXPathError; /* @@ -263,8 +267,13 @@ void xmlXPatherror (xmlXPathParserContextPtr ctxt, int no); /** - * Utilities for implementing more functions + * Utilities to extend XPath (XPointer) */ +xmlXPathParserContextPtr + xmlXPathNewParserContext (const xmlChar *str, + xmlXPathContextPtr ctxt); +void xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt); + xmlXPathObjectPtr valuePop (xmlXPathParserContextPtr ctxt); int valuePush (xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr value); diff --git a/nanoftp.c b/nanoftp.c index 769628c0..b70dfebb 100644 --- a/nanoftp.c +++ b/nanoftp.c @@ -21,7 +21,7 @@ #endif #endif /* STANDALONE */ -#include "xmlversion.h" +#include #ifdef LIBXML_FTP_ENABLED #include diff --git a/nanohttp.c b/nanohttp.c index f5fa0442..88db9fc3 100644 --- a/nanohttp.c +++ b/nanohttp.c @@ -21,7 +21,7 @@ #include "config.h" #endif -#include "xmlversion.h" +#include #ifdef LIBXML_HTTP_ENABLED #include diff --git a/parser.c b/parser.c index ab7ae810..5ed22d3e 100644 --- a/parser.c +++ b/parser.c @@ -39,7 +39,19 @@ #endif #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #ifdef HAVE_CTYPE_H #include #endif @@ -59,16 +71,6 @@ #include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #define XML_PARSER_BIG_BUFFER_SIZE 1000 #define XML_PARSER_BUFFER_SIZE 100 diff --git a/parserInternals.c b/parserInternals.c index 727dfeb7..595567bb 100644 --- a/parserInternals.c +++ b/parserInternals.c @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/testHTML.c b/testHTML.c index 0bd7fee8..1aff9670 100644 --- a/testHTML.c +++ b/testHTML.c @@ -12,7 +12,7 @@ #include "config.h" #endif -#include "xmlversion.h" +#include #ifdef LIBXML_HTML_ENABLED #include diff --git a/testSAX.c b/testSAX.c index 5d5a1896..b4f5512f 100644 --- a/testSAX.c +++ b/testSAX.c @@ -36,7 +36,7 @@ #endif -#include +#include #include #include /* only for xmlNewInputFromFile() */ #include diff --git a/testXPath.c b/testXPath.c index dc0a3471..65fc5451 100644 --- a/testXPath.c +++ b/testXPath.c @@ -12,7 +12,7 @@ #include "config.h" #endif -#include "xmlversion.h" +#include #if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_DEBUG_ENABLED) #include diff --git a/xmlerror.h b/xmlerror.h new file mode 100644 index 00000000..25d9db09 --- /dev/null +++ b/xmlerror.h @@ -0,0 +1,156 @@ +#ifndef __XML_ERROR_H__ +#define __XML_ERROR_H__ + +#include +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + XML_ERR_OK = 0, + XML_ERR_INTERNAL_ERROR, + XML_ERR_NO_MEMORY, + + XML_ERR_DOCUMENT_START, /* 3 */ + XML_ERR_DOCUMENT_EMPTY, + XML_ERR_DOCUMENT_END, + + XML_ERR_INVALID_HEX_CHARREF, /* 6 */ + XML_ERR_INVALID_DEC_CHARREF, + XML_ERR_INVALID_CHARREF, + XML_ERR_INVALID_CHAR, + + XML_ERR_CHARREF_AT_EOF, /* 10 */ + XML_ERR_CHARREF_IN_PROLOG, + XML_ERR_CHARREF_IN_EPILOG, + XML_ERR_CHARREF_IN_DTD, + XML_ERR_ENTITYREF_AT_EOF, + XML_ERR_ENTITYREF_IN_PROLOG, + XML_ERR_ENTITYREF_IN_EPILOG, + XML_ERR_ENTITYREF_IN_DTD, + XML_ERR_PEREF_AT_EOF, + XML_ERR_PEREF_IN_PROLOG, + XML_ERR_PEREF_IN_EPILOG, + XML_ERR_PEREF_IN_INT_SUBSET, + + XML_ERR_ENTITYREF_NO_NAME, /* 22 */ + XML_ERR_ENTITYREF_SEMICOL_MISSING, + + XML_ERR_PEREF_NO_NAME, /* 24 */ + XML_ERR_PEREF_SEMICOL_MISSING, + + XML_ERR_UNDECLARED_ENTITY, /* 26 */ + XML_WAR_UNDECLARED_ENTITY, + XML_ERR_UNPARSED_ENTITY, + XML_ERR_ENTITY_IS_EXTERNAL, + XML_ERR_ENTITY_IS_PARAMETER, + + XML_ERR_UNKNOWN_ENCODING, /* 31 */ + XML_ERR_UNSUPPORTED_ENCODING, + + XML_ERR_STRING_NOT_STARTED, /* 33 */ + XML_ERR_STRING_NOT_CLOSED, + XML_ERR_NS_DECL_ERROR, + + XML_ERR_ENTITY_NOT_STARTED, /* 36 */ + XML_ERR_ENTITY_NOT_FINISHED, + + XML_ERR_LT_IN_ATTRIBUTE, /* 38 */ + XML_ERR_ATTRIBUTE_NOT_STARTED, + XML_ERR_ATTRIBUTE_NOT_FINISHED, + XML_ERR_ATTRIBUTE_WITHOUT_VALUE, + XML_ERR_ATTRIBUTE_REDEFINED, + + XML_ERR_LITERAL_NOT_STARTED, /* 43 */ + XML_ERR_LITERAL_NOT_FINISHED, + + XML_ERR_COMMENT_NOT_FINISHED, /* 45 */ + + XML_ERR_PI_NOT_STARTED, /* 47 */ + XML_ERR_PI_NOT_FINISHED, + + XML_ERR_NOTATION_NOT_STARTED, /* 49 */ + XML_ERR_NOTATION_NOT_FINISHED, + + XML_ERR_ATTLIST_NOT_STARTED, /* 51 */ + XML_ERR_ATTLIST_NOT_FINISHED, + + XML_ERR_MIXED_NOT_STARTED, /* 53 */ + XML_ERR_MIXED_NOT_FINISHED, + + XML_ERR_ELEMCONTENT_NOT_STARTED, /* 55 */ + XML_ERR_ELEMCONTENT_NOT_FINISHED, + + XML_ERR_XMLDECL_NOT_STARTED, /* 57 */ + XML_ERR_XMLDECL_NOT_FINISHED, + + XML_ERR_CONDSEC_NOT_STARTED, /* 59 */ + XML_ERR_CONDSEC_NOT_FINISHED, + + XML_ERR_EXT_SUBSET_NOT_FINISHED, /* 61 */ + + XML_ERR_DOCTYPE_NOT_FINISHED, /* 62 */ + + XML_ERR_MISPLACED_CDATA_END, /* 63 */ + XML_ERR_CDATA_NOT_FINISHED, + + XML_ERR_RESERVED_XML_NAME, /* 65 */ + + XML_ERR_SPACE_REQUIRED, /* 66 */ + XML_ERR_SEPARATOR_REQUIRED, + XML_ERR_NMTOKEN_REQUIRED, + XML_ERR_NAME_REQUIRED, + XML_ERR_PCDATA_REQUIRED, + XML_ERR_URI_REQUIRED, + XML_ERR_PUBID_REQUIRED, + XML_ERR_LT_REQUIRED, + XML_ERR_GT_REQUIRED, + XML_ERR_LTSLASH_REQUIRED, + XML_ERR_EQUAL_REQUIRED, + + XML_ERR_TAG_NAME_MISMATCH, /* 77 */ + XML_ERR_TAG_NOT_FINISED, + + XML_ERR_STANDALONE_VALUE, /* 79 */ + + XML_ERR_ENCODING_NAME, /* 80 */ + + XML_ERR_HYPHEN_IN_COMMENT, /* 81 */ + + XML_ERR_INVALID_ENCODING, /* 82 */ + + XML_ERR_EXT_ENTITY_STANDALONE, /* 83 */ + + XML_ERR_CONDSEC_INVALID, /* 84 */ + + XML_ERR_VALUE_REQUIRED, /* 85 */ + + XML_ERR_NOT_WELL_BALANCED, /* 86 */ + XML_ERR_EXTRA_CONTENT, /* 87 */ + XML_ERR_ENTITY_CHAR_ERROR, /* 88 */ + XML_ERR_ENTITY_PE_INTERNAL, /* 88 */ + XML_ERR_ENTITY_LOOP, /* 89 */ + XML_ERR_ENTITY_BOUNDARY, /* 90 */ + XML_ERR_INVALID_URI, /* 91 */ + XML_ERR_URI_FRAGMENT /* 92 */ +}xmlParserErrors; + +void xmlParserError (void *ctx, + const char *msg, + ...); +void xmlParserWarning (void *ctx, + const char *msg, + ...); +void xmlParserValidityError (void *ctx, + const char *msg, + ...); +void xmlParserValidityWarning(void *ctx, + const char *msg, + ...); +void xmlParserPrintFileInfo (xmlParserInputPtr input); +void xmlParserPrintFileContext(xmlParserInputPtr input); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_ERROR_H__ */ diff --git a/xpath.c b/xpath.c index a67a2f6d..840ae4df 100644 --- a/xpath.c +++ b/xpath.c @@ -19,7 +19,7 @@ #include "config.h" #endif -#include "xmlversion.h" +#include #ifdef LIBXML_XPATH_ENABLED #include @@ -269,6 +269,10 @@ const char *xmlXPathErrorMessages[] = { "Invalid number of arguments", "Invalid context size", "Invalid context position", + "Memory allocation error", + "Syntax error", + "Resource error", + "Sub resource error" }; /** @@ -777,9 +781,11 @@ xmlXPathFreeObject(xmlXPathObjectPtr obj) { if (obj->type == XPATH_NODESET) { if (obj->nodesetval != NULL) xmlXPathFreeNodeSet(obj->nodesetval); +#ifdef LIBXML_XPTR_ENABLED } else if (obj->type == XPATH_LOCATIONSET) { if (obj->user != NULL) xmlXPathFreeLocationSet(obj->user); +#endif } else if (obj->type == XPATH_STRING) { if (obj->stringval != NULL) xmlFree(obj->stringval); @@ -4872,68 +4878,6 @@ xmlXPathEval(const xmlChar *str, xmlXPathContextPtr ctx) { return(res); } -/** - * xmlXPathEvalXPtrExpr: - * @str: the XPointer XPtrExpr expression - * @ctx: the XPointer context - * - * Evaluate the location set corresponding to this expression. - * - * Returns the xmlXPathObjectPtr resulting from the eveluation or NULL. - * the caller has to free the object. - */ -xmlXPathObjectPtr -xmlXPathEvalXPtrExpr(const xmlChar *str, xmlXPathContextPtr ctx) { - xmlXPathParserContextPtr ctxt; - xmlXPathObjectPtr res = NULL, tmp; - xmlXPathObjectPtr init = NULL; - int stack = 0; - - xmlXPathInit(); - - CHECK_CONTEXT(ctx) - - if (xmlXPathDebug == NULL) - xmlXPathDebug = stderr; - ctxt = xmlXPathNewParserContext(str, ctx); - if (ctx->node != NULL) { - init = xmlXPathNewNodeSet(ctx->node); - valuePush(ctxt, init); - } - if (str[0] == '/') - xmlXPathRoot(ctxt); - xmlXPathEvalExpr(ctxt); - - if ((ctxt->value == NULL) || - ((ctxt->value->type != XPATH_NODESET) && - (ctxt->value->type != XPATH_LOCATIONSET))) { - fprintf(xmlXPathDebug, - "xmlXPathEvalXPtrExpr: evaluation failed to return a node set\n"); - } else { - res = valuePop(ctxt); - } - - do { - tmp = valuePop(ctxt); - if (tmp != NULL) { - xmlXPathFreeObject(tmp); - if (tmp != init) - stack++; - } - } while (tmp != NULL); - if (stack != 0) { - fprintf(xmlXPathDebug, "xmlXPathEvalXPtrExpr: %d object left on the stack\n", - stack); - } - if (ctxt->error != XPATH_EXPRESSION_OK) { - xmlXPathFreeObject(res); - res = NULL; - } - - xmlXPathFreeParserContext(ctxt); - return(res); -} - /** * xmlXPathEvalExpression: * @str: the XPath expression diff --git a/xpath.h b/xpath.h index 7031c578..98455783 100644 --- a/xpath.h +++ b/xpath.h @@ -42,7 +42,11 @@ typedef enum { XPATH_INVALID_TYPE, XPATH_INVALID_ARITY, XPATH_INVALID_CTXT_SIZE, - XPATH_INVALID_CTXT_POSITION + XPATH_INVALID_CTXT_POSITION, + XPATH_MEMORY_ERROR, + XPTR_SYNTAX_ERROR, + XPTR_RESOURCE_ERROR, + XPTR_SUB_RESOURCE_ERROR } xmlXPathError; /* @@ -263,8 +267,13 @@ void xmlXPatherror (xmlXPathParserContextPtr ctxt, int no); /** - * Utilities for implementing more functions + * Utilities to extend XPath (XPointer) */ +xmlXPathParserContextPtr + xmlXPathNewParserContext (const xmlChar *str, + xmlXPathContextPtr ctxt); +void xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt); + xmlXPathObjectPtr valuePop (xmlXPathParserContextPtr ctxt); int valuePush (xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr value);