mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
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
This commit is contained in:
@ -48,6 +48,19 @@
|
||||
#include <libxml/xmlIO.h>
|
||||
#include <libxml/uri.h>
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* When running GCC in vaacum cleaner mode *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define UNUSED __attribute__((__unused__))
|
||||
#else
|
||||
#define UNUSED
|
||||
#endif
|
||||
|
||||
void xmlUpgradeOldNs(xmlDocPtr doc);
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
@ -932,7 +945,7 @@ int
|
||||
xmlParserInputRead(xmlParserInputPtr in, int len) {
|
||||
int ret;
|
||||
int used;
|
||||
int index;
|
||||
int indx;
|
||||
|
||||
#ifdef DEBUG_INPUT
|
||||
xmlGenericError(xmlGenericErrorContext, "Read\n");
|
||||
@ -956,9 +969,9 @@ xmlParserInputRead(xmlParserInputPtr in, int len) {
|
||||
/*
|
||||
* the buffer has been realloced
|
||||
*/
|
||||
index = in->cur - in->base;
|
||||
indx = in->cur - in->base;
|
||||
in->base = in->buf->buffer->content;
|
||||
in->cur = &in->buf->buffer->content[index];
|
||||
in->cur = &in->buf->buffer->content[indx];
|
||||
}
|
||||
in->end = &in->buf->buffer->content[in->buf->buffer->use];
|
||||
|
||||
@ -981,7 +994,7 @@ xmlParserInputRead(xmlParserInputPtr in, int len) {
|
||||
int
|
||||
xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
||||
int ret;
|
||||
int index;
|
||||
int indx;
|
||||
|
||||
#ifdef DEBUG_INPUT
|
||||
xmlGenericError(xmlGenericErrorContext, "Grow\n");
|
||||
@ -993,8 +1006,8 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
||||
|
||||
CHECK_BUFFER(in);
|
||||
|
||||
index = in->cur - in->base;
|
||||
if (in->buf->buffer->use > (unsigned int) index + INPUT_CHUNK) {
|
||||
indx = in->cur - in->base;
|
||||
if (in->buf->buffer->use > (unsigned int) indx + INPUT_CHUNK) {
|
||||
|
||||
CHECK_BUFFER(in);
|
||||
|
||||
@ -1015,9 +1028,9 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
||||
/*
|
||||
* the buffer has been realloced
|
||||
*/
|
||||
index = in->cur - in->base;
|
||||
indx = in->cur - in->base;
|
||||
in->base = in->buf->buffer->content;
|
||||
in->cur = &in->buf->buffer->content[index];
|
||||
in->cur = &in->buf->buffer->content[indx];
|
||||
}
|
||||
in->end = &in->buf->buffer->content[in->buf->buffer->use];
|
||||
|
||||
@ -1036,7 +1049,7 @@ void
|
||||
xmlParserInputShrink(xmlParserInputPtr in) {
|
||||
int used;
|
||||
int ret;
|
||||
int index;
|
||||
int indx;
|
||||
|
||||
#ifdef DEBUG_INPUT
|
||||
xmlGenericError(xmlGenericErrorContext, "Shrink\n");
|
||||
@ -1053,7 +1066,7 @@ xmlParserInputShrink(xmlParserInputPtr in) {
|
||||
* Do not shrink on large buffers whose only a tiny fraction
|
||||
* was consumned
|
||||
*/
|
||||
if (in->buf->buffer->use > used + 2 * INPUT_CHUNK)
|
||||
if ((int) in->buf->buffer->use > used + 2 * INPUT_CHUNK)
|
||||
return;
|
||||
if (used > INPUT_CHUNK) {
|
||||
ret = xmlBufferShrink(in->buf->buffer, used - LINE_LEN);
|
||||
@ -1074,9 +1087,9 @@ xmlParserInputShrink(xmlParserInputPtr in) {
|
||||
/*
|
||||
* the buffer has been realloced
|
||||
*/
|
||||
index = in->cur - in->base;
|
||||
indx = in->cur - in->base;
|
||||
in->base = in->buf->buffer->content;
|
||||
in->cur = &in->buf->buffer->content[index];
|
||||
in->cur = &in->buf->buffer->content[indx];
|
||||
}
|
||||
in->end = &in->buf->buffer->content[in->buf->buffer->use];
|
||||
|
||||
@ -1481,18 +1494,16 @@ encoding_error:
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCopyChar:
|
||||
* @len: pointer to the length of the char read (or zero)
|
||||
* @array: pointer to an arry of xmlChar
|
||||
* xmlCopyCharMultiByte:
|
||||
* @out: pointer to an arry of xmlChar
|
||||
* @val: the char value
|
||||
*
|
||||
* append the char value in the array
|
||||
*
|
||||
* Returns the number of xmlChar written
|
||||
*/
|
||||
|
||||
int
|
||||
xmlCopyChar(int len, xmlChar *out, int val) {
|
||||
xmlCopyCharMultiByte(xmlChar *out, int val) {
|
||||
/*
|
||||
* We are supposed to handle UTF8, check it's valid
|
||||
* From rfc2044: encoding of the Unicode values on UTF-8:
|
||||
@ -1502,34 +1513,45 @@ xmlCopyChar(int len, xmlChar *out, int val) {
|
||||
* 0000 0080-0000 07FF 110xxxxx 10xxxxxx
|
||||
* 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
|
||||
*/
|
||||
if (len == 0) {
|
||||
if (val < 0) len = 0;
|
||||
else if (val < 0x80) len = 1;
|
||||
else if (val < 0x800) len = 2;
|
||||
else if (val < 0x10000) len = 3;
|
||||
else if (val < 0x110000) len = 4;
|
||||
if (len == 0) {
|
||||
if (val >= 0x80) {
|
||||
xmlChar *savedout = out;
|
||||
int bits;
|
||||
if (val < 0x800) { *out++= (val >> 6) | 0xC0; bits= 0; }
|
||||
else if (val < 0x10000) { *out++= (val >> 12) | 0xE0; bits= 6;}
|
||||
else if (val < 0x110000) { *out++= (val >> 18) | 0xF0; bits= 12; }
|
||||
else {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Internal error, xmlCopyChar 0x%X out of bound\n",
|
||||
val);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
if (len > 1) {
|
||||
int bits;
|
||||
|
||||
if (val < 0x80) { *out++= val; bits= -6; }
|
||||
else if (val < 0x800) { *out++= (val >> 6) | 0xC0; bits= 0; }
|
||||
else if (val < 0x10000) { *out++= (val >> 12) | 0xE0; bits= 6; }
|
||||
else { *out++= (val >> 18) | 0xF0; bits= 12; }
|
||||
|
||||
for ( ; bits >= 0; bits-= 6)
|
||||
*out++= ((val >> bits) & 0x3F) | 0x80 ;
|
||||
|
||||
return(len);
|
||||
for ( ; bits >= 0; bits-= 6)
|
||||
*out++= ((val >> bits) & 0x3F) | 0x80 ;
|
||||
return (out - savedout);
|
||||
}
|
||||
*out = (xmlChar) val;
|
||||
return(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCopyChar:
|
||||
* @len: Ignored, compatibility
|
||||
* @out: pointer to an arry of xmlChar
|
||||
* @val: the char value
|
||||
*
|
||||
* append the char value in the array
|
||||
*
|
||||
* Returns the number of xmlChar written
|
||||
*/
|
||||
|
||||
int
|
||||
xmlCopyChar(int len UNUSED, xmlChar *out, int val) {
|
||||
/* the len parameter is ignored */
|
||||
if (val >= 0x80) {
|
||||
return(xmlCopyCharMultiByte (out, val));
|
||||
}
|
||||
*out = (xmlChar) val;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -2575,8 +2597,8 @@ xmlCheckLanguageID(const xmlChar *lang) {
|
||||
* must deallocate it !
|
||||
*/
|
||||
xmlChar *
|
||||
xmlDecodeEntities(xmlParserCtxtPtr ctxt, int len, int what,
|
||||
xmlChar end, xmlChar end2, xmlChar end3) {
|
||||
xmlDecodeEntities(xmlParserCtxtPtr ctxt UNUSED, int len UNUSED, int what UNUSED,
|
||||
xmlChar end UNUSED, xmlChar end2 UNUSED, xmlChar end3 UNUSED) {
|
||||
#if 0
|
||||
xmlChar *buffer = NULL;
|
||||
unsigned int buffer_size = 0;
|
||||
@ -2709,7 +2731,7 @@ xmlDecodeEntities(xmlParserCtxtPtr ctxt, int len, int what,
|
||||
*/
|
||||
|
||||
xmlChar *
|
||||
xmlNamespaceParseNCName(xmlParserCtxtPtr ctxt) {
|
||||
xmlNamespaceParseNCName(xmlParserCtxtPtr ctxt UNUSED) {
|
||||
#if 0
|
||||
xmlChar buf[XML_MAX_NAMELEN + 5];
|
||||
int len = 0, l;
|
||||
@ -2778,7 +2800,7 @@ xmlGenericError(xmlGenericErrorContext,
|
||||
*/
|
||||
|
||||
xmlChar *
|
||||
xmlNamespaceParseQName(xmlParserCtxtPtr ctxt, xmlChar **prefix) {
|
||||
xmlNamespaceParseQName(xmlParserCtxtPtr ctxt UNUSED, xmlChar **prefix UNUSED) {
|
||||
|
||||
static int deprecated = 0;
|
||||
if (!deprecated) {
|
||||
@ -2820,7 +2842,7 @@ xmlNamespaceParseQName(xmlParserCtxtPtr ctxt, xmlChar **prefix) {
|
||||
*/
|
||||
|
||||
xmlChar *
|
||||
xmlNamespaceParseNSDef(xmlParserCtxtPtr ctxt) {
|
||||
xmlNamespaceParseNSDef(xmlParserCtxtPtr ctxt UNUSED) {
|
||||
static int deprecated = 0;
|
||||
if (!deprecated) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
@ -2855,7 +2877,7 @@ xmlNamespaceParseNSDef(xmlParserCtxtPtr ctxt) {
|
||||
* Returns the string parser or NULL.
|
||||
*/
|
||||
xmlChar *
|
||||
xmlParseQuotedString(xmlParserCtxtPtr ctxt) {
|
||||
xmlParseQuotedString(xmlParserCtxtPtr ctxt UNUSED) {
|
||||
static int deprecated = 0;
|
||||
if (!deprecated) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
@ -2953,7 +2975,7 @@ xmlGenericError(xmlGenericErrorContext,
|
||||
*/
|
||||
|
||||
void
|
||||
xmlParseNamespace(xmlParserCtxtPtr ctxt) {
|
||||
xmlParseNamespace(xmlParserCtxtPtr ctxt UNUSED) {
|
||||
static int deprecated = 0;
|
||||
if (!deprecated) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
@ -3080,7 +3102,7 @@ xmlGenericError(xmlGenericErrorContext,
|
||||
*/
|
||||
|
||||
xmlChar *
|
||||
xmlScanName(xmlParserCtxtPtr ctxt) {
|
||||
xmlScanName(xmlParserCtxtPtr ctxt UNUSED) {
|
||||
static int deprecated = 0;
|
||||
if (!deprecated) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
@ -3153,7 +3175,7 @@ xmlScanName(xmlParserCtxtPtr ctxt) {
|
||||
* http://www.w3.org/TR/REC-xml#entproc
|
||||
*/
|
||||
void
|
||||
xmlParserHandleReference(xmlParserCtxtPtr ctxt) {
|
||||
xmlParserHandleReference(xmlParserCtxtPtr ctxt UNUSED) {
|
||||
static int deprecated = 0;
|
||||
if (!deprecated) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
@ -3399,7 +3421,7 @@ xmlGenericError(xmlGenericErrorContext,
|
||||
*/
|
||||
|
||||
void
|
||||
xmlHandleEntity(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
|
||||
xmlHandleEntity(xmlParserCtxtPtr ctxt UNUSED, xmlEntityPtr entity UNUSED) {
|
||||
static int deprecated = 0;
|
||||
if (!deprecated) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
@ -3452,7 +3474,8 @@ handle_as_char:
|
||||
* Returns NULL this functionnality had been removed
|
||||
*/
|
||||
xmlNsPtr
|
||||
xmlNewGlobalNs(xmlDocPtr doc, const xmlChar *href, const xmlChar *prefix) {
|
||||
xmlNewGlobalNs(xmlDocPtr doc UNUSED, const xmlChar *href UNUSED,
|
||||
const xmlChar *prefix UNUSED) {
|
||||
static int deprecated = 0;
|
||||
if (!deprecated) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
@ -3513,7 +3536,7 @@ xmlNewGlobalNs(xmlDocPtr doc, const xmlChar *href, const xmlChar *prefix) {
|
||||
* DEPRECATED
|
||||
*/
|
||||
void
|
||||
xmlUpgradeOldNs(xmlDocPtr doc) {
|
||||
xmlUpgradeOldNs(xmlDocPtr doc UNUSED) {
|
||||
static int deprecated = 0;
|
||||
if (!deprecated) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
|
Reference in New Issue
Block a user