Commit 56a4cb8c authored by Daniel Veillard's avatar Daniel Veillard

Huge cleanup, I switched to compile with

-Wall -g -O -ansi -pedantic -W -Wunused -Wimplicit
-Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat
-Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow
-Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return
-Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline
- HTMLparser.[ch] HTMLtree.c SAX.c debugXML.c encoding.[ch]
  encoding.h entities.c error.c list.[ch] nanoftp.c
  nanohttp.c parser.[ch] parserInternals.[ch] testHTML.c
  testSAX.c testURI.c testXPath.c tree.[ch] uri.c
  valid.[ch] xinclude.c xmlIO.[ch] xmllint.c xmlmemory.c
  xpath.c xpathInternals.h xpointer.[ch] example/gjobread.c:
  Cleanup, staticfied a number of non-exported functions,
  detected and cleaned up a dozen of problem found this way,
  avoided a lot of public function name/typedef/system names clashes
- doc/xml.html: updated
- configure.in: switched private flags to the really pedantic ones.
Daniel
parent c7ad7ce5
Sat Mar 24 17:45:36 CET 2001
Huge cleanup, I switched to compile with
-Wall -g -O -ansi -pedantic -W -Wunused -Wimplicit
-Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat
-Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow
-Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return
-Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline
* HTMLparser.[ch] HTMLtree.c SAX.c debugXML.c encoding.[ch]
encoding.h entities.c error.c list.[ch] nanoftp.c
nanohttp.c parser.[ch] parserInternals.[ch] testHTML.c
testSAX.c testURI.c testXPath.c tree.[ch] uri.c
valid.[ch] xinclude.c xmlIO.[ch] xmllint.c xmlmemory.c
xpath.c xpathInternals.h xpointer.[ch] example/gjobread.c:
Cleanup, staticfied a number of non-exported functions,
detected and cleaned up a dozen of problem found this way,
avoided a lot of public function name/typedef/system names clashes
* doc/xml.html: updated
* configure.in: switched private flags to the really pedantic ones.
Thu Mar 22 22:44:15 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* configure.in: 2.3.5
......
This diff is collapsed.
......@@ -49,7 +49,7 @@ struct _htmlElemDesc {
typedef struct _htmlEntityDesc htmlEntityDesc;
typedef htmlEntityDesc *htmlEntityDescPtr;
struct _htmlEntityDesc {
int value; /* the UNICODE value for the character */
unsigned int value; /* the UNICODE value for the character */
const char *name; /* The entity name */
const char *desc; /* the description */
};
......@@ -59,7 +59,7 @@ struct _htmlEntityDesc {
*/
htmlElemDescPtr htmlTagLookup (const xmlChar *tag);
htmlEntityDescPtr htmlEntityLookup(const xmlChar *name);
htmlEntityDescPtr htmlEntityValueLookup(int value);
htmlEntityDescPtr htmlEntityValueLookup(unsigned int value);
int htmlIsAutoClosed(htmlDocPtr doc,
htmlNodePtr elem);
......
......@@ -34,6 +34,18 @@
#include <libxml/xmlerror.h>
#include <libxml/parserInternals.h>
/************************************************************************
* *
* When running GCC in vaacum cleaner mode *
* *
************************************************************************/
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
/************************************************************************
* *
* Getting/Setting encoding meta tags *
......@@ -680,10 +692,13 @@ htmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem, int *size) {
* @doc: the document
* @encoding: the encoding string
*
* TODO: check whether encoding is needed
*
* Dump the HTML document DTD, if any.
*/
static void
htmlDtdDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, const char *encoding) {
htmlDtdDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
const char *encoding UNUSED) {
xmlDtdPtr cur = doc->intSubset;
if (cur == NULL) {
......@@ -717,7 +732,8 @@ htmlDtdDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, const char *encoding) {
* Dump an HTML attribute
*/
static void
htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur, const char *encoding) {
htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
const char *encoding UNUSED) {
xmlChar *value;
if (cur == NULL) {
......
......@@ -31,6 +31,16 @@
/* #define DEBUG_SAX */
/* #define DEBUG_SAX_TREE */
#ifdef __GNUC__
#ifndef DEBUG_SAX
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
#else
#define UNUSED
#endif
/**
* getPublicId:
* @ctx: the user data (XML parser context)
......@@ -40,7 +50,7 @@
* Returns a xmlChar *
*/
const xmlChar *
getPublicId(void *ctx)
getPublicId(void *ctx UNUSED)
{
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
return(NULL);
......@@ -59,7 +69,7 @@ const xmlChar *
getSystemId(void *ctx)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
return(BAD_CAST ctxt->input->filename);
return((const xmlChar *) ctxt->input->filename);
}
/**
......@@ -648,7 +658,7 @@ unparsedEntityDecl(void *ctx, const xmlChar *name,
* Everything is available on the context, so this is useless in our case.
*/
void
setDocumentLocator(void *ctx, xmlSAXLocatorPtr loc)
setDocumentLocator(void *ctx UNUSED, xmlSAXLocatorPtr loc UNUSED)
{
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
#ifdef DEBUG_SAX
......@@ -693,7 +703,7 @@ startDocument(void *ctx)
}
if ((ctxt->myDoc != NULL) && (ctxt->myDoc->URL == NULL) &&
(ctxt->input != NULL) && (ctxt->input->filename != NULL)) {
ctxt->myDoc->URL = xmlStrdup((xmlChar *) ctxt->input->filename);
ctxt->myDoc->URL = xmlStrdup((const xmlChar *) ctxt->input->filename);
}
}
......@@ -1082,7 +1092,7 @@ startElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
* called when the end of an element has been detected.
*/
void
endElement(void *ctx, const xmlChar *name)
endElement(void *ctx, const xmlChar *name UNUSED)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlParserNodeInfo node_info;
......@@ -1261,7 +1271,7 @@ characters(void *ctx, const xmlChar *ch, int len)
* Question: how much at a time ???
*/
void
ignorableWhitespace(void *ctx, const xmlChar *ch, int len)
ignorableWhitespace(void *ctx UNUSED, const xmlChar *ch UNUSED, int len UNUSED)
{
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
#ifdef DEBUG_SAX
......
......@@ -237,7 +237,8 @@ dnl fi
if test "${with_xptr}" = "" ; then
with_xptr="yes"
fi
CFLAGS="-Wall -g -pedantic"
CFLAGS="-Wall -g -O -ansi -pedantic -W -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline "
dnl -Wcast-qual
fi
dnl
dnl Aloow to disable various pieces
......
......@@ -33,6 +33,18 @@
#include <libxml/HTMLparser.h>
#include <libxml/xmlerror.h>
/************************************************************************
* *
* When running GCC in vaacum cleaner mode *
* *
************************************************************************/
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
#define IS_BLANK(c) \
(((c) == '\n') || ((c) == '\r') || ((c) == '\t') || ((c) == ' '))
......@@ -51,7 +63,8 @@ void xmlDebugDumpString(FILE *output, const xmlChar *str) {
fprintf(output, "...");
}
void xmlDebugDumpDtd(FILE *output, xmlDtdPtr dtd, int depth) {
static void
xmlDebugDumpDtdNode(FILE *output, xmlDtdPtr dtd, int depth) {
int i;
char shift[100];
......@@ -99,7 +112,8 @@ void xmlDebugDumpDtd(FILE *output, xmlDtdPtr dtd, int depth) {
}
}
void xmlDebugDumpAttrDecl(FILE *output, xmlAttributePtr attr, int depth) {
static void
xmlDebugDumpAttrDecl(FILE *output, xmlAttributePtr attr, int depth) {
int i;
char shift[100];
......@@ -154,11 +168,11 @@ void xmlDebugDumpAttrDecl(FILE *output, xmlAttributePtr attr, int depth) {
break;
}
if (attr->tree != NULL) {
int i;
int indx;
xmlEnumerationPtr cur = attr->tree;
for (i = 0;i < 5; i++) {
if (i != 0)
for (indx = 0;indx < 5; indx++) {
if (indx != 0)
fprintf(output, "|%s", cur->name);
else
fprintf(output, " (%s", cur->name);
......@@ -215,7 +229,8 @@ void xmlDebugDumpAttrDecl(FILE *output, xmlAttributePtr attr, int depth) {
}
}
void xmlDebugDumpElemDecl(FILE *output, xmlElementPtr elem, int depth) {
static void
xmlDebugDumpElemDecl(FILE *output, xmlElementPtr elem, int depth) {
int i;
char shift[100];
......@@ -284,7 +299,8 @@ void xmlDebugDumpElemDecl(FILE *output, xmlElementPtr elem, int depth) {
}
}
void xmlDebugDumpEntityDecl(FILE *output, xmlEntityPtr ent, int depth) {
static void
xmlDebugDumpEntityDecl(FILE *output, xmlEntityPtr ent, int depth) {
int i;
char shift[100];
......@@ -368,7 +384,8 @@ void xmlDebugDumpEntityDecl(FILE *output, xmlEntityPtr ent, int depth) {
}
}
void xmlDebugDumpNamespace(FILE *output, xmlNsPtr ns, int depth) {
static void
xmlDebugDumpNamespace(FILE *output, xmlNsPtr ns, int depth) {
int i;
char shift[100];
......@@ -397,14 +414,16 @@ void xmlDebugDumpNamespace(FILE *output, xmlNsPtr ns, int depth) {
}
}
void xmlDebugDumpNamespaceList(FILE *output, xmlNsPtr ns, int depth) {
static void
xmlDebugDumpNamespaceList(FILE *output, xmlNsPtr ns, int depth) {
while (ns != NULL) {
xmlDebugDumpNamespace(output, ns, depth);
ns = ns->next;
}
}
void xmlDebugDumpEntity(FILE *output, xmlEntityPtr ent, int depth) {
static void
xmlDebugDumpEntity(FILE *output, xmlEntityPtr ent, int depth) {
int i;
char shift[100];
......@@ -563,7 +582,7 @@ void xmlDebugDumpOneNode(FILE *output, xmlNodePtr node, int depth) {
fprintf(output, "NOTATION\n");
break;
case XML_DTD_NODE:
xmlDebugDumpDtd(output, (xmlDtdPtr) node, depth);
xmlDebugDumpDtdNode(output, (xmlDtdPtr) node, depth);
return;
case XML_ELEMENT_DECL:
xmlDebugDumpElemDecl(output, (xmlElementPtr) node, depth);
......@@ -786,8 +805,8 @@ void xmlDebugDumpDTD(FILE *output, xmlDtdPtr dtd) {
xmlDebugDumpNodeList(output, dtd->children, 1);
}
void xmlDebugDumpEntityCallback(xmlEntityPtr cur, FILE *output,
const xmlChar *name) {
static void
xmlDebugDumpEntityCallback(xmlEntityPtr cur, FILE *output) {
fprintf(output, "%s : ", cur->name);
switch (cur->etype) {
case XML_INTERNAL_GENERAL_ENTITY:
......@@ -1067,9 +1086,9 @@ void xmlLsOneNode(FILE *output, xmlNodePtr node) {
*
* Returns 0
*/
int
xmlShellList(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node,
xmlNodePtr node2) {
static int
xmlShellList(xmlShellCtxtPtr ctxt UNUSED , char *arg UNUSED, xmlNodePtr node,
xmlNodePtr node2 UNUSED) {
xmlNodePtr cur;
if ((node->type == XML_DOCUMENT_NODE) ||
......@@ -1100,9 +1119,9 @@ xmlShellList(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node,
*
* Returns 0
*/
int
xmlShellDir(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node,
xmlNodePtr node2) {
static int
xmlShellDir(xmlShellCtxtPtr ctxt UNUSED, char *arg UNUSED, xmlNodePtr node,
xmlNodePtr node2 UNUSED) {
if ((node->type == XML_DOCUMENT_NODE) ||
(node->type == XML_HTML_DOCUMENT_NODE)) {
xmlDebugDumpDocumentHead(stdout, (xmlDocPtr) node);
......@@ -1126,9 +1145,9 @@ xmlShellDir(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node,
*
* Returns 0
*/
int
xmlShellCat(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node,
xmlNodePtr node2) {
static int
xmlShellCat(xmlShellCtxtPtr ctxt, char *arg UNUSED, xmlNodePtr node,
xmlNodePtr node2 UNUSED) {
if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) {
#ifdef LIBXML_HTML_ENABLED
if (node->type == XML_HTML_DOCUMENT_NODE)
......@@ -1163,9 +1182,9 @@ xmlShellCat(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node,
*
* Returns 0 or -1 if loading failed
*/
int
xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
xmlNodePtr node2) {
static int
xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node UNUSED,
xmlNodePtr node2 UNUSED) {
xmlDocPtr doc;
int html = 0;
......@@ -1215,9 +1234,9 @@ xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
*
* Returns 0 or -1 in case of error
*/
int
static int
xmlShellWrite(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
xmlNodePtr node2) {
xmlNodePtr node2 UNUSED) {
if (node == NULL)
return(-1);
if ((filename == NULL) || (filename[0] == 0)) {
......@@ -1283,9 +1302,9 @@ xmlShellWrite(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
*
* Returns 0 or -1 in case of error
*/
int
xmlShellSave(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
xmlNodePtr node2) {
static int
xmlShellSave(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node UNUSED,
xmlNodePtr node2 UNUSED) {
if (ctxt->doc == NULL)
return(-1);
if ((filename == NULL) || (filename[0] == 0))
......@@ -1339,9 +1358,9 @@ xmlShellSave(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
*
* Returns 0 or -1 in case of error
*/
int
xmlShellValidate(xmlShellCtxtPtr ctxt, char *dtd, xmlNodePtr node,
xmlNodePtr node2) {
static int
xmlShellValidate(xmlShellCtxtPtr ctxt, char *dtd, xmlNodePtr node UNUSED,
xmlNodePtr node2 UNUSED) {
xmlValidCtxt vctxt;
int res = -1;
......@@ -1377,9 +1396,9 @@ xmlShellValidate(xmlShellCtxtPtr ctxt, char *dtd, xmlNodePtr node,
*
* Returns 0 or -1 in case of error
*/
int
xmlShellDu(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr tree,
xmlNodePtr node2) {
static int
xmlShellDu(xmlShellCtxtPtr ctxt UNUSED, char *arg UNUSED, xmlNodePtr tree,
xmlNodePtr node2 UNUSED) {
xmlNodePtr node;
int indent = 0,i;
......@@ -1453,9 +1472,9 @@ xmlShellDu(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr tree,
*
* Returns 0 or -1 in case of error
*/
int
xmlShellPwd(xmlShellCtxtPtr ctxt, char *buffer, xmlNodePtr node,
xmlNodePtr node2) {
static int
xmlShellPwd(xmlShellCtxtPtr ctxt UNUSED, char *buffer, xmlNodePtr node,
xmlNodePtr node2 UNUSED) {
xmlNodePtr cur, tmp, next;
char buf[500];
char sep;
......@@ -1605,6 +1624,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
* Parse the command itself
*/
cur = cmdline;
nbargs = 0;
while ((*cur == ' ') || (*cur == '\t')) cur++;
i = 0;
while ((*cur != ' ') && (*cur != '\t') &&
......@@ -1685,15 +1705,16 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
"%s: no such node\n", arg);
break;
case XPATH_NODESET: {
int i;
int indx;
for (i = 0;i < list->nodesetval->nodeNr;i++) {
for (indx = 0;indx < list->nodesetval->nodeNr;
indx++) {
if (dir)
xmlShellDir(ctxt, NULL,
list->nodesetval->nodeTab[i], NULL);
list->nodesetval->nodeTab[indx], NULL);
else
xmlShellList(ctxt, NULL,
list->nodesetval->nodeTab[i], NULL);
list->nodesetval->nodeTab[indx], NULL);
}
break;
}
......@@ -1819,12 +1840,13 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
"%s: no such node\n", arg);
break;
case XPATH_NODESET: {
int i;
int indx;
for (i = 0;i < list->nodesetval->nodeNr;i++) {
for (indx = 0;indx < list->nodesetval->nodeNr;
indx++) {
if (i > 0) printf(" -------\n");
xmlShellCat(ctxt, NULL,
list->nodesetval->nodeTab[i], NULL);
list->nodesetval->nodeTab[indx], NULL);
}
break;
}
......
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>The XML C library for Gnome</title>
......@@ -246,6 +244,15 @@ you want to test those</p>
docs</li>
</ul>
<h3>2.3.5: Mar 23 2001</h3>
<ul>
<li>Biggest change is separate parsing and evaluation of XPath expressions,
there is some new APIs for this too</li>
<li>included a number of bug fixes(XML push parser, 51876, notations,
52299)</li>
<li>Fixed some portability issues</li>
</ul>
<h3>2.3.4: Mar 10 2001</h3>
<ul>
<li>Fixed bugs #51860 and #51861</li>
......@@ -1481,6 +1488,6 @@ Gnome CVS base under gnome-xml/example</p>
<p><a href="mailto:Daniel.Veillard@imag.fr">Daniel Veillard</a></p>
<p>$Id: xml.html,v 1.74 2001/03/10 12:32:02 veillard Exp $</p>
<p>$Id: xml.html,v 1.75 2001/03/21 10:28:36 veillard Exp $</p>
</body>
</html>
......@@ -91,7 +91,7 @@ static int xmlLittleEndian = 1;
* Returns the char value or -1 in case of error and update @len with the
* number of bytes used
*/
int
static int
xmlGetUTF8Char(const unsigned char *utf, int *len) {
unsigned int c;
......@@ -206,7 +206,7 @@ xmlCheckUTF8(const unsigned char *utf)
* as the return value is positive, else unpredictiable.
* The value of @outlen after return is the number of ocetes consumed.
*/
int
static int
asciiToUTF8(unsigned char* out, int *outlen,
const unsigned char* in, int *inlen) {
unsigned char* outstart = out;
......@@ -258,7 +258,7 @@ asciiToUTF8(unsigned char* out, int *outlen,
* as the return value is positive, else unpredictiable.
* The value of @outlen after return is the number of ocetes consumed.
*/
int
static int
UTF8Toascii(unsigned char* out, int *outlen,
const unsigned char* in, int *inlen) {
const unsigned char* processed = in;
......@@ -478,7 +478,7 @@ UTF8Toisolat1(unsigned char* out, int *outlen,
* The value of *inlen after return is the number of octets consumed
* as the return value is positive, else unpredictiable.
*/
int
static int
UTF16LEToUTF8(unsigned char* out, int *outlen,
const unsigned char* inb, int *inlenb)
{
......@@ -562,7 +562,7 @@ UTF16LEToUTF8(unsigned char* out, int *outlen,
* Returns the number of byte written, or -1 by lack of space, or -2
* if the transcoding failed.
*/
int
static int
UTF8ToUTF16LE(unsigned char* outb, int *outlen,
const unsigned char* in, int *inlen)
{
......@@ -685,7 +685,7 @@ UTF8ToUTF16LE(unsigned char* outb, int *outlen,
* The value of *inlen after return is the number of octets consumed
* as the return value is positive, else unpredictiable.
*/
int
static int
UTF16BEToUTF8(unsigned char* out, int *outlen,
const unsigned char* inb, int *inlenb)
{
......@@ -773,7 +773,7 @@ UTF16BEToUTF8(unsigned char* out, int *outlen,
* Returns the number of byte written, or -1 by lack of space, or -2
* if the transcoding failed.
*/
int
static int
UTF8ToUTF16BE(unsigned char* outb, int *outlen,
const unsigned char* in, int *inlen)
{
......@@ -1247,7 +1247,7 @@ static xmlCharEncodingHandlerPtr xmlDefaultCharEncodingHandler = NULL;
* Create and registers an xmlCharEncodingHandler.
* Returns the xmlCharEncodingHandlerPtr created (or NULL in case of error).
*/
xmlCharEncodingHandlerPtr
static xmlCharEncodingHandlerPtr
xmlNewCharEncodingHandler(const char *name,
xmlCharEncodingInputFunc input,
xmlCharEncodingOutputFunc output) {
......@@ -1662,9 +1662,7 @@ xmlIconvWrapper(iconv_t cd,
char *icv_out = (char *) out;
int ret;
ret = iconv(cd,
&icv_in, &icv_inlen,
&icv_out, &icv_outlen);
ret = iconv(cd, &icv_in, &icv_inlen, &icv_out, &icv_outlen);
if (in != NULL) {
*inlen -= icv_inlen;
*outlen -= icv_outlen;
......@@ -1672,7 +1670,7 @@ xmlIconvWrapper(iconv_t cd,
*inlen = 0;
*outlen = 0;
}
if (icv_inlen != 0 || ret == (size_t) -1) {
if ((icv_inlen != 0) || (ret == -1)) {
#ifdef EILSEQ
if (errno == EILSEQ) {
return -2;
......
......@@ -180,6 +180,17 @@ int xmlCharEncFirstLine (xmlCharEncodingHandler *handler,
xmlBufferPtr in);
int xmlCharEncCloseFunc (xmlCharEncodingHandler *handler);
/*
* Export a few useful functions
*/
int UTF8Toisolat1 (unsigned char* out,
int *outlen,
const unsigned char* in,
int *inlen);
int isolat1ToUTF8 (unsigned char* out,
int *outlen,
const unsigned char* in,
int *inlen);
#ifdef __cplusplus
}
#endif
......
......@@ -24,23 +24,6 @@
#include <libxml/xmlerror.h>
#define DEBUG_ENT_REF /* debugging of cross entities dependancies */
#define ENTITY_HASH_SIZE 256 /* modify xmlEntityComputeHash accordingly */
/*
* xmlEntityComputeHash:
*
* Computes the hash value for this given entity
*/
int
xmlEntityComputeHash(const xmlChar *name) {
register const unsigned char *cur = (const unsigned char *) name;
register unsigned char val = 0;
if (name == NULL)
return(val);
while (*cur) val += *cur++;
return(val);
}
/*
* The XML predefined entities.
......@@ -67,7 +50,7 @@ xmlHashTablePtr xmlPredefinedEntities = NULL;
/*
* xmlFreeEntity : clean-up an entity record.
*/
void xmlFreeEntity(xmlEntityPtr entity) {
static void xmlFreeEntity(xmlEntityPtr entity) {
if (entity == NULL) return;
if (entity->children)
......@@ -166,7 +149,7 @@ xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
* Set up the predefined entities.
*/
void xmlInitializePredefinedEntities(void) {
int i;
unsigned int i;
xmlChar name[50];
xmlChar value[50];
const char *in;
......@@ -326,7 +309,7 @@ xmlAddDocEntity(xmlDocPtr doc, const xmlChar *name, int type,
*
* Returns A pointer to the entity structure or NULL if not found.
*/
xmlEntityPtr
static xmlEntityPtr
xmlGetEntityFromTable(xmlEntitiesTablePtr table, const xmlChar *name) {
return((xmlEntityPtr) xmlHashLookup(table, name));
}
......@@ -428,13 +411,13 @@ xmlGetDocEntity(xmlDocPtr doc, const xmlChar *name) {
/*
* A buffer used for converting entities to their equivalent and back.
*/
static int buffer_size = 0;
static xmlChar *buffer = NULL;
static int static_buffer_size = 0;
static xmlChar *static_buffer = NULL;
int growBuffer(void) {
buffer_size *= 2;
buffer = (xmlChar *) xmlRealloc(buffer, buffer_size * sizeof(xmlChar));
if (buffer == NULL) {
static int growBuffer(void) {
static_buffer_size *= 2;
static_buffer = (xmlChar *) xmlRealloc(static_buffer, static_buffer_size * sizeof(xmlChar));
if (static_buffer == NULL) {
perror("realloc failed");
return(-1);
}
......@@ -461,7 +444,7 @@ int growBuffer(void) {
const xmlChar *
xmlEncodeEntities(xmlDocPtr doc, const xmlChar *input) {
const xmlChar *cur = input;
xmlChar *out = buffer;
xmlChar *out = static_buffer;
static int warning = 1;
int html = 0;
......@@ -478,21 +461,21 @@ xmlEncodeEntities(xmlDocPtr doc, const xmlChar *input) {
if (doc != NULL)
html = (doc->type == XML_HTML_DOCUMENT_NODE);
if (buffer == NULL) {
buffer_size = 1000;
buffer = (xmlChar *) xmlMalloc(buffer_size * sizeof(xmlChar));
if (buffer == NULL) {
if (static_buffer == NULL) {
static_buffer_size = 1000;
static_buffer = (xmlChar *) xmlMalloc(static_buffer_size * sizeof(xmlChar));
if (static_buffer == NULL) {
perror("malloc failed");
return(NULL);
}
out = buffer;
out = static_buffer;
}
while (*cur != '\0') {
if (out - buffer > buffer_size - 100) {
int index = out - buffer;
if (out - static_buffer > static_buffer_size - 100) {
int indx = out - static_buffer;
growBuffer();
out = &buffer[index];
out = &static_buffer[indx];
}
/*
......@@ -572,7 +555,7 @@ xmlEncodeEntities(xmlDocPtr doc, const xmlChar *input) {
cur++;
}
*out++ = 0;
return(buffer);
return(static_buffer);
}
/*
......@@ -626,10 +609,10 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
while (*cur != '\0') {
if (out - buffer > buffer_size - 100) {
int index = out - buffer;
int indx = out - buffer;
growBufferReentrant();
out = &buffer[index];
out = &buffer[indx];
}
/*
......@@ -819,10 +802,10 @@ xmlEncodeSpecialChars(xmlDocPtr doc, const xmlChar *input) {
while (*cur != '\0') {
if (out - buffer > buffer_size - 10) {
int index = out - buffer;
int indx = out - buffer;
growBufferReentrant();
out = &buffer[index];
out = &buffer[indx];
}
/*
......@@ -895,7 +878,7 @@ xmlFreeEntitiesTable(xmlEntitiesTablePtr table) {
*
* Returns the new xmlEntitiesPtr or NULL in case of error.
*/
xmlEntityPtr
static xmlEntityPtr
xmlCopyEntity(xmlEntityPtr ent) {
xmlEntityPtr cur;
......
......@@ -18,6 +18,11 @@
#include <libxml/xmlerror.h>
#include <libxml/xmlmemory.h>
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
/************************************************************************
* *
* Handling of out of context errors *
......@@ -32,8 +37,8 @@
*
* Default handler for out of context error messages.
*/
void
xmlGenericErrorDefaultFunc(void *ctx, const char *msg, ...) {
static void