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:
65
entities.c
65
entities.c
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user