#ifdef __cplusplus
extern "C" {
@@ -167,6 +168,8 @@ int xmlIsRef (xmlDocPtr doc,
xmlNodePtr elem,
xmlAttrPtr attr);
int xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr);
+xmlListPtr xmlGetRefs (xmlDocPtr doc,
+ const xmlChar *ID);
/**
* The public function calls related to validity checking
diff --git a/xinclude.c b/xinclude.c
index 3c203638..b27773f5 100644
--- a/xinclude.c
+++ b/xinclude.c
@@ -79,7 +79,7 @@ struct _xmlXIncludeCtxt {
*
* Add a new node to process to an XInclude context
*/
-void
+static void
xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
if (ctxt->incMax == 0) {
ctxt->incMax = 4;
@@ -128,7 +128,7 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
*
* Add a new document to the list
*/
-void
+static void
xmlXIncludeAddDoc(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, const xmlURL url) {
if (ctxt->docMax == 0) {
ctxt->docMax = 4;
@@ -177,7 +177,7 @@ xmlXIncludeAddDoc(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, const xmlURL url) {
*
* Add a new txtument to the list
*/
-void
+static void
xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, xmlNodePtr txt, const xmlURL url) {
if (ctxt->txtMax == 0) {
ctxt->txtMax = 4;
@@ -226,7 +226,7 @@ xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, xmlNodePtr txt, const xmlURL url) {
*
* Returns the new set
*/
-xmlXIncludeCtxtPtr
+static xmlXIncludeCtxtPtr
xmlXIncludeNewContext(xmlDocPtr doc) {
xmlXIncludeCtxtPtr ret;
@@ -254,7 +254,7 @@ xmlXIncludeNewContext(xmlDocPtr doc) {
*
* Free an XInclude context
*/
-void
+static void
xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
int i;
@@ -299,7 +299,7 @@ xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
*
* Load the document, and store the result in the XInclude context
*/
-void
+static void
xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
xmlDocPtr doc;
xmlURIPtr uri;
@@ -417,7 +417,7 @@ loaded:
*
* Load the content, and store the result in the XInclude context
*/
-void
+static void
xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
xmlParserInputBufferPtr buf;
xmlNodePtr node;
@@ -529,7 +529,7 @@ loaded:
*
* Returns the result list or NULL in case of error
*/
-xmlNodePtr
+static xmlNodePtr
xmlXIncludePreProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
xmlXIncludeAddNode(ctxt, node);
return(0);
@@ -544,7 +544,7 @@ xmlXIncludePreProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
*
* Returns 0 if substition succeeded, -1 if some processing failed
*/
-int
+static int
xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
xmlNodePtr cur;
xmlChar *href;
@@ -668,7 +668,7 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
*
* Returns 0 if substition succeeded, -1 if some processing failed
*/
-int
+static int
xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
xmlNodePtr cur, end, list;
@@ -710,15 +710,14 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
/**
* xmlXIncludeTestNode:
- * @doc: an XML document
* @node: an XInclude node
*
* test if the node is an XInclude node
*
* Returns 1 true, 0 otherwise
*/
-int
-xmlXIncludeTestNode(xmlDocPtr doc, xmlNodePtr node) {
+static int
+xmlXIncludeTestNode(xmlNodePtr node) {
if (node == NULL)
return(0);
if (node->ns == NULL)
@@ -754,18 +753,18 @@ xmlXIncludeProcess(xmlDocPtr doc) {
* First phase: lookup the elements in the document
*/
cur = xmlDocGetRootElement(doc);
- if (xmlXIncludeTestNode(doc, cur))
+ if (xmlXIncludeTestNode(cur))
xmlXIncludePreProcessNode(ctxt, cur);
while (cur != NULL) {
/* TODO: need to work on entities -> stack */
if ((cur->children != NULL) &&
(cur->children->type != XML_ENTITY_DECL)) {
cur = cur->children;
- if (xmlXIncludeTestNode(doc, cur))
+ if (xmlXIncludeTestNode(cur))
xmlXIncludePreProcessNode(ctxt, cur);
} else if (cur->next != NULL) {
cur = cur->next;
- if (xmlXIncludeTestNode(doc, cur))
+ if (xmlXIncludeTestNode(cur))
xmlXIncludePreProcessNode(ctxt, cur);
} else {
do {
@@ -773,7 +772,7 @@ xmlXIncludeProcess(xmlDocPtr doc) {
if (cur == NULL) break; /* do */
if (cur->next != NULL) {
cur = cur->next;
- if (xmlXIncludeTestNode(doc, cur))
+ if (xmlXIncludeTestNode(cur))
xmlXIncludePreProcessNode(ctxt, cur);
break; /* do */
}
diff --git a/xmlIO.c b/xmlIO.c
index 9860ef66..5e72400d 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -118,6 +118,18 @@ xmlOutputCallback xmlOutputCallbackTable[MAX_OUTPUT_CALLBACK];
int xmlOutputCallbackNr = 0;
int xmlOutputCallbackInitialized = 0;
+/************************************************************************
+ * *
+ * When running GCC in vaacum cleaner mode *
+ * *
+ ************************************************************************/
+
+#ifdef __GNUC__
+#define UNUSED __attribute__((__unused__))
+#else
+#define UNUSED
+#endif
+
/************************************************************************
* *
* Standard I/O for file accesses *
@@ -159,94 +171,11 @@ xmlCheckFilename (const char *path)
return 1;
}
-int
+static int
xmlNop(void) {
return(0);
}
-/**
- * xmlFdMatch:
- * @filename: the URI for matching
- *
- * input from file descriptor
- *
- * Returns 1 if matches, 0 otherwise
- */
-int
-xmlFdMatch (const char *filename) {
- return(1);
-}
-
-/**
- * xmlFdOpen:
- * @filename: the URI for matching
- *
- * input from file descriptor, supports compressed input
- * if @filename is "-" then the standard input is used
- *
- * Returns an I/O context or NULL in case of error
- */
-void *
-xmlFdOpen (const char *filename) {
- const char *path = NULL;
- int fd;
-
- if (!strcmp(filename, "-")) {
- fd = 0;
- return((void *) fd);
- }
-
- if (!strncmp(filename, "file://localhost", 16))
- path = &filename[16];
- else if (!strncmp(filename, "file:///", 8))
- path = &filename[8];
- else if (filename[0] == '/')
- path = filename;
- if (path == NULL)
- return(NULL);
-
-#ifdef WIN32
- fd = _open (path, O_RDONLY | _O_BINARY);
-#else
- fd = open (path, O_RDONLY);
-#endif
-
- return((void *) fd);
-}
-
-/**
- * xmlFdOpenW:
- * @filename: the URI for matching
- *
- * input from file descriptor,
- * if @filename is "-" then the standard output is used
- *
- * Returns an I/O context or NULL in case of error
- */
-void *
-xmlFdOpenW (const char *filename) {
- const char *path = NULL;
- int fd;
-
- if (!strcmp(filename, "-")) {
- fd = 1;
- return((void *) fd);
- }
-
- if (!strncmp(filename, "file://localhost", 16))
- path = &filename[16];
- else if (!strncmp(filename, "file:///", 8))
- path = &filename[8];
- else if (filename[0] == '/')
- path = filename;
- if (path == NULL)
- return(NULL);
-
- fd = open (path, O_WRONLY);
-
- return((void *) fd);
-}
-
/**
* xmlFdRead:
* @context: the I/O context
@@ -257,7 +186,7 @@ xmlFdOpenW (const char *filename) {
*
* Returns the number of bytes written
*/
-int
+static int
xmlFdRead (void * context, char * buffer, int len) {
return(read((int) context, &buffer[0], len));
}
@@ -272,7 +201,7 @@ xmlFdRead (void * context, char * buffer, int len) {
*
* Returns the number of bytes written
*/
-int
+static int
xmlFdWrite (void * context, const char * buffer, int len) {
return(write((int) context, &buffer[0], len));
}
@@ -283,7 +212,7 @@ xmlFdWrite (void * context, const char * buffer, int len) {
*
* Close an I/O channel
*/
-void
+static void
xmlFdClose (void * context) {
close((int) context);
}
@@ -296,8 +225,8 @@ xmlFdClose (void * context) {
*
* Returns 1 if matches, 0 otherwise
*/
-int
-xmlFileMatch (const char *filename) {
+static int
+xmlFileMatch (const char *filename UNUSED) {
return(1);
}
@@ -310,7 +239,7 @@ xmlFileMatch (const char *filename) {
*
* Returns an I/O context or NULL in case of error
*/
-void *
+static void *
xmlFileOpen (const char *filename) {
const char *path = NULL;
FILE *fd;
@@ -349,7 +278,7 @@ xmlFileOpen (const char *filename) {
*
* Returns an I/O context or NULL in case of error
*/
-void *
+static void *
xmlFileOpenW (const char *filename) {
const char *path = NULL;
FILE *fd;
@@ -383,7 +312,7 @@ xmlFileOpenW (const char *filename) {
*
* Returns the number of bytes written
*/
-int
+static int
xmlFileRead (void * context, char * buffer, int len) {
return(fread(&buffer[0], 1, len, (FILE *) context));
}
@@ -398,7 +327,7 @@ xmlFileRead (void * context, char * buffer, int len) {
*
* Returns the number of bytes written
*/
-int
+static int
xmlFileWrite (void * context, const char * buffer, int len) {
return(fwrite(&buffer[0], 1, len, (FILE *) context));
}
@@ -409,7 +338,7 @@ xmlFileWrite (void * context, const char * buffer, int len) {
*
* Close an I/O channel
*/
-void
+static void
xmlFileClose (void * context) {
fclose((FILE *) context);
}
@@ -420,7 +349,7 @@ xmlFileClose (void * context) {
*
* Flush an I/O channel
*/
-void
+static void
xmlFileFlush (void * context) {
fflush((FILE *) context);
}
@@ -439,8 +368,8 @@ xmlFileFlush (void * context) {
*
* Returns 1 if matches, 0 otherwise
*/
-int
-xmlGzfileMatch (const char *filename) {
+static int
+xmlGzfileMatch (const char *filename UNUSED) {
return(1);
}
@@ -453,7 +382,7 @@ xmlGzfileMatch (const char *filename) {
*
* Returns an I/O context or NULL in case of error
*/
-void *
+static void *
xmlGzfileOpen (const char *filename) {
const char *path = NULL;
gzFile fd;
@@ -489,7 +418,7 @@ xmlGzfileOpen (const char *filename) {
*
* Returns an I/O context or NULL in case of error
*/
-void *
+static void *
xmlGzfileOpenW (const char *filename, int compression) {
const char *path = NULL;
char mode[15];
@@ -525,7 +454,7 @@ xmlGzfileOpenW (const char *filename, int compression) {
*
* Returns the number of bytes written
*/
-int
+static int
xmlGzfileRead (void * context, char * buffer, int len) {
return(gzread((gzFile) context, &buffer[0], len));
}
@@ -540,7 +469,7 @@ xmlGzfileRead (void * context, char * buffer, int len) {
*
* Returns the number of bytes written
*/
-int
+static int
xmlGzfileWrite (void * context, const char * buffer, int len) {
return(gzwrite((gzFile) context, (char *) &buffer[0], len));
}
@@ -551,7 +480,7 @@ xmlGzfileWrite (void * context, const char * buffer, int len) {
*
* Close a compressed I/O channel
*/
-void
+static void
xmlGzfileClose (void * context) {
gzclose((gzFile) context);
}
@@ -571,7 +500,7 @@ xmlGzfileClose (void * context) {
*
* Returns 1 if matches, 0 otherwise
*/
-int
+static int
xmlIOHTTPMatch (const char *filename) {
if (!strncmp(filename, "http://", 7))
return(1);
@@ -586,7 +515,7 @@ xmlIOHTTPMatch (const char *filename) {
*
* Returns an I/O context or NULL in case of error
*/
-void *
+static void *
xmlIOHTTPOpen (const char *filename) {
return(xmlNanoHTTPOpen(filename, NULL));
}
@@ -601,7 +530,7 @@ xmlIOHTTPOpen (const char *filename) {
*
* Returns the number of bytes written
*/
-int
+static int
xmlIOHTTPRead(void * context, char * buffer, int len) {
return(xmlNanoHTTPRead(context, &buffer[0], len));
}
@@ -612,7 +541,7 @@ xmlIOHTTPRead(void * context, char * buffer, int len) {
*
* Close an HTTP I/O channel
*/
-void
+static void
xmlIOHTTPClose (void * context) {
xmlNanoHTTPClose(context);
}
@@ -632,7 +561,7 @@ xmlIOHTTPClose (void * context) {
*
* Returns 1 if matches, 0 otherwise
*/
-int
+static int
xmlIOFTPMatch (const char *filename) {
if (!strncmp(filename, "ftp://", 6))
return(1);
@@ -647,7 +576,7 @@ xmlIOFTPMatch (const char *filename) {
*
* Returns an I/O context or NULL in case of error
*/
-void *
+static void *
xmlIOFTPOpen (const char *filename) {
return(xmlNanoFTPOpen(filename));
}
@@ -662,7 +591,7 @@ xmlIOFTPOpen (const char *filename) {
*
* Returns the number of bytes written
*/
-int
+static int
xmlIOFTPRead(void * context, char * buffer, int len) {
return(xmlNanoFTPRead(context, &buffer[0], len));
}
@@ -673,7 +602,7 @@ xmlIOFTPRead(void * context, char * buffer, int len) {
*
* Close an FTP I/O channel
*/
-void
+static void
xmlIOFTPClose (void * context) {
xmlNanoFTPClose(context);
}
@@ -682,51 +611,51 @@ xmlIOFTPClose (void * context) {
/**
* xmlRegisterInputCallbacks:
- * @match: the xmlInputMatchCallback
- * @open: the xmlInputOpenCallback
- * @read: the xmlInputReadCallback
- * @close: the xmlInputCloseCallback
+ * @matchFunc: the xmlInputMatchCallback
+ * @openFunc: the xmlInputOpenCallback
+ * @readFunc: the xmlInputReadCallback
+ * @closeFunc: the xmlInputCloseCallback
*
* Register a new set of I/O callback for handling parser input.
*
* Returns the registered handler number or -1 in case of error
*/
int
-xmlRegisterInputCallbacks(xmlInputMatchCallback match,
- xmlInputOpenCallback open, xmlInputReadCallback read,
- xmlInputCloseCallback close) {
+xmlRegisterInputCallbacks(xmlInputMatchCallback matchFunc,
+ xmlInputOpenCallback openFunc, xmlInputReadCallback readFunc,
+ xmlInputCloseCallback closeFunc) {
if (xmlInputCallbackNr >= MAX_INPUT_CALLBACK) {
return(-1);
}
- xmlInputCallbackTable[xmlInputCallbackNr].matchcallback = match;
- xmlInputCallbackTable[xmlInputCallbackNr].opencallback = open;
- xmlInputCallbackTable[xmlInputCallbackNr].readcallback = read;
- xmlInputCallbackTable[xmlInputCallbackNr].closecallback = close;
+ xmlInputCallbackTable[xmlInputCallbackNr].matchcallback = matchFunc;
+ xmlInputCallbackTable[xmlInputCallbackNr].opencallback = openFunc;
+ xmlInputCallbackTable[xmlInputCallbackNr].readcallback = readFunc;
+ xmlInputCallbackTable[xmlInputCallbackNr].closecallback = closeFunc;
return(xmlInputCallbackNr++);
}
/**
* xmlRegisterOutputCallbacks:
- * @match: the xmlOutputMatchCallback
- * @open: the xmlOutputOpenCallback
- * @write: the xmlOutputWriteCallback
- * @close: the xmlOutputCloseCallback
+ * @matchFunc: the xmlOutputMatchCallback
+ * @openFunc: the xmlOutputOpenCallback
+ * @writeFunc: the xmlOutputWriteCallback
+ * @closeFunc: the xmlOutputCloseCallback
*
* Register a new set of I/O callback for handling output.
*
* Returns the registered handler number or -1 in case of error
*/
int
-xmlRegisterOutputCallbacks(xmlOutputMatchCallback match,
- xmlOutputOpenCallback open, xmlOutputWriteCallback write,
- xmlOutputCloseCallback close) {
+xmlRegisterOutputCallbacks(xmlOutputMatchCallback matchFunc,
+ xmlOutputOpenCallback openFunc, xmlOutputWriteCallback writeFunc,
+ xmlOutputCloseCallback closeFunc) {
if (xmlOutputCallbackNr >= MAX_INPUT_CALLBACK) {
return(-1);
}
- xmlOutputCallbackTable[xmlOutputCallbackNr].matchcallback = match;
- xmlOutputCallbackTable[xmlOutputCallbackNr].opencallback = open;
- xmlOutputCallbackTable[xmlOutputCallbackNr].writecallback = write;
- xmlOutputCallbackTable[xmlOutputCallbackNr].closecallback = close;
+ xmlOutputCallbackTable[xmlOutputCallbackNr].matchcallback = matchFunc;
+ xmlOutputCallbackTable[xmlOutputCallbackNr].opencallback = openFunc;
+ xmlOutputCallbackTable[xmlOutputCallbackNr].writecallback = writeFunc;
+ xmlOutputCallbackTable[xmlOutputCallbackNr].closecallback = closeFunc;
return(xmlOutputCallbackNr++);
}
diff --git a/xmlIO.h b/xmlIO.h
index ecff73bc..fee5b9b3 100644
--- a/xmlIO.h
+++ b/xmlIO.h
@@ -112,10 +112,10 @@ int xmlParserInputBufferPush (xmlParserInputBufferPtr in,
void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
char * xmlParserGetDirectory (const char *filename);
-int xmlRegisterInputCallbacks (xmlInputMatchCallback match,
- xmlInputOpenCallback open,
- xmlInputReadCallback read,
- xmlInputCloseCallback close);
+int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
+ xmlInputOpenCallback openFunc,
+ xmlInputReadCallback readFunc,
+ xmlInputCloseCallback closeFunc);
/*
* Interfaces for output
*/
@@ -151,10 +151,10 @@ int xmlOutputBufferWriteString (xmlOutputBufferPtr out,
int xmlOutputBufferFlush (xmlOutputBufferPtr out);
int xmlOutputBufferClose (xmlOutputBufferPtr out);
-int xmlRegisterOutputCallbacks (xmlOutputMatchCallback match,
- xmlOutputOpenCallback open,
- xmlOutputWriteCallback write,
- xmlOutputCloseCallback close);
+int xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc,
+ xmlOutputOpenCallback openFunc,
+ xmlOutputWriteCallback writeFunc,
+ xmlOutputCloseCallback closeFunc);
/*
* This save function are part of tree.h and HTMLtree.h actually
diff --git a/xmllint.c b/xmllint.c
index 332146a2..dfe1e690 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -109,7 +109,7 @@ extern int xmlGetWarningsDefaultValue;
************************************************************************/
char buffer[50000];
-void
+static void
xmlHTMLEncodeSend(void) {
char *result;
@@ -128,7 +128,7 @@ xmlHTMLEncodeSend(void) {
* Displays the associated file and line informations for the current input
*/
-void
+static void
xmlHTMLPrintFileInfo(xmlParserInputPtr input) {
xmlGenericError(xmlGenericErrorContext, "");
if (input != NULL) {
@@ -149,7 +149,7 @@ xmlHTMLPrintFileInfo(xmlParserInputPtr input) {
* Displays current context within the input content for error tracking
*/
-void
+static void
xmlHTMLPrintFileContext(xmlParserInputPtr input) {
const xmlChar *cur, *base;
int n;
@@ -194,7 +194,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) {
* Display and format an error messages, gives file, line, position and
* extra parameters.
*/
-void
+static void
xmlHTMLError(void *ctx, const char *msg, ...)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@@ -231,7 +231,7 @@ xmlHTMLError(void *ctx, const char *msg, ...)
* Display and format a warning messages, gives file, line, position and
* extra parameters.
*/
-void
+static void
xmlHTMLWarning(void *ctx, const char *msg, ...)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@@ -269,7 +269,7 @@ xmlHTMLWarning(void *ctx, const char *msg, ...)
* Display and format an validity error messages, gives file,
* line, position and extra parameters.
*/
-void
+static void
xmlHTMLValidityError(void *ctx, const char *msg, ...)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@@ -303,7 +303,7 @@ xmlHTMLValidityError(void *ctx, const char *msg, ...)
* Display and format a validity warning messages, gives file, line,
* position and extra parameters.
*/
-void
+static void
xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@@ -342,7 +342,7 @@ xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
* Returns a pointer to it or NULL on EOF the caller is expected to
* free the returned string.
*/
-char *
+static char *
xmlShellReadline(char *prompt) {
#ifdef HAVE_LIBREADLINE
char *line_read;
@@ -373,10 +373,10 @@ xmlShellReadline(char *prompt) {
* *
************************************************************************/
-int myRead(FILE *f, char * buffer, int len) {
- return(fread(buffer, 1, len, f));
+static int myRead(FILE *f, char * buf, int len) {
+ return(fread(buf, 1, len, f));
}
-void myClose(FILE *f) {
+static void myClose(FILE *f) {
if (f != stdin) {
fclose(f);
}
@@ -387,7 +387,7 @@ void myClose(FILE *f) {
* Test processing *
* *
************************************************************************/
-void parseAndPrintFile(char *filename) {
+static void parseAndPrintFile(char *filename) {
xmlDocPtr doc = NULL, tmp;
if ((timing) && (!repeat))
diff --git a/xmlmemory.c b/xmlmemory.c
index 4cf16031..dd695da1 100644
--- a/xmlmemory.c
+++ b/xmlmemory.c
@@ -33,6 +33,32 @@
#include
#include
+/************************************************************************
+ * *
+ * When running GCC in vaacum cleaner mode *
+ * *
+ ************************************************************************/
+
+#ifdef __GNUC__
+#define UNUSED __attribute__((__unused__))
+#else
+#define UNUSED
+#endif
+
+void xmlMallocBreakpoint(void);
+void * xmlMemMalloc(int size);
+void * xmlMallocLoc(int size, const char * file, int line);
+void * xmlMemRealloc(void *ptr,int size);
+void xmlMemFree(void *ptr);
+char * xmlMemoryStrdup(const char *str);
+
+/************************************************************************
+ * *
+ * Macros, variables and associated types *
+ * *
+ ************************************************************************/
+
+
#ifdef xmlMalloc
#undef xmlMalloc
#endif
@@ -384,7 +410,7 @@ xmlMemUsed(void) {
* tries to show some content from the memory block
*/
-void
+static void
xmlMemContentShow(FILE *fp, MEMHDR *p)
{
int i,j,len = p->mh_size;
@@ -498,7 +524,7 @@ xmlMemDisplay(FILE *fp)
currentTime = time(NULL);
tstruct = localtime(¤tTime);
- strftime(buf, sizeof(buf) - 1, "%c", tstruct);
+ strftime(buf, sizeof(buf) - 1, "%I:%M:%S %p", tstruct);
fprintf(fp," %s\n\n", buf);
#endif
diff --git a/xpath.c b/xpath.c
index 32ecbb22..fd760e5a 100644
--- a/xpath.c
+++ b/xpath.c
@@ -276,7 +276,7 @@ struct _xmlXPathCompExpr {
*
* Returns the newly allocated xmlXPathCompExprPtr or NULL in case of error
*/
-xmlXPathCompExprPtr
+static xmlXPathCompExprPtr
xmlXPathNewCompExpr(void) {
xmlXPathCompExprPtr cur;
@@ -350,7 +350,7 @@ xmlXPathFreeCompExpr(xmlXPathCompExprPtr comp) {
*
* Returns -1 in case of failure, the index otherwise
*/
-int
+static int
xmlXPathCompExprAdd(xmlXPathCompExprPtr comp, int ch1, int ch2,
xmlXPathOp op, int value,
int value2, int value3, void *value4, void *value5) {
@@ -410,7 +410,8 @@ xmlXPathCompExprAdd(ctxt->comp, (ch1), (ch2), (op), (val), (val2), 0 ,NULL ,NULL
__FILE__, __LINE__);
#ifdef LIBXML_DEBUG_ENABLED
-void xmlXPathDebugDumpNode(FILE *output, xmlNodePtr cur, int depth) {
+static void
+xmlXPathDebugDumpNode(FILE *output, xmlNodePtr cur, int depth) {
int i;
char shift[100];
@@ -433,7 +434,8 @@ void xmlXPathDebugDumpNode(FILE *output, xmlNodePtr cur, int depth) {
else
xmlDebugDumpOneNode(output, cur, depth);
}
-void xmlXPathDebugDumpNodeList(FILE *output, xmlNodePtr cur, int depth) {
+static void
+xmlXPathDebugDumpNodeList(FILE *output, xmlNodePtr cur, int depth) {
xmlNodePtr tmp;
int i;
char shift[100];
@@ -455,7 +457,8 @@ void xmlXPathDebugDumpNodeList(FILE *output, xmlNodePtr cur, int depth) {
}
}
-void xmlXPathDebugDumpNodeSet(FILE *output, xmlNodeSetPtr cur, int depth) {
+static void
+xmlXPathDebugDumpNodeSet(FILE *output, xmlNodeSetPtr cur, int depth) {
int i;
char shift[100];
@@ -478,7 +481,8 @@ void xmlXPathDebugDumpNodeSet(FILE *output, xmlNodeSetPtr cur, int depth) {
}
}
-void xmlXPathDebugDumpValueTree(FILE *output, xmlNodeSetPtr cur, int depth) {
+static void
+xmlXPathDebugDumpValueTree(FILE *output, xmlNodeSetPtr cur, int depth) {
int i;
char shift[100];
@@ -499,7 +503,8 @@ void xmlXPathDebugDumpValueTree(FILE *output, xmlNodeSetPtr cur, int depth) {
}
#if defined(LIBXML_XPTR_ENABLED)
void xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth);
-void xmlXPathDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) {
+static void
+xmlXPathDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) {
int i;
char shift[100];
@@ -617,7 +622,8 @@ xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) {
}
}
-void xmlXPathDebugDumpStepOp(FILE *output, xmlXPathCompExprPtr comp,
+static void
+xmlXPathDebugDumpStepOp(FILE *output, xmlXPathCompExprPtr comp,
xmlXPathStepOpPtr op, int depth) {
int i;
char shift[100];
@@ -788,8 +794,10 @@ finish:
if (op->ch2 >= 0)
xmlXPathDebugDumpStepOp(output, comp, &comp->steps[op->ch2], depth + 1);
}
-void xmlXPathDebugDumpCompExpr(FILE *output, xmlXPathCompExprPtr comp,
- int depth) {
+
+void
+xmlXPathDebugDumpCompExpr(FILE *output, xmlXPathCompExprPtr comp,
+ int depth) {
int i;
char shift[100];
@@ -933,7 +941,7 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize)
int is_negative;
int use_scientific;
int exponent;
- int index;
+ int indx;
int count;
double n;
@@ -964,8 +972,8 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize)
} else {
n = number;
for (i = 1; i < INTEGER_DIGITS - 1; i++) {
- index = (int)n % 10;
- *(--pointer) = "0123456789"[index];
+ indx = (int)n % 10;
+ *(--pointer) = "0123456789"[indx];
n /= 10.0;
if (n < 1.0)
break;
@@ -989,10 +997,10 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize)
while (i < FRACTION_DIGITS) {
n -= floor(n);
n *= 10.0;
- index = (int)n % 10;
- *(pointer++) = "0123456789"[index];
+ indx = (int)n % 10;
+ *(pointer++) = "0123456789"[indx];
i++;
- if ((index != 0) || (count > 0))
+ if ((indx != 0) || (count > 0))
count++;
if ((n > 10.0) || (count > FRACTION_DIGITS / 2))
break;
@@ -1494,7 +1502,7 @@ xmlXPathFreeNodeSet(xmlNodeSetPtr obj) {
* Free the NodeSet compound and the actual tree, this is different
* from xmlXPathFreeNodeSet()
*/
-void
+static void
xmlXPathFreeValueTree(xmlNodeSetPtr obj) {
int i;
@@ -2326,7 +2334,7 @@ xmlXPathNewParserContext(const xmlChar *str, xmlXPathContextPtr ctxt) {
*
* Returns the xmlXPathParserContext just allocated.
*/
-xmlXPathParserContextPtr
+static xmlXPathParserContextPtr
xmlXPathCompParserContext(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt) {
xmlXPathParserContextPtr ret;
@@ -2420,7 +2428,7 @@ void xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs);
*
* Returns 0 or 1 depending on the results of the test.
*/
-int
+static int
xmlXPathCompareNodeSetFloat(xmlXPathParserContextPtr ctxt, int inf, int strict,
xmlXPathObjectPtr arg, xmlXPathObjectPtr f) {
int i, ret = 0;
@@ -2473,7 +2481,7 @@ xmlXPathCompareNodeSetFloat(xmlXPathParserContextPtr ctxt, int inf, int strict,
*
* Returns 0 or 1 depending on the results of the test.
*/
-int
+static int
xmlXPathCompareNodeSetString(xmlXPathParserContextPtr ctxt, int inf, int strict,
xmlXPathObjectPtr arg, xmlXPathObjectPtr s) {
int i, ret = 0;
@@ -2506,7 +2514,6 @@ xmlXPathCompareNodeSetString(xmlXPathParserContextPtr ctxt, int inf, int strict,
/**
* xmlXPathCompareNodeSets:
- * @ctxt: the XPath Parser context
* @op: less than (-1), equal (0) or greater than (1)
* @strict: is the comparison strict
* @arg1: the fist node set object
@@ -2533,8 +2540,8 @@ xmlXPathCompareNodeSetString(xmlXPathParserContextPtr ctxt, int inf, int strict,
* Conclusion all nodes need to be converted first to their string value
* and then the comparison must be done when possible
*/
-int
-xmlXPathCompareNodeSets(xmlXPathParserContextPtr ctxt, int inf, int strict,
+static int
+xmlXPathCompareNodeSets(int inf, int strict,
xmlXPathObjectPtr arg1, xmlXPathObjectPtr arg2) {
int i, j, init = 0;
double val1;
@@ -2624,7 +2631,7 @@ xmlXPathCompareNodeSets(xmlXPathParserContextPtr ctxt, int inf, int strict,
*
* Returns 0 or 1 depending on the results of the test.
*/
-int
+static int
xmlXPathCompareNodeSetValue(xmlXPathParserContextPtr ctxt, int inf, int strict,
xmlXPathObjectPtr arg, xmlXPathObjectPtr val) {
if ((val == NULL) || (arg == NULL) ||
@@ -2636,7 +2643,7 @@ xmlXPathCompareNodeSetValue(xmlXPathParserContextPtr ctxt, int inf, int strict,
return(xmlXPathCompareNodeSetFloat(ctxt, inf, strict, arg, val));
case XPATH_NODESET:
case XPATH_XSLT_TREE:
- return(xmlXPathCompareNodeSets(ctxt, inf, strict, arg, val));
+ return(xmlXPathCompareNodeSets(inf, strict, arg, val));
case XPATH_STRING:
return(xmlXPathCompareNodeSetString(ctxt, inf, strict, arg, val));
case XPATH_BOOLEAN:
@@ -2664,7 +2671,7 @@ xmlXPathCompareNodeSetValue(xmlXPathParserContextPtr ctxt, int inf, int strict,
*
* Returns 0 or 1 depending on the results of the test.
*/
-int
+static int
xmlXPathEqualNodeSetString(xmlXPathObjectPtr arg, const xmlChar *str) {
int i;
xmlNodeSetPtr ns;
@@ -2702,7 +2709,7 @@ xmlXPathEqualNodeSetString(xmlXPathObjectPtr arg, const xmlChar *str) {
*
* Returns 0 or 1 depending on the results of the test.
*/
-int
+static int
xmlXPathEqualNodeSetFloat(xmlXPathObjectPtr arg, double f) {
char buf[100] = "";
@@ -2730,7 +2737,7 @@ xmlXPathEqualNodeSetFloat(xmlXPathObjectPtr arg, double f) {
*
* Returns 0 or 1 depending on the results of the test.
*/
-int
+static int
xmlXPathEqualNodeSets(xmlXPathObjectPtr arg1, xmlXPathObjectPtr arg2) {
int i, j;
xmlChar **values1;
@@ -3034,7 +3041,7 @@ xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict) {
if ((arg2->type == XPATH_NODESET) || (arg1->type == XPATH_NODESET)) {
if ((arg2->type == XPATH_NODESET) && (arg1->type == XPATH_NODESET)) {
- ret = xmlXPathCompareNodeSets(ctxt, inf, strict, arg1, arg2);
+ ret = xmlXPathCompareNodeSets(inf, strict, arg1, arg2);
} else {
if (arg1->type == XPATH_NODESET) {
ret = xmlXPathCompareNodeSetValue(ctxt, inf, strict,
@@ -3468,9 +3475,9 @@ xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
return((xmlNodePtr) ctxt->context->doc);
return(ctxt->context->node->parent);
case XML_ATTRIBUTE_NODE: {
- xmlAttrPtr cur = (xmlAttrPtr) ctxt->context->node;
+ xmlAttrPtr tmp = (xmlAttrPtr) ctxt->context->node;
- return(cur->parent);
+ return(tmp->parent);
}
case XML_DOCUMENT_NODE:
case XML_DOCUMENT_TYPE_NODE:
@@ -3756,7 +3763,7 @@ xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
*
* Returns the new NodeSet resulting from the search.
*/
-void
+static void
xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, xmlXPathAxisVal axis,
xmlXPathTestVal test, xmlXPathTypeVal type,
const xmlChar *prefix, const xmlChar *name) {
@@ -4393,7 +4400,7 @@ xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* Libxml keep the original prefix so the "real qualified name" used is
* returned.
*/
-void
+static void
xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathObjectPtr cur;
@@ -4457,7 +4464,7 @@ xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs) {
*/
xmlXPathObjectPtr
xmlXPathConvertString(xmlXPathObjectPtr val) {
- xmlXPathObjectPtr ret;
+ xmlXPathObjectPtr ret = NULL;
if (val == NULL)
return(xmlXPathNewCString(""));
@@ -5183,7 +5190,7 @@ not_equal:
*/
xmlXPathObjectPtr
xmlXPathConvertNumber(xmlXPathObjectPtr val) {
- xmlXPathObjectPtr ret;
+ xmlXPathObjectPtr ret = NULL;
double res;
if (val == NULL)
@@ -5447,7 +5454,7 @@ xmlXPathParseNCName(xmlXPathParserContextPtr ctxt) {
* to get the Prefix if any.
*/
-xmlChar *
+static xmlChar *
xmlXPathParseQName(xmlXPathParserContextPtr ctxt, xmlChar **prefix) {
xmlChar *ret = NULL;
@@ -5884,7 +5891,7 @@ xmlXPathCompFilterExpr(xmlXPathParserContextPtr ctxt) {
* Returns the Name parsed or NULL
*/
-xmlChar *
+static xmlChar *
xmlXPathScanName(xmlXPathParserContextPtr ctxt) {
xmlChar buf[XML_MAX_NAMELEN];
int len = 0;
@@ -6405,7 +6412,7 @@ xmlXPathCompPredicate(xmlXPathParserContextPtr ctxt) {
*
* Returns the name found and update @test, @type and @prefix appropriately
*/
-xmlChar *
+static xmlChar *
xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test,
xmlXPathTypeVal *type, const xmlChar **prefix,
xmlChar *name) {
@@ -6463,8 +6470,6 @@ xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test,
/*
* Specific case: search a PI by name.
*/
- xmlXPathObjectPtr cur;
-
if (name != NULL)
xmlFree(name);
@@ -6539,7 +6544,7 @@ xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test,
*
* Returns the axis or 0
*/
-xmlXPathAxisVal
+static xmlXPathAxisVal
xmlXPathIsAxisName(const xmlChar *name) {
xmlXPathAxisVal ret = 0;
switch (name[0]) {
@@ -6587,41 +6592,6 @@ xmlXPathIsAxisName(const xmlChar *name) {
return(ret);
}
-/**
- * xmlXPathCompAxisSpecifier:
- * @ctxt: the XPath Parser context
- *
- * Parse an axis value
- *
- * Returns the axis found
- */
-xmlXPathAxisVal
-xmlXPathCompAxisSpecifier(xmlXPathParserContextPtr ctxt) {
- xmlXPathAxisVal ret = AXIS_CHILD;
- int blank = 0;
- xmlChar *name;
-
- if (CUR == '@') {
- NEXT;
- return(AXIS_ATTRIBUTE);
- } else {
- name = xmlXPathParseNCName(ctxt);
- if (name == NULL) {
- XP_ERROR0(XPATH_EXPR_ERROR);
- }
- if (IS_BLANK(CUR))
- blank = 1;
- SKIP_BLANKS;
- if ((CUR == ':') && (NXT(1) == ':')) {
- ret = xmlXPathIsAxisName(name);
- } else if ((blank) && (CUR == ':'))
- XP_ERROR0(XPATH_EXPR_ERROR);
-
- xmlFree(name);
- }
- return(ret);
-}
-
/**
* xmlXPathCompStep:
* @ctxt: the XPath Parser context
@@ -7047,20 +7017,20 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op) {
* Hum are we filtering the result of an XPointer expression
*/
if (ctxt->value->type == XPATH_LOCATIONSET) {
- xmlLocationSetPtr newset = NULL;
- xmlLocationSetPtr oldset;
+ xmlLocationSetPtr newlocset = NULL;
+ xmlLocationSetPtr oldlocset;
/*
- * Extract the old set, and then evaluate the result of the
- * expression for all the element in the set. use it to grow
- * up a new set.
+ * Extract the old locset, and then evaluate the result of the
+ * expression for all the element in the locset. use it to grow
+ * up a new locset.
*/
CHECK_TYPE(XPATH_LOCATIONSET);
obj = valuePop(ctxt);
- oldset = obj->user;
+ oldlocset = obj->user;
ctxt->context->node = NULL;
- if ((oldset == NULL) || (oldset->locNr == 0)) {
+ if ((oldlocset == NULL) || (oldlocset->locNr == 0)) {
ctxt->context->contextSize = 0;
ctxt->context->proximityPosition = 0;
if (op->ch2 != -1)
@@ -7072,17 +7042,17 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op) {
CHECK_ERROR;
return;
}
- newset = xmlXPtrLocationSetCreate(NULL);
+ newlocset = xmlXPtrLocationSetCreate(NULL);
- for (i = 0; i < oldset->locNr; i++) {
+ for (i = 0; i < oldlocset->locNr; i++) {
/*
* Run the evaluation with a node list made of a
- * single item in the nodeset.
+ * single item in the nodelocset.
*/
- ctxt->context->node = oldset->locTab[i]->user;
+ ctxt->context->node = oldlocset->locTab[i]->user;
tmp = xmlXPathNewNodeSet(ctxt->context->node);
valuePush(ctxt, tmp);
- ctxt->context->contextSize = oldset->locNr;
+ ctxt->context->contextSize = oldlocset->locNr;
ctxt->context->proximityPosition = i + 1;
if (op->ch2 != -1)
@@ -7095,8 +7065,8 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op) {
*/
res = valuePop(ctxt);
if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
- xmlXPtrLocationSetAdd(newset,
- xmlXPathObjectCopy(oldset->locTab[i]));
+ xmlXPtrLocationSetAdd(newlocset,
+ xmlXPathObjectCopy(oldlocset->locTab[i]));
}
/*
@@ -7113,13 +7083,13 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op) {
}
/*
- * The result is used as the new evaluation set.
+ * The result is used as the new evaluation locset.
*/
xmlXPathFreeObject(obj);
ctxt->context->node = NULL;
ctxt->context->contextSize = -1;
ctxt->context->proximityPosition = -1;
- valuePush(ctxt, xmlXPtrWrapLocationSet(newset));
+ valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
ctxt->context->node = oldnode;
return;
}
@@ -7464,7 +7434,6 @@ xmlXPathCompiledEval(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctx) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathEval: %d object left on the stack\n",
stack);
- xmlXPathDebugDumpCompExpr(stdout, ctxt->comp, 0);
}
if (ctxt->error != XPATH_EXPRESSION_OK) {
xmlXPathFreeObject(res);
diff --git a/xpathInternals.h b/xpathInternals.h
index 51f6ad55..cb2f3b42 100644
--- a/xpathInternals.h
+++ b/xpathInternals.h
@@ -79,7 +79,9 @@ void xmlXPatherror (xmlXPathParserContextPtr ctxt,
void xmlXPathDebugDumpObject (FILE *output,
xmlXPathObjectPtr cur,
int depth);
-
+void xmlXPathDebugDumpCompExpr(FILE *output,
+ xmlXPathCompExprPtr comp,
+ int depth);
/**
* Extending a context
*/
@@ -139,7 +141,9 @@ xmlXPathObjectPtr xmlXPathNewNodeSet (xmlNodePtr val);
xmlXPathObjectPtr xmlXPathNewValueTree (xmlNodePtr val);
void xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
xmlNodePtr val);
-
+void xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur,
+ xmlNodePtr val);
+void xmlXPathNodeSetSort (xmlNodeSetPtr set);
void xmlXPathIdFunction (xmlXPathParserContextPtr ctxt,
int nargs);
@@ -193,13 +197,37 @@ void xmlXPathMultValues(xmlXPathParserContextPtr ctxt);
void xmlXPathDivValues(xmlXPathParserContextPtr ctxt);
void xmlXPathModValues(xmlXPathParserContextPtr ctxt);
+int xmlXPathIsNodeType(const xmlChar *name);
/*
* Some of the axis navigation routines
*/
-xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur);
-xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur);
-xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur);
+xmlNodePtr xmlXPathNextSelf(xmlXPathParserContextPtr ctxt,
+ xmlNodePtr cur);
+xmlNodePtr xmlXPathNextChild(xmlXPathParserContextPtr ctxt,
+ xmlNodePtr cur);
+xmlNodePtr xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt,
+ xmlNodePtr cur);
+xmlNodePtr xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt,
+ xmlNodePtr cur);
+xmlNodePtr xmlXPathNextParent(xmlXPathParserContextPtr ctxt,
+ xmlNodePtr cur);
+xmlNodePtr xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt,
+ xmlNodePtr cur);
+xmlNodePtr xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt,
+ xmlNodePtr cur);
+xmlNodePtr xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt,
+ xmlNodePtr cur);
+xmlNodePtr xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt,
+ xmlNodePtr cur);
+xmlNodePtr xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt,
+ xmlNodePtr cur);
+xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt,
+ xmlNodePtr cur);
+xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt,
+ xmlNodePtr cur);
+xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt,
+ xmlNodePtr cur);
/*
* The official core of XPath functions
*/
diff --git a/xpointer.c b/xpointer.c
index 37c13a6a..cfd3ee43 100644
--- a/xpointer.c
+++ b/xpointer.c
@@ -15,6 +15,18 @@
#include "config.h"
#endif
+/************************************************************************
+ * *
+ * When running GCC in vaacum cleaner mode *
+ * *
+ ************************************************************************/
+
+#ifdef __GNUC__
+#define UNUSED __attribute__((__unused__))
+#else
+#define UNUSED
+#endif
+
/**
* TODO: better handling of error cases, the full expression should
* be parsed beforehand instead of a progressive evaluation
@@ -66,7 +78,7 @@ xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur);
*
* Returns the number of child for an element, -1 in case of error
*/
-int
+static int
xmlXPtrGetArity(xmlNodePtr cur) {
int i;
if (cur == NULL)
@@ -89,7 +101,7 @@ xmlXPtrGetArity(xmlNodePtr cur) {
* Returns the index of the node in its parent children list, -1
* in case of error
*/
-int
+static int
xmlXPtrGetIndex(xmlNodePtr cur) {
int i;
if (cur == NULL)
@@ -111,7 +123,7 @@ xmlXPtrGetIndex(xmlNodePtr cur) {
*
* Returns the @no'th element child of @cur or NULL
*/
-xmlNodePtr
+static xmlNodePtr
xmlXPtrGetNthChild(xmlNodePtr cur, int no) {
int i;
if (cur == NULL)
@@ -149,7 +161,7 @@ xmlXPtrGetNthChild(xmlNodePtr cur, int no) {
* Returns -2 in case of error 1 if first point < second point, 0 if
* that's the same point, -1 otherwise
*/
-int
+static int
xmlXPtrCmpPoints(xmlNodePtr node1, int index1, xmlNodePtr node2, int index2) {
if ((node1 == NULL) || (node2 == NULL))
return(-2);
@@ -169,19 +181,19 @@ xmlXPtrCmpPoints(xmlNodePtr node1, int index1, xmlNodePtr node2, int index2) {
/**
* xmlXPtrNewPoint:
* @node: the xmlNodePtr
- * @index: the index within the node
+ * @indx: the indx within the node
*
* Create a new xmlXPathObjectPtr of type point
*
* Returns the newly created object.
*/
-xmlXPathObjectPtr
-xmlXPtrNewPoint(xmlNodePtr node, int index) {
+static xmlXPathObjectPtr
+xmlXPtrNewPoint(xmlNodePtr node, int indx) {
xmlXPathObjectPtr ret;
if (node == NULL)
return(NULL);
- if (index < 0)
+ if (indx < 0)
return(NULL);
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
@@ -193,7 +205,7 @@ xmlXPtrNewPoint(xmlNodePtr node, int index) {
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
ret->type = XPATH_POINT;
ret->user = (void *) node;
- ret->index = index;
+ ret->index = indx;
return(ret);
}
@@ -203,7 +215,7 @@ xmlXPtrNewPoint(xmlNodePtr node, int index) {
*
* Make sure the points in the range are in the right order
*/
-void
+static void
xmlXPtrRangeCheckOrder(xmlXPathObjectPtr range) {
int tmp;
xmlNodePtr tmp2;
@@ -234,7 +246,7 @@ xmlXPtrRangeCheckOrder(xmlXPathObjectPtr range) {
*
* Return 1 if equal, 0 otherwise
*/
-int
+static int
xmlXPtrRangesEqual(xmlXPathObjectPtr range1, xmlXPathObjectPtr range2) {
if (range1 == range2)
return(1);
@@ -862,8 +874,8 @@ xmlXPtrWrapLocationSet(xmlLocationSetPtr val) {
* Move the current node of the nodeset on the stack to the
* given child if found
*/
-void
-xmlXPtrGetChildNo(xmlXPathParserContextPtr ctxt, int index) {
+static void
+xmlXPtrGetChildNo(xmlXPathParserContextPtr ctxt, int indx) {
xmlNodePtr cur = NULL;
xmlXPathObjectPtr obj;
xmlNodeSetPtr oldset;
@@ -871,12 +883,12 @@ xmlXPtrGetChildNo(xmlXPathParserContextPtr ctxt, int index) {
CHECK_TYPE(XPATH_NODESET);
obj = valuePop(ctxt);
oldset = obj->nodesetval;
- if ((index <= 0) || (oldset == NULL) || (oldset->nodeNr != 1)) {
+ if ((indx <= 0) || (oldset == NULL) || (oldset->nodeNr != 1)) {
xmlXPathFreeObject(obj);
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
return;
}
- cur = xmlXPtrGetNthChild(oldset->nodeTab[0], index);
+ cur = xmlXPtrGetNthChild(oldset->nodeTab[0], indx);
if (cur == NULL) {
xmlXPathFreeObject(obj);
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
@@ -920,7 +932,7 @@ xmlXPtrGetChildNo(xmlXPathParserContextPtr ctxt, int index) {
* TODO: there is no new scheme registration mechanism
*/
-void
+static void
xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
xmlChar *buffer, *cur;
int len;
@@ -1062,7 +1074,7 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
* Parse and evaluate a Full XPtr i.e. possibly a cascade of XPath based
* expressions or other shemes.
*/
-void
+static void
xmlXPtrEvalFullXPtr(xmlXPathParserContextPtr ctxt, xmlChar *name) {
if (name == NULL)
name = xmlXPathParseName(ctxt);
@@ -1130,7 +1142,7 @@ xmlXPtrEvalFullXPtr(xmlXPathParserContextPtr ctxt, xmlChar *name) {
* Parse and evaluate a Child Sequence. This routine also handle the
* case of a Bare Name used to get a document ID.
*/
-void
+static void
xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt, xmlChar *name) {
/*
* XPointer don't allow by syntax to adress in mutirooted trees
@@ -1171,7 +1183,7 @@ xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt, xmlChar *name) {
*
* Parse and evaluate an XPointer
*/
-void
+static void
xmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) {
if (ctxt->valueTab == NULL) {
/* Allocate the value stack */
@@ -1346,13 +1358,13 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
* Returns an xmlNodePtr list or NULL.
* the caller has to free the node tree.
*/
-xmlNodePtr
+static xmlNodePtr
xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
/* pointers to generated nodes */
xmlNodePtr list = NULL, last = NULL, parent = NULL, tmp;
/* pointers to traversal nodes */
xmlNodePtr start, cur, end;
- int index, index2;
+ int index1, index2;
if (range == NULL)
return(NULL);
@@ -1367,7 +1379,7 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
return(xmlCopyNode(start, 1));
cur = start;
- index = range->index;
+ index1 = range->index;
index2 = range->index2;
while (cur != NULL) {
if (cur == end) {
@@ -1379,10 +1391,10 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
tmp = xmlNewTextLen(NULL, 0);
} else {
len = index2;
- if ((cur == start) && (index > 1)) {
- content += (index - 1);
- len -= (index - 1);
- index = 0;
+ if ((cur == start) && (index1 > 1)) {
+ content += (index1 - 1);
+ len -= (index1 - 1);
+ index1 = 0;
} else {
len = index2;
}
@@ -1414,9 +1426,9 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
end = xmlXPtrGetNthChild(cur, index2 - 1);
index2 = 0;
}
- if ((cur == start) && (index > 1)) {
- cur = xmlXPtrGetNthChild(cur, index - 1);
- index = 0;
+ if ((cur == start) && (index1 > 1)) {
+ cur = xmlXPtrGetNthChild(cur, index1 - 1);
+ index1 = 0;
} else {
cur = cur->children;
}
@@ -1433,20 +1445,20 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
if (content == NULL) {
tmp = xmlNewTextLen(NULL, 0);
} else {
- if (index > 1) {
- content += (index - 1);
+ if (index1 > 1) {
+ content += (index1 - 1);
}
tmp = xmlNewText(content);
}
last = list = tmp;
} else {
- if ((cur == start) && (index > 1)) {
+ if ((cur == start) && (index1 > 1)) {
tmp = xmlCopyNode(cur, 0);
list = tmp;
parent = tmp;
last = NULL;
- cur = xmlXPtrGetNthChild(cur, index - 1);
- index = 0;
+ cur = xmlXPtrGetNthChild(cur, index1 - 1);
+ index1 = 0;
/*
* Now gather the remaining nodes from cur to end
*/
@@ -1580,7 +1592,7 @@ xmlXPtrBuildNodeList(xmlXPathObjectPtr obj) {
*
* Returns the number of location children
*/
-int
+static int
xmlXPtrNbLocChildren(xmlNodePtr node) {
int ret = 0;
if (node == NULL)
@@ -1619,12 +1631,15 @@ xmlXPtrNbLocChildren(xmlNodePtr node) {
/**
* xmlXPtrHereFunction:
* @ctxt: the XPointer Parser context
+ * @nargs: the number of args
*
* Function implementing here() operation
* as described in 5.4.3
*/
void
xmlXPtrHereFunction(xmlXPathParserContextPtr ctxt, int nargs) {
+ CHECK_ARITY(0);
+
if (ctxt->context->here == NULL)
XP_ERROR(XPTR_SYNTAX_ERROR);
@@ -1634,12 +1649,15 @@ xmlXPtrHereFunction(xmlXPathParserContextPtr ctxt, int nargs) {
/**
* xmlXPtrOriginFunction:
* @ctxt: the XPointer Parser context
+ * @nargs: the number of args
*
* Function implementing origin() operation
* as described in 5.4.3
*/
void
xmlXPtrOriginFunction(xmlXPathParserContextPtr ctxt, int nargs) {
+ CHECK_ARITY(0);
+
if (ctxt->context->origin == NULL)
XP_ERROR(XPTR_SYNTAX_ERROR);
@@ -1649,6 +1667,7 @@ xmlXPtrOriginFunction(xmlXPathParserContextPtr ctxt, int nargs) {
/**
* xmlXPtrStartPointFunction:
* @ctxt: the XPointer Parser context
+ * @nargs: the number of args
*
* Function implementing start-point() operation
* as described in 5.4.3
@@ -1740,6 +1759,7 @@ xmlXPtrStartPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
/**
* xmlXPtrEndPointFunction:
* @ctxt: the XPointer Parser context
+ * @nargs: the number of args
*
* Function implementing end-point() operation
* as described in 5.4.3
@@ -1841,7 +1861,7 @@ xmlXPtrEndPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
*
* Returns a new location or NULL in case of error
*/
-xmlXPathObjectPtr
+static xmlXPathObjectPtr
xmlXPtrCoveringRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
if (loc == NULL)
return(NULL);
@@ -1876,11 +1896,11 @@ xmlXPtrCoveringRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
case XML_DOCUMENT_NODE:
case XML_NOTATION_NODE:
case XML_HTML_DOCUMENT_NODE: {
- int index = xmlXPtrGetIndex(node);
+ int indx = xmlXPtrGetIndex(node);
node = node->parent;
- return(xmlXPtrNewRange(node, index - 1,
- node, index + 1));
+ return(xmlXPtrNewRange(node, indx - 1,
+ node, indx + 1));
}
default:
return(NULL);
@@ -1896,6 +1916,7 @@ xmlXPtrCoveringRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
/**
* xmlXPtrRangeFunction:
* @ctxt: the XPointer Parser context
+ * @nargs: the number of args
*
* Function implementing the range() function 5.4.3
* location-set range(location-set )
@@ -1956,7 +1977,7 @@ xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
*
* Returns a new location or NULL in case of error
*/
-xmlXPathObjectPtr
+static xmlXPathObjectPtr
xmlXPtrInsideRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
if (loc == NULL)
return(NULL);
@@ -2044,6 +2065,7 @@ xmlXPtrInsideRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
/**
* xmlXPtrRangeInsideFunction:
* @ctxt: the XPointer Parser context
+ * @nargs: the number of args
*
* Function implementing the range-inside() function 5.4.3
* location-set range-inside(location-set )
@@ -2105,6 +2127,7 @@ xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs) {
/**
* xmlXPtrRangeToFunction:
* @ctxt: the XPointer Parser context
+ * @nargs: the number of args
*
* Implement the range-to() XPointer function
*/
@@ -2225,25 +2248,25 @@ found:
/**
* xmlXPtrAdvanceChar:
* @node: the node
- * @index: the index
+ * @indx: the indx
* @bytes: the number of bytes
*
* Advance a point of the associated number of bytes (not UTF8 chars)
*
* Returns -1 in case of failure, 0 otherwise
*/
-int
-xmlXPtrAdvanceChar(xmlNodePtr *node, int *index, int bytes) {
+static int
+xmlXPtrAdvanceChar(xmlNodePtr *node, int *indx, int bytes) {
xmlNodePtr cur;
int pos;
int len;
- if ((node == NULL) || (index == NULL))
+ if ((node == NULL) || (indx == NULL))
return(-1);
cur = *node;
if (cur == NULL)
return(-1);
- pos = *index;
+ pos = *indx;
while (bytes >= 0) {
/*
@@ -2265,7 +2288,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *index, int bytes) {
if (cur == NULL) {
*node = NULL;
- *index = 0;
+ *indx = 0;
return(-1);
}
@@ -2275,7 +2298,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *index, int bytes) {
if (pos == 0) pos = 1;
if (bytes == 0) {
*node = cur;
- *index = pos;
+ *indx = pos;
return(0);
}
/*
@@ -2290,7 +2313,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *index, int bytes) {
#endif
}
if (pos > len) {
- /* Strange, the index in the text node is greater than it's len */
+ /* Strange, the indx in the text node is greater than it's len */
STRANGE
pos = len;
}
@@ -2301,7 +2324,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *index, int bytes) {
} else if (pos + bytes < len) {
pos += bytes;
*node = cur;
- *index = pos;
+ *indx = pos;
return(0);
}
}
@@ -2324,7 +2347,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *index, int bytes) {
* of the range and (@end, @endindex) will endicate the end
* of the range
*/
-int
+static int
xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
xmlNodePtr *end, int *endindex) {
xmlNodePtr cur;
@@ -2422,7 +2445,7 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
* of the range and (@end, @endindex) will endicate the end
* of the range
*/
-int
+static int
xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
xmlNodePtr *end, int *endindex) {
xmlNodePtr cur;
@@ -2519,15 +2542,15 @@ xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
*
* Returns -1 in case of failure, 0 otherwise
*/
-int
-xmlXPtrGetLastChar(xmlNodePtr *node, int *index) {
+static int
+xmlXPtrGetLastChar(xmlNodePtr *node, int *indx) {
xmlNodePtr cur;
int pos, len = 0;
- if ((node == NULL) || (index == NULL))
+ if ((node == NULL) || (indx == NULL))
return(-1);
cur = *node;
- pos = *index;
+ pos = *indx;
if (cur == NULL)
return(-1);
@@ -2557,7 +2580,7 @@ xmlXPtrGetLastChar(xmlNodePtr *node, int *index) {
if (cur == NULL)
return(-1);
*node = cur;
- *index = len;
+ *indx = len;
return(0);
}
@@ -2565,31 +2588,31 @@ xmlXPtrGetLastChar(xmlNodePtr *node, int *index) {
* xmlXPtrGetStartPoint:
* @obj: an range
* @node: the resulting node
- * @index: the resulting index
+ * @indx: the resulting index
*
* read the object and return the start point coordinates.
*
* Returns -1 in case of failure, 0 otherwise
*/
-int
-xmlXPtrGetStartPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *index) {
- if ((obj == NULL) || (node == NULL) || (index == NULL))
+static int
+xmlXPtrGetStartPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *indx) {
+ if ((obj == NULL) || (node == NULL) || (indx == NULL))
return(-1);
switch (obj->type) {
case XPATH_POINT:
*node = obj->user;
if (obj->index <= 0)
- *index = 0;
+ *indx = 0;
else
- *index = obj->index;
+ *indx = obj->index;
return(0);
case XPATH_RANGE:
*node = obj->user;
if (obj->index <= 0)
- *index = 0;
+ *indx = 0;
else
- *index = obj->index;
+ *indx = obj->index;
return(0);
default:
return(-1);
@@ -2601,31 +2624,31 @@ xmlXPtrGetStartPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *index) {
* xmlXPtrGetEndPoint:
* @obj: an range
* @node: the resulting node
- * @index: the resulting index
+ * @indx: the resulting indx
*
* read the object and return the end point coordinates.
*
* Returns -1 in case of failure, 0 otherwise
*/
-int
-xmlXPtrGetEndPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *index) {
- if ((obj == NULL) || (node == NULL) || (index == NULL))
+static int
+xmlXPtrGetEndPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *indx) {
+ if ((obj == NULL) || (node == NULL) || (indx == NULL))
return(-1);
switch (obj->type) {
case XPATH_POINT:
*node = obj->user;
if (obj->index <= 0)
- *index = 0;
+ *indx = 0;
else
- *index = obj->index;
+ *indx = obj->index;
return(0);
case XPATH_RANGE:
*node = obj->user;
if (obj->index <= 0)
- *index = 0;
+ *indx = 0;
else
- *index = obj->index;
+ *indx = obj->index;
return(0);
default:
return(-1);
@@ -2636,6 +2659,7 @@ xmlXPtrGetEndPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *index) {
/**
* xmlXPtrStringRangeFunction:
* @ctxt: the XPointer Parser context
+ * @nargs: the number of args
*
* Function implementing the string-range() function
* range as described in 5.4.2
@@ -2678,7 +2702,7 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathObjectPtr string;
xmlXPathObjectPtr position = NULL;
xmlXPathObjectPtr number = NULL;
- int found, pos, num;
+ int found, pos = 0, num = 0;
/*
* Grab the arguments
@@ -2755,15 +2779,15 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
} else if (xmlXPtrAdvanceChar(&start, &startindex,
pos - 1) == 0) {
if ((number != NULL) && (num > 0)) {
- int rindex;
+ int rindx;
xmlNodePtr rend;
rend = start;
- rindex = startindex - 1;
- if (xmlXPtrAdvanceChar(&rend, &rindex,
+ rindx = startindex - 1;
+ if (xmlXPtrAdvanceChar(&rend, &rindx,
num) == 0) {
xmlXPtrLocationSetAdd(newset,
xmlXPtrNewRange(start, startindex,
- rend, rindex));
+ rend, rindx));
}
} else if ((number != NULL) && (num <= 0)) {
xmlXPtrLocationSetAdd(newset,
diff --git a/xpointer.h b/xpointer.h
index 255f826e..45efd791 100644
--- a/xpointer.h
+++ b/xpointer.h
@@ -38,11 +38,31 @@ xmlLocationSetPtr xmlXPtrLocationSetCreate(xmlXPathObjectPtr val);
void xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
xmlLocationSetPtr xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
xmlLocationSetPtr val2);
+xmlXPathObjectPtr xmlXPtrNewRange (xmlNodePtr start,
+ int startindex,
+ xmlNodePtr end,
+ int endindex);
+xmlXPathObjectPtr xmlXPtrNewRangePoints (xmlXPathObjectPtr start,
+ xmlXPathObjectPtr end);
+xmlXPathObjectPtr xmlXPtrNewRangeNodePoint(xmlNodePtr start,
+ xmlXPathObjectPtr end);
+xmlXPathObjectPtr xmlXPtrNewRangePointNode(xmlXPathObjectPtr start,
+ xmlNodePtr end);
+xmlXPathObjectPtr xmlXPtrNewRangeNodes (xmlNodePtr start,
+ xmlNodePtr end);
+xmlXPathObjectPtr xmlXPtrNewLocationSetNodes(xmlNodePtr start,
+ xmlNodePtr end);
+xmlXPathObjectPtr xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set);
xmlXPathObjectPtr xmlXPtrNewRangeNodeObject(xmlNodePtr start,
xmlXPathObjectPtr end);
+xmlXPathObjectPtr xmlXPtrNewCollapsedRange(xmlNodePtr start);
void xmlXPtrLocationSetAdd (xmlLocationSetPtr cur,
xmlXPathObjectPtr val);
xmlXPathObjectPtr xmlXPtrWrapLocationSet (xmlLocationSetPtr val);
+void xmlXPtrLocationSetDel (xmlLocationSetPtr cur,
+ xmlXPathObjectPtr val);
+void xmlXPtrLocationSetRemove(xmlLocationSetPtr cur,
+ int val);
/*
* Functions