1
0
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:
Daniel Veillard
2001-03-24 17:00:36 +00:00
parent c7ad7ce598
commit 56a4cb8c4d
49 changed files with 1261 additions and 1186 deletions

View File

@ -41,6 +41,7 @@
#include <libxml/parserInternals.h>
#include <libxml/xmlerror.h>
#include <libxml/HTMLparser.h>
#include <libxml/HTMLtree.h>
#include <libxml/entities.h>
#include <libxml/encoding.h>
#include <libxml/valid.h>
@ -55,6 +56,21 @@
int htmlOmittedDefaultValue = 1;
/************************************************************************
* *
* When running GCC in vaacum cleaner mode *
* *
************************************************************************/
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
xmlChar * htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len,
xmlChar end, xmlChar end2, xmlChar end3);
/************************************************************************
* *
* Parser stacks related functions and macros *
@ -95,8 +111,8 @@ scope type html##name##Pop(htmlParserCtxtPtr ctxt) { \
return(ret); \
} \
PUSH_AND_POP(extern, xmlNodePtr, node)
PUSH_AND_POP(extern, xmlChar*, name)
/* PUSH_AND_POP(static, xmlNodePtr, node) */
PUSH_AND_POP(static, xmlChar*, name)
/*
* Macros for accessing the content. Those should be used only by the parser,
@ -189,7 +205,7 @@ PUSH_AND_POP(extern, xmlChar*, name)
* Returns the current char value and its lenght
*/
int
static int
htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
if (ctxt->instate == XML_PARSER_EOF)
return(0);
@ -305,31 +321,6 @@ encoding_error:
return((int) *ctxt->input->cur);
}
/**
* htmlNextChar:
* @ctxt: the HTML parser context
*
* Skip to the next char input char.
*/
void
htmlNextChar(htmlParserCtxtPtr ctxt) {
if (ctxt->instate == XML_PARSER_EOF)
return;
if ((*ctxt->input->cur == 0) &&
(xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) {
xmlPopInput(ctxt);
} else {
if (*(ctxt->input->cur) == '\n') {
ctxt->input->line++; ctxt->input->col = 1;
} else ctxt->input->col++;
ctxt->input->cur++;
ctxt->nbChars++;
if (*ctxt->input->cur == 0)
xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
}
}
/**
* htmlSkipBlankChars:
* @ctxt: the HTML parser context
@ -339,7 +330,7 @@ htmlNextChar(htmlParserCtxtPtr ctxt) {
* Returns the number of space chars skipped
*/
int
static int
htmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
int res = 0;
@ -478,7 +469,7 @@ htmlElemDesc html40ElementTable[] = {
* any tag of each line implies the end of the current element if the type of
* that element is in the same line
*/
char *htmlEquEnd[] = {
const char *htmlEquEnd[] = {
"dt", "dd", "li", "option", NULL,
"h1", "h2", "h3", "h4", "h5", "h6", NULL,
"ol", "menu", "dir", "address", "pre", "listing", "xmp", NULL,
@ -493,7 +484,7 @@ NULL
/*
* start tags that imply the end of current element
*/
char *htmlStartClose[] = {
const char *htmlStartClose[] = {
"form", "form", "p", "hr", "h1", "h2", "h3", "h4", "h5", "h6",
"dl", "ul", "ol", "menu", "dir", "address", "pre",
"listing", "xmp", "head", NULL,
@ -557,7 +548,7 @@ NULL
* TODO: extend that list by reading the HTML SGML DtD on
* implied paragraph
*/
static char *htmlNoContentElements[] = {
static const char *htmlNoContentElements[] = {
"html",
"head",
"body",
@ -569,7 +560,7 @@ static char *htmlNoContentElements[] = {
* NOTE: when adding ones, check htmlIsScriptAttribute() since
* it assumes the name starts with 'on'
*/
static char *htmlScriptAttributes[] = {
static const char *htmlScriptAttributes[] = {
"onclick",
"ondblclick",
"onmousedown",
@ -591,7 +582,7 @@ static char *htmlScriptAttributes[] = {
};
static char** htmlStartCloseIndex[100];
static const char** htmlStartCloseIndex[100];
static int htmlStartCloseIndexinitialized = 0;
/************************************************************************
@ -609,14 +600,14 @@ static int htmlStartCloseIndexinitialized = 0;
*/
void
htmlInitAutoClose(void) {
int index, i = 0;
int indx, i = 0;
if (htmlStartCloseIndexinitialized) return;
for (index = 0;index < 100;index ++) htmlStartCloseIndex[index] = NULL;
index = 0;
while ((htmlStartClose[i] != NULL) && (index < 100 - 1)) {
htmlStartCloseIndex[index++] = &htmlStartClose[i];
for (indx = 0;indx < 100;indx ++) htmlStartCloseIndex[indx] = NULL;
indx = 0;
while ((htmlStartClose[i] != NULL) && (indx < 100 - 1)) {
htmlStartCloseIndex[indx++] = &htmlStartClose[i];
while (htmlStartClose[i] != NULL) i++;
i++;
}
@ -633,7 +624,7 @@ htmlInitAutoClose(void) {
*/
htmlElemDescPtr
htmlTagLookup(const xmlChar *tag) {
int i;
unsigned int i;
for (i = 0; i < (sizeof(html40ElementTable) /
sizeof(html40ElementTable[0]));i++) {
@ -653,21 +644,21 @@ htmlTagLookup(const xmlChar *tag) {
*
* Returns 0 if no, 1 if yes.
*/
int
static int
htmlCheckAutoClose(const xmlChar *newtag, const xmlChar *oldtag) {
int i, index;
char **close = NULL;
int i, indx;
const char **closed = NULL;
if (htmlStartCloseIndexinitialized == 0) htmlInitAutoClose();
/* inefficient, but not a big deal */
for (index = 0; index < 100;index++) {
close = htmlStartCloseIndex[index];
if (close == NULL) return(0);
if (xmlStrEqual(BAD_CAST *close, newtag)) break;
for (indx = 0; indx < 100;indx++) {
closed = htmlStartCloseIndex[indx];
if (closed == NULL) return(0);
if (xmlStrEqual(BAD_CAST *closed, newtag)) break;
}
i = close - htmlStartClose;
i = closed - htmlStartClose;
i++;
while (htmlStartClose[i] != NULL) {
if (xmlStrEqual(BAD_CAST htmlStartClose[i], oldtag)) {
@ -685,7 +676,7 @@ htmlCheckAutoClose(const xmlChar *newtag, const xmlChar *oldtag) {
*
* The HTmL DtD allows an ending tag to implicitely close other tags.
*/
void
static void
htmlAutoCloseOnClose(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
htmlElemDescPtr info;
xmlChar *oldname;
@ -739,7 +730,7 @@ htmlAutoCloseOnClose(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
* If newtag is NULL this mean we are at the end of the resource
* and we should check
*/
void
static void
htmlAutoClose(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
xmlChar *oldname;
while ((newtag != NULL) && (ctxt->name != NULL) &&
@ -843,7 +834,7 @@ htmlIsAutoClosed(htmlDocPtr doc, htmlNodePtr elem) {
* called when a new tag has been detected and generates the
* appropriates implicit tags if missing
*/
void
static void
htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
if (!htmlOmittedDefaultValue)
return;
@ -909,7 +900,7 @@ htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
* in case of error.
*/
int
static int
htmlCheckParagraph(htmlParserCtxtPtr ctxt) {
const xmlChar *tag;
int i;
@ -953,7 +944,7 @@ htmlCheckParagraph(htmlParserCtxtPtr ctxt) {
*/
int
htmlIsScriptAttribute(const xmlChar *name) {
int i;
unsigned int i;
if (name == NULL)
return(0);
@ -1113,7 +1104,7 @@ htmlEntityDesc html40EntitiesTable[] = {
{ 920, "Theta","greek capital letter theta, U+0398 ISOgrk3" },
{ 921, "Iota", "greek capital letter iota, U+0399" },
{ 922, "Kappa","greek capital letter kappa, U+039A" },
{ 923, "Lambda""greek capital letter lambda, U+039B ISOgrk3" },
{ 923, "Lambda", "greek capital letter lambda, U+039B ISOgrk3" },
{ 924, "Mu", "greek capital letter mu, U+039C" },
{ 925, "Nu", "greek capital letter nu, U+039D" },
{ 926, "Xi", "greek capital letter xi, U+039E ISOgrk3" },
@ -1291,7 +1282,7 @@ htmlEntityDesc html40EntitiesTable[] = {
*/
htmlEntityDescPtr
htmlEntityLookup(const xmlChar *name) {
int i;
unsigned int i;
for (i = 0;i < (sizeof(html40EntitiesTable)/
sizeof(html40EntitiesTable[0]));i++) {
@ -1316,16 +1307,16 @@ htmlEntityLookup(const xmlChar *name) {
* Returns the associated htmlEntityDescPtr if found, NULL otherwise.
*/
htmlEntityDescPtr
htmlEntityValueLookup(int value) {
int i;
htmlEntityValueLookup(unsigned int value) {
unsigned int i;
#ifdef DEBUG
int lv = 0;
#endif
for (i = 0;i < (sizeof(html40EntitiesTable)/
sizeof(html40EntitiesTable[0]));i++) {
if ((unsigned int) html40EntitiesTable[i].value >= value) {
if ((unsigned int) html40EntitiesTable[i].value > value)
if (html40EntitiesTable[i].value >= value) {
if (html40EntitiesTable[i].value > value)
break;
#ifdef DEBUG
xmlGenericError(xmlGenericErrorContext,"Found entity %s\n", html40EntitiesTable[i].name);
@ -1503,7 +1494,8 @@ htmlEncodeEntities(unsigned char* out, int *outlen,
}
/* assertion: c is a single UTF-4 value */
if (c < 0x80 && c != quoteChar && c != '&' && c != '<' && c != '>') {
if ((c < 0x80) && (c != (unsigned int) quoteChar) &&
(c != '&') && (c != '<') && (c != '>')) {
if (out >= outend)
break;
*out++ = c;
@ -1554,8 +1546,16 @@ htmlEncodeEntities(unsigned char* out, int *outlen,
* must deallocate it !
*/
xmlChar *
htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len,
xmlChar end, xmlChar end2, xmlChar end3) {
htmlDecodeEntities(htmlParserCtxtPtr ctxt UNUSED, int len UNUSED,
xmlChar end UNUSED, xmlChar end2 UNUSED, xmlChar end3 UNUSED) {
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"htmlDecodeEntities() deprecated function reached\n");
deprecated = 1;
}
return(NULL);
#if 0
xmlChar *name = NULL;
xmlChar *buffer = NULL;
unsigned int buffer_size = 0;
@ -1627,6 +1627,7 @@ htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len,
}
buffer[nbchars++] = 0;
return(buffer);
#endif
}
/************************************************************************
@ -1635,26 +1636,6 @@ htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len,
* *
************************************************************************/
/**
* htmlFreeInputStream:
* @input: an htmlParserInputPtr
*
* Free up an input stream.
*/
void
htmlFreeInputStream(htmlParserInputPtr input) {
if (input == NULL) return;
if (input->filename != NULL) xmlFree((char *) input->filename);
if (input->directory != NULL) xmlFree((char *) input->directory);
if ((input->free != NULL) && (input->base != NULL))
input->free((xmlChar *) input->base);
if (input->buf != NULL)
xmlFreeParserInputBuffer(input->buf);
MEM_CLEANUP(input, sizeof(htmlParserInput));
xmlFree(input);
}
/**
* htmlNewInputStream:
* @ctxt: an HTML parser context
@ -1662,7 +1643,7 @@ htmlFreeInputStream(htmlParserInputPtr input) {
* Create a new input stream structure
* Returns the new input stream or NULL
*/
htmlParserInputPtr
static htmlParserInputPtr
htmlNewInputStream(htmlParserCtxtPtr ctxt) {
htmlParserInputPtr input;
@ -1741,37 +1722,6 @@ static int areBlanks(htmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
return(1);
}
/**
* htmlHandleEntity:
* @ctxt: an HTML parser context
* @entity: an XML entity pointer.
*
* Default handling of an HTML entity, call the parser with the
* substitution string
*/
void
htmlHandleEntity(htmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
int len;
if (entity->content == NULL) {
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData, "htmlHandleEntity %s: content == NULL\n",
entity->name);
ctxt->wellFormed = 0;
return;
}
len = xmlStrlen(entity->content);
/*
* Just handle the content as a set of chars.
*/
htmlCheckParagraph(ctxt);
if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData, entity->content, len);
}
/**
* htmlNewDocNoDtD:
* @URI: URI for the dtd, or NULL
@ -1857,7 +1807,7 @@ htmlNewDoc(const xmlChar *URI, const xmlChar *ExternalID) {
* Returns the Tag Name parsed or NULL
*/
xmlChar *
static xmlChar *
htmlParseHTMLName(htmlParserCtxtPtr ctxt) {
xmlChar *ret = NULL;
int i = 0;
@ -1890,7 +1840,7 @@ htmlParseHTMLName(htmlParserCtxtPtr ctxt) {
* Returns the Name parsed or NULL
*/
xmlChar *
static xmlChar *
htmlParseName(htmlParserCtxtPtr ctxt) {
xmlChar buf[HTML_MAX_NAMELEN];
int len = 0;
@ -1933,7 +1883,7 @@ htmlParseName(htmlParserCtxtPtr ctxt) {
* Returns the attribute parsed or NULL
*/
xmlChar *
static xmlChar *
htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
xmlChar *buffer = NULL;
int buffer_size = 0;
@ -1982,20 +1932,20 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
if (name == NULL) {
*out++ = '&';
if (out - buffer > buffer_size - 100) {
int index = out - buffer;
int indx = out - buffer;
growBuffer(buffer);
out = &buffer[index];
out = &buffer[indx];
}
} else if (ent == NULL) {
*out++ = '&';
cur = name;
while (*cur != 0) {
if (out - buffer > buffer_size - 100) {
int index = out - buffer;
int indx = out - buffer;
growBuffer(buffer);
out = &buffer[index];
out = &buffer[indx];
}
*out++ = *cur++;
}
@ -2005,10 +1955,10 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
int bits;
if (out - buffer > buffer_size - 100) {
int index = out - buffer;
int indx = out - buffer;
growBuffer(buffer);
out = &buffer[index];
out = &buffer[indx];
}
c = (xmlChar)ent->value;
if (c < 0x80)
@ -2031,10 +1981,10 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
int bits, l;
if (out - buffer > buffer_size - 100) {
int index = out - buffer;
int indx = out - buffer;
growBuffer(buffer);
out = &buffer[index];
out = &buffer[indx];
}
c = CUR_CHAR(l);
if (c < 0x80)
@ -2056,43 +2006,6 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
return(buffer);
}
/**
* htmlParseNmtoken:
* @ctxt: an HTML parser context
*
* parse an HTML Nmtoken.
*
* Returns the Nmtoken parsed or NULL
*/
xmlChar *
htmlParseNmtoken(htmlParserCtxtPtr ctxt) {
xmlChar buf[HTML_MAX_NAMELEN];
int len = 0;
GROW;
while ((IS_LETTER(CUR)) || (IS_DIGIT(CUR)) ||
(CUR == '.') || (CUR == '-') ||
(CUR == '_') || (CUR == ':') ||
(IS_COMBINING(CUR)) ||
(IS_EXTENDER(CUR))) {
buf[len++] = CUR;
NEXT;
if (len >= HTML_MAX_NAMELEN) {
xmlGenericError(xmlGenericErrorContext,
"htmlParseNmtoken: reached HTML_MAX_NAMELEN limit\n");
while ((IS_LETTER(CUR)) || (IS_DIGIT(CUR)) ||
(CUR == '.') || (CUR == '-') ||
(CUR == '_') || (CUR == ':') ||
(IS_COMBINING(CUR)) ||
(IS_EXTENDER(CUR)))
NEXT;
break;
}
}
return(xmlStrndup(buf, len));
}
/**
* htmlParseEntityRef:
* @ctxt: an HTML parser context
@ -2152,7 +2065,7 @@ htmlParseEntityRef(htmlParserCtxtPtr ctxt, xmlChar **str) {
* Returns the AttValue parsed or NULL.
*/
xmlChar *
static xmlChar *
htmlParseAttValue(htmlParserCtxtPtr ctxt) {
xmlChar *ret = NULL;
@ -2199,7 +2112,7 @@ htmlParseAttValue(htmlParserCtxtPtr ctxt) {
* Returns the SystemLiteral parsed or NULL
*/
xmlChar *
static xmlChar *
htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) {
const xmlChar *q;
xmlChar *ret = NULL;
@ -2251,7 +2164,7 @@ htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) {
* Returns the PubidLiteral parsed or NULL.
*/
xmlChar *
static xmlChar *
htmlParsePubidLiteral(htmlParserCtxtPtr ctxt) {
const xmlChar *q;
xmlChar *ret = NULL;
@ -2313,7 +2226,7 @@ htmlParsePubidLiteral(htmlParserCtxtPtr ctxt) {
* as CDATA but SGML allows entities references in attributes so their
* processing is identical as other attributes
*/
void
static void
htmlParseScript(htmlParserCtxtPtr ctxt) {
xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 1];
int nbchar = 0;
@ -2368,7 +2281,6 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
/**
* htmlParseCharData:
* @ctxt: an HTML parser context
* @cdata: int indicating whether we are within a CDATA section
*
* parse a CharData section.
* if we are within a CDATA section ']]>' marks an end of section.
@ -2376,8 +2288,8 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
* [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
*/
void
htmlParseCharData(htmlParserCtxtPtr ctxt, int cdata) {
static void
htmlParseCharData(htmlParserCtxtPtr ctxt) {
xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 5];
int nbchar = 0;
int cur, l;
@ -2429,14 +2341,9 @@ htmlParseCharData(htmlParserCtxtPtr ctxt, int cdata) {
* htmlParseExternalID:
* @ctxt: an HTML parser context
* @publicID: a xmlChar** receiving PubidLiteral
* @strict: indicate whether we should restrict parsing to only
* production [75], see NOTE below
*
* Parse an External ID or a Public ID
*
* NOTE: Productions [75] and [83] interract badly since [75] can generate
* 'PUBLIC' S PubidLiteral S SystemLiteral
*
* [75] ExternalID ::= 'SYSTEM' S SystemLiteral
* | 'PUBLIC' S PubidLiteral S SystemLiteral
*
@ -2447,8 +2354,8 @@ htmlParseCharData(htmlParserCtxtPtr ctxt, int cdata) {
* it is possible to return NULL and have publicID set.
*/
xmlChar *
htmlParseExternalID(htmlParserCtxtPtr ctxt, xmlChar **publicID, int strict) {
static xmlChar *
htmlParseExternalID(htmlParserCtxtPtr ctxt, xmlChar **publicID) {
xmlChar *URI = NULL;
if ((UPPER == 'S') && (UPP(1) == 'Y') &&
@ -2503,7 +2410,7 @@ htmlParseExternalID(htmlParserCtxtPtr ctxt, xmlChar **publicID, int strict) {
*
* [15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
*/
void
static void
htmlParseComment(htmlParserCtxtPtr ctxt) {
xmlChar *buf = NULL;
int len;
@ -2662,7 +2569,7 @@ htmlParseCharRef(htmlParserCtxtPtr ctxt) {
* ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
*/
void
static void
htmlParseDocTypeDecl(htmlParserCtxtPtr ctxt) {
xmlChar *name;
xmlChar *ExternalID = NULL;
@ -2693,7 +2600,7 @@ htmlParseDocTypeDecl(htmlParserCtxtPtr ctxt) {
/*
* Check for SystemID and ExternalID
*/
URI = htmlParseExternalID(ctxt, &ExternalID, 0);
URI = htmlParseExternalID(ctxt, &ExternalID);
SKIP_BLANKS;
/*
@ -2743,7 +2650,7 @@ htmlParseDocTypeDecl(htmlParserCtxtPtr ctxt) {
* Returns the attribute name, and the value in *value.
*/
xmlChar *
static xmlChar *
htmlParseAttribute(htmlParserCtxtPtr ctxt, xmlChar **value) {
xmlChar *name, *val = NULL;
@ -2786,7 +2693,7 @@ htmlParseAttribute(htmlParserCtxtPtr ctxt, xmlChar **value) {
* If a new encoding is detected the parser is switched to decode
* it and pass UTF8
*/
void
static void
htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
const xmlChar *encoding;
@ -2869,7 +2776,7 @@ htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
*
* Checks an attributes from a Meta tag
*/
void
static void
htmlCheckMeta(htmlParserCtxtPtr ctxt, const xmlChar **atts) {
int i;
const xmlChar *att, *value;
@ -2914,7 +2821,7 @@ htmlCheckMeta(htmlParserCtxtPtr ctxt, const xmlChar **atts) {
*
*/
void
static void
htmlParseStartTag(htmlParserCtxtPtr ctxt) {
xmlChar *name;
xmlChar *attname;
@ -2975,9 +2882,9 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
return;
}
if (xmlStrEqual(name, BAD_CAST"body")) {
int i;
for (i = 0;i < ctxt->nameNr;i++) {
if (xmlStrEqual(ctxt->nameTab[i], BAD_CAST"body")) {
int indx;
for (indx = 0;indx < ctxt->nameNr;indx++) {
if (xmlStrEqual(ctxt->nameTab[indx], BAD_CAST"body")) {
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData,
"htmlParseStartTag: misplaced <body> tag\n");
@ -3108,7 +3015,7 @@ failed:
* [NS 9] ETag ::= '</' QName S? '>'
*/
void
static void
htmlParseEndTag(htmlParserCtxtPtr ctxt) {
xmlChar *name;
xmlChar *oldname;
@ -3213,7 +3120,7 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt) {
* this will end-up in a call to character() since this is either a
* CharRef, or a predefined entity.
*/
void
static void
htmlParseReference(htmlParserCtxtPtr ctxt) {
htmlEntityDescPtr ent;
xmlChar out[6];
@ -3292,7 +3199,7 @@ htmlParseReference(htmlParserCtxtPtr ctxt) {
*
*/
void
static void
htmlParseContent(htmlParserCtxtPtr ctxt) {
xmlChar *currentNode;
int depth;
@ -3381,7 +3288,7 @@ htmlParseContent(htmlParserCtxtPtr ctxt) {
* Last case, text. Note that References are handled directly.
*/
else {
htmlParseCharData(ctxt, 0);
htmlParseCharData(ctxt);
}
if (cons == ctxt->nbChars) {
@ -3592,7 +3499,7 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
* as a result of the parsing.
*/
int
static int
htmlParseDocument(htmlParserCtxtPtr ctxt) {
xmlDtdPtr dtd;
@ -3696,7 +3603,7 @@ htmlParseDocument(htmlParserCtxtPtr ctxt) {
* Initialize a parser context
*/
void
static void
htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
{
htmlSAXHandler *sax;
@ -3806,10 +3713,12 @@ htmlFreeParserCtxt(htmlParserCtxtPtr ctxt)
*
* Create a parser context for an HTML document.
*
* TODO: check the need to add encoding handling there
*
* Returns the new parser context or NULL
*/
htmlParserCtxtPtr
htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding) {
static htmlParserCtxtPtr
htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding UNUSED) {
htmlParserCtxtPtr ctxt;
htmlParserInputPtr input;
/* htmlCharEncoding enc; */
@ -3860,7 +3769,7 @@ htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding) {
* Returns the index to the current parsing point if the full sequence
* is available, -1 otherwise.
*/
int
static int
htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
xmlChar next, xmlChar third) {
int base, len;
@ -3933,7 +3842,7 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
*
* Returns zero if no parsing was possible
*/
int
static int
htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
int ret = 0;
htmlParserInputPtr in;
@ -4158,7 +4067,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
goto done;
cur = in->cur[0];
if (IS_BLANK(cur)) {
htmlParseCharData(ctxt, 0);
htmlParseCharData(ctxt);
goto done;
}
if (avail < 2)
@ -4466,7 +4375,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
xmlGenericError(xmlGenericErrorContext,
"HPP: Parsing char data\n");
#endif
htmlParseCharData(ctxt, 0);
htmlParseCharData(ctxt);
}
}
if (cons == ctxt->nbChars) {
@ -4621,19 +4530,6 @@ done:
return(ret);
}
/**
* htmlParseTry:
* @ctxt: an HTML parser context
*
* Try to progress on parsing
*
* Returns zero if no parsing was possible
*/
int
htmlParseTry(htmlParserCtxtPtr ctxt) {
return(htmlParseTryOrFinish(ctxt, 0));
}
/**
* htmlParseChunk:
* @ctxt: an XML parser context